As a good exercise for someone very new to Python, I wanted to learn how to create simple graphics and interactive images using Python scripting.
Starting off with what I learned in class, using Processing, we create a class which we identify as Star and set the locations of the stars on the X and Y values at random, as well as the random colors they have.Â
The def twinkle(self) helps randomize the colors and the brightness of the stars. I se the first numbers to be low because I wanted the changes to be drastic.
I wanted to, unlike in class, go for a background sky more similar to a sun setting. The def setup(): creates the gradient for the background and the 3 values in parenthesis by adjust the color of between the number 0 and 255. 255, 100, and 0 creates an orange bottom while the 0, 0, 70 creates a dark blue top.
This final chunk of code allows the user to add stars in the sky by pressing on their mouse key and for the def keyPressed, when R is pressed, the stars begin to randomize, and when D or P is pressed on the keyboard, the color changes to a dark purple and blackish blue gradient.