Star simulation with geometry

I developed a code, just for fun, to simulate a star using only geometric shapes and a modified texture of the Sun’s surface.

First, I acquired the texture:

tex = Map[ImageAdjust[#, {0, 0, 0.1}] &, 
  WebImageSearch["Sun surface", Method -> "Google", 
   MaxItems -> 8]]; list = Flatten[{tex[[1]], tex[[3 ;; 7]]}]

Then, I created the geometric shape of the star (and added the texture). Just replace the “list” in the code below with the texture list above (the evaluation can take up to 5 minutes):

z1 = Table[n = RandomPolygon[{"StarShaped", 10000}]; 
   a = PolygonDecomposition[n, "Triangle"]; 
   b = Table[
     Map[Disk[#, 0.001] &, RandomPoint[a[[i]], 40]], {i, 1, 
      Length@a}]; 
   Show[{Graphics[{Texture[{"list"}[[x]]], 
       RandomPolygon[{"StarShaped", 10000}, 
        VertexTextureCoordinates -> Automatic], ImageSize -> 1000}], 
     Graphics[{Opacity[0.3], Red, b}]}], {x, 1, 6}];

The animation can be done with, for example, ListAnimate[]:

ListAnimate[z1, AnimationRate -> 0.5]

star.gif

Thanks.

9 Likes

enter image description here – you have earned Featured Contributor Badge
2015-11-02_10-07-11.png

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!

1 Like

Texture[{“list”}[]]

should it be

Texture[list[[x]]]

?

Hi Shenghui,

Yes, you are correct, but… I left it that way on purpose, as I needed to manually replace {“list”} with the list of images above.. for some reason list[[x]] does not work automatically in the Texture[] (at least on my PC)…