Message Boards Message Boards


Star simulation with geometry

Posted 1 year ago
3 Replies
10 Total Likes

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, 
       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]



3 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 and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!


should it be



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)...

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract