###### Featured Posts

**Assignment for Week 2**

Â

Â

I call this Apple-Watch Doomsday Counter.

Â

Â

**How I Made It**

Â

Quick recap:Â

The original sketch wasÂ based on this icon created by a couple illustrators based in Ukraine.

Â

Very cute, but was quite challenging because of I had to be very exact with the organic lines.

Â

What I did in week 1:Â

Previous post on how I did it.

Â

Initially, I made this for the assignment.

Â

In summary, I broke the animation into 3 parts:

Â

1) Rotating planet & orbit

The planet surface rotates using translate() & rotate() function, while its outline and orbit are "animated" via increasing the angle of the arc() over time. The speed and direction of the rotation could be changed using mouseX value.

Â

rotSpeed=map(mouseX, 0, width, -20, 20);

rotAngle+=rotSpeed;

Â

var planetSize=200;

noFill();

arc(width/2, height/2, planetSize, planetSize, radians(rotAngle),radians(rotAngle+350));

//planet outline rotates clockwise

push();

stroke(180);

arc(width/2, height/2, planetSize+70, planetSize+70, radians(-rotAngle),radians(-rotAngle+300));

pop();Â

//planet orbit rotates counter-clockwise

Â

Â

This portion of code is the translation & rotating function for the planet's surface. The rotation is not controlled by mouse and will move regardless.

Â

translate(width/2,height/2);

rotate(radians(rotAngle2));

rotAngle2+=5; //!!surface rotates regardless mouse's position

Â

Â

2) Sine wave

I randomly changed the curvature of the line using a randomly generated value added to the bezier() control points.

Â

bezX=random(-5,5);Â //!!smoothen or roughen curve with random values

bezier(100, 270, 108, 270, 112+bezX, 280, 120+bezX, 280);Â

Â

3) Random shapes controlled by mouseY

mouseY coordinate is mapped into a line that generates 0 or 1, and the digits determine the shape type (rectangle or circle).

Â

I was not very satisfied, so I decided to add on to the assignment.

Â

I started with changing the background() function to have an alpha value, so that the shapes will leave a "trail" as they move.

Â

background(0, 80);

Â

Â

I took out some bezier lines to make the sketch cleaner, and added more orbit lines in various length and rotation speed.

Â

stroke(255,255,0);

arc(width/2, height/2, planetSize+70, planetSize+70, radians(-rotAngle), radians(-rotAngle+300));

stroke(255);

arc(width/2, height/2, planetSize+100, planetSize+100, radians(rotAngle), radians(rotAngle+270));

stroke(255,30,115);

arc(width/2, height/2, planetSize+130, planetSize+130, radians(-rotAngle), radians(-rotAngle+180));

stroke(100);

arc(width/2, height/2, planetSize+160, planetSize+160, radians(rotAngle+30), radians(rotAngle+100));

arc(width/2, height/2, planetSize+250, planetSize+250, radians(-rotAngle+30), radians(-rotAngle+100));

Â

Â

At this point, I realised that the animation was kind of poetic. The white circle lookedÂ like the sun and the sine wave, the sea. With the lines rotating around the planet, it kinda lookedÂ like the canvas wasÂ a time lapse of starry sky.

Â

And also, it looked a lotÂ like Apple Watch.

Â

Â

For the last part, which was to create something that changes every time the program runs, I took inspiration from the watch: numerical counter.

Â

/***RANDOM NUMBER***/

push();

Â Â Â Â fill(80);

Â Â Â Â noStroke();

Â Â Â Â textSize(200);

Â Â Â Â textStyle(BOLD);

Â Â Â Â text(int(num), width/2, 270);

pop();

Â Â

/////////////////////

Â Â

rotSpeed=map(mouseX,0,width,-20,20); //!!rotation speed depends on mouseX

num=num+rotSpeed; //!!make the number increase / decrease according to Â mouseXÂ

â€‹

Note here that mouse X affects both rotation speed of the planet, orbit and the counter. I like how it seemed like moving the mouse affected the "speed" or star revolution and the counter (hence "Doomsday Counter").

Â

Â

Once again, the final sketch.

Â

Source code can be found here!