Message Boards Message Boards

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

im1

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]

im2

Thanks.

POSTED BY: Claudio Chaib
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 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: Moderation Team
Texture[{"list"}[[x]]]

should it be

Texture[list[[x]]]

?

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

Group Abstract Group Abstract