Idea:
At first, I wanted to make a galaxy portrait where most of the screen would consist of stars of different shapes and sizes. But, then I realized in order to do that with oop, every star would be an individual object and I was not sure how I would make the program construct objects by itself. Since, for instance, it is impractical to make 100 objects to display 100 stars. So, instead, I decided to make a portrait of the solar system. I made a class where I could use to make any celestial object (planet, meteor, star, etc.). The class was quite simple so I added the random generators to give different y values for the planets; planets do not orbit at the same rate so it made sense. Every time the user runs the program, the location of the planets will change. After I was done with the class and the planets, I still needed the stars in the background, so I tried again with stars. However, this time I used two for loops, the Perlin noise function, and a random generator to make the stars spin around and I really liked how they turned out. But, they did not quite match the static planets so I thought I’d make the planets move. After doing so, the planets looked like they were vibrating. I was listening to a song at that time and they vibrated with the music as if they were dancing to it. So, I called it a day to the dancing planets portrait.
class celestial {
float y;
celestial(){
y = random(height/3, height/2);
}
//void color(){
// fill(r, g, b);
// }
//void size(){
// ellipse(xUnique, yUnique, radius, radius);
// }
void shape (float r, float g, float b, float radius, float x){
fill(r, g, b);
ellipse(x, y, radius, radius);
}
}
celestial sun;
celestial mercury;
celestial venus;
celestial earth;
celestial mars;
celestial jupiter;
celestial saturn;
celestial uranus;
celestial neptune;
int sunSize;
int xSun;
float xStar;
float yStar;
void setup() {
size (1000, 1000);
sun = new celestial();
mercury = new celestial();
venus = new celestial();
earth = new celestial();
mars = new celestial();
jupiter = new celestial();
saturn = new celestial();
uranus = new celestial();
neptune = new celestial();
sunSize = 600;
xSun = -40;
xStar = random(width);
yStar = random(height);
}
void draw(){
background(0, 17, 46);
// stars
stroke (245, 237, 24);
for (float i = noise(width); i < width; i = i+random(width/2)) {
for(float j = noise(height); j < height; j = j+random(height/2)){
line(i, j, i+2, j+2);
}
}
// plants
noStroke();
for (float i = noise(width); i < width/200; i = i+random(width/4)){
sun.shape(250, 232, 92, sunSize, xSun-70+i);
mercury.shape(224, 179, 72, sunSize/40, xSun+sunSize/2-50+i);
venus.shape(214, 130, 41, sunSize/35, xSun+sunSize/2+i);
earth.shape(58, 161, 199, sunSize/25, xSun+sunSize/2+90+i);
mars.shape(191, 76, 38, sunSize/30, xSun+sunSize/2+150+i);
jupiter.shape(145, 128, 71, sunSize/8, xSun+sunSize/2+250+i);
saturn.shape(191, 185, 117, sunSize/10, xSun+sunSize/2+350+i);
uranus.shape(22, 219, 216,sunSize/14, xSun+sunSize/2+475+i);
neptune.shape(28, 53, 138, sunSize/19, xSun+sunSize/2+550+i);
}
}
I used this picture for reference (idk why it’s so compressed here):
Here are the final results (the music is not from the program;-;):
