Star-shaped generation algorithm

I just found out about Logo yesterday. Being born in the nineties, I had never encountered this before. So I started using the online translation of Logo Interpreter , written by Joshua Bell, and I decided to write a circle function to create concentric circles. Here is what I wrote:

 cs to circle penup forward :radius right 90 pendown repeat 360 [forward 3.14 * :radius / 180 right 1] penup left 90 back :radius pendown end make "radius 30 repeat 160 [circle make "radius :radius + 30] 

Interestingly, the canvas for painting is a toroidal array. Consequently, the circles eventually overlap. Drawing 160 concentric circles with increasing radii by 30 times, I got the image as follows:

Logo starfield generated by 160 concentric circles with increasing radii in multiples of 30.

This is really amazing. At first glance, this looks like an authentic picture of the night sky, and it made me wonder if there is a general algorithm for drawing asterisks.

By the way, if you look carefully, you will see a grid of squares of pixels 30 x 30 . The borders are black, so it's a little hard to notice.

+4
source share
2 answers

As an avid player of the Dwarven Fortress, I would like to get a fractal formula for creating stars. In my opinion, a random computer is simply not good enough. Borrowing from the DF game again, I would add various steps to improve the stellar field, such as randomizing the shape, color, size, glow, cluster (deliberately adding a cluster of stars together).

If you want to go with realism, also simulate a gas background. Space is not white dots on a solid black background.

Finally, I would suggest you get some satellite images (from our old Hubble telescope friend) and try to copy it as accurately as possible. Then play with the options that you like (maybe you want to make a game out of this).

PS: I did not specify any coding language, because I think that this is not a question about the code (its quite simple), but a design question. You WOLD make it a lot easier in Flash / Actionscript than Java, trust me.

+5
source

The usual way to create a star field is to randomly select points in the x / y plane, in psuedocode something like:

 fill image with black for (however many stars you want) x = random() * width y = random() * height plot star at position x,y loop 

If you want a fantasy, you can also display stars with random brightness. Also remember that the stars flicker slightly, so if you make an animation and then change the brightness, each frame can make them more realistic.

+6
source

Source: https://habr.com/ru/post/1479384/


All Articles