Group Abstract Group Abstract

Message Boards Message Boards

[GIF] Gerontocracy (circular slices of a triangle)

Overlapping circle arcs forming a triangle

Gerontocracy

I'm extremely interested in using slices of an object to implicitly reconstruct the object itself. Of course, this is most obviously useful for high-dimensional objects, but it can also lead to some interesting visualizations of low-dimensional objects. Here are a couple of examples.

Taking circle arc slices of an equilateral triangle isn't particularly interesting mathematically, but it still gives an interesting visual effect.

Here's the code:

cols = RGBColor /@ {"#118DF0", "#ECECDA", "#FF304F", "#0E2F56"}

Module[{polygonvertices, n},
 polygonvertices = {{0, 0}, {1, 0}, {1/2, Sqrt[3]/2}};
 n = 25;
 Manipulate[
  Graphics[{Thickness[.02], CapForm["Round"], 
    Flatten[Table[{cols[[i]], 
       Circle[polygonvertices[[i]], 
        r, {\[Pi] *2 (i - 1)/3, \[Pi] (2 i - 1)/3}]}, {r, s, 1.02, 
       1/n}, {i, 1, 3}], 1], EdgeForm[None], cols[[4]], 
    Polygon[{{3/2, 5}, {3/2, Sqrt[3]/2}, {1/2, Sqrt[3]/2}, {0, 
       0}, {-5, 0}, {-5, 5}}], 
    Polygon[{{1/2, 5}, {1/2, Sqrt[3]/2}, {1, 0}, {5, 0}}], 
    Polygon[{{0, 0}, {0, 1}, {-5, 1}, {-5, -5}, {5, -5}, {5, 1}, {1, 
       1}, {1, 0}}]}, 
   PlotRange -> {{-.1, 1.1}, {-0.16698729810778068`, 
      1.0330127018922193`}}, Background -> cols[[4]], 
   ImageSize -> 540], {s, 0., 1/n}]
 ]

(The stupid Polygon objects are to blank out the region outside the triangle. As already mentioned, I would be very happy to learn a better way to approximate the functionality of RegionFunction in a Graphics object.)

6 Replies

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: EDITORIAL BOARD
Posted 10 years ago

Indeed a beautiful GIF! Inspired by some of Vitaly's ideas, I came up with the following. I used Overlay and created a mask by means of a triangular AlphaChannel "hole" in the image. Hope this helps you to further improve this:

Manipulate[
 Module[{mask, cols},
  cols = RGBColor /@ {"#118DF0", "#ECECDA", "#FF304F", "#0E2F56"};
  mask = Image[
    Graphics[SSSTriangle[1, 1, 1], 
     PlotRange -> {{-.1, 1.1}, {-0.2, 1}}]];
  Overlay[{
    Graphics[{Thickness[.02], CapForm["Round"], 
      Table[{cols[[i]], 
        Circle[SSSTriangle[1, 1, 1][[-1, i]], 
         r, {2 \[Pi] /3 (i - 1), \[Pi] (2 i - 1)/3}]}, {r, s, 1.02, 
        1/n}, {i, 3}]}],
    SetAlphaChannel[Image[Graphics[{}, Background -> cols[[-1]]]], 
     mask]}]],
 {s, 0., 1/n}, {{n, 25}, None}]

enter image description here

POSTED BY: Erik Mahieu

Thanks, that's definitely cleaner than my solution.

It would still be nice to have a true RegionFunction replacement so that lines/curves/etc. don't just disappear under the background, but actually end. For example, I think this GIF would have been worse if the black lines were just disappearing under a light gray background rather than coming to rounded ends:

linear slices of a pentagon

Incidentally, I did try a ParametricPlot implementation of the GIF so that I could use RegionFunction, but the boundary-detection was too erratic to be useful. Here's what was produced:

buggy boundary detection

Notice how jumpy the circle arcs are near the boundary.

(By the way, thanks @Vitaliy Kaurov for the link...it looks very interesting.)

POSTED BY: Vitaliy Kaurov

I've already advocated a few times for a ClippingMask function, like illustrator/gimp/photoshop has. I think Mathematica really should have it. It probably already has such construct anyhow for the plotting functions.

ClippingMask[object,mask] which shows parts of object (or objects) that are covered by mask. Where mask can be a polygon, region, bspline, rectangle, disk, ellipse, .......

POSTED BY: Sander Huisman
Posted 10 years ago

By lack of better, I am using the following combination of Overlay and SetAplhaChannel to mask images with square or round masks (illustrated with a Manipulate):

Manipulate[Module[{im, sz, mask},
  im = ImageResize[ExampleData[{"TestImage", "Lena"}], 350];
  sz = ImageMeasurements[im, "Dimensions"];
  mask = ImageResize[
    ColorNegate@
     Blur[Image[Graphics[RegularPolygon[pos, r, n], PlotRange -> 1]], 
      blur], Most@sz];
  Overlay[{Switch[bg, "black", mask, "white", Nothing], 
    SetAlphaChannel[im, mask]}]],
 Grid[{
   {Control[{{r, .95, "size"}, .5, 1.25, ImageSize -> Small}], 
    Control[{{blur, 0}, 0, 50, ImageSize -> Small}]},
   {Control[{{n, 4, "shape"}, {3 -> "triangle", 4 -> "square", 
       36 -> "round"}}],
    Control[{{pos, {0, 0}, "position"}, {-.5, -.5}, {.5, .5}, 
      Slider2D, ImageSize -> 70}]},
   {Control[{{bg, "black", "color"}, {"black", "white"}}], 
    SpanFromAbove}}, Alignment -> {Left}, ItemSize -> 22]]

here are some results: enter image description here

POSTED BY: Erik Mahieu
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard