Assignment #2 – Earth is in danger

For this assignment I took inspiration from the 1966 Version of ProgrammInformation21 which is written in German and luckily I have been learning German for over 6 years now. The piece I was initially interested is this one:

Initially I created the circles and added a little bit of noise but it was too simplistic for my liking so I decided to make the circles come out from one of the edges of the canvas. After doing that I noticed that the circles kind of reminded me of a meteor so I started creating a concept of a meteor heading towards earth.  That lead to me “inventing” the piece code I am most proud of. It looks like this:

for (let i = 70; i < 3000; i += 30) {
    strokeWeight(5);
    let noiseFactor = 5;
    let posX = mouseX - i + random(-noiseFactor, noiseFactor);
    let posY = mouseY - i + random(-noiseFactor, noiseFactor);
    if (i == 70) {
      fill(92, 64, 51);
      circle(posX, posY, i);
    } else if (i > 70 && i < 150) {
      fill(255, 255, 0);
      circle(posX, posY, i);
    } else if (i > 150 && i < 450) {
      fill(255, 165, 0);
      circle(posX, posY, i);
    } else {
      fill(255, 0, 0);
      circle(posX, posY, i);
    }
  }

I wanted to add stars in the background that would be randomized and different every time someone runs the code and in order to make it static compared to the other elements of the canvas I needed to draw on a different buffer. It was also fun to add the element of surprise so now every time we click on the mouse button Earth changes into a random color. The final product looks like this:

I also added a little satelitte which rotates around Earth and adds another layer of animation.

Further improvements can be done and more interesting animations can be added. For the moment I already feel like I am overcrowding the screen with elements a little bit, so I decided not to add any more complexity.

Leave a Reply