dnam-project-07

sketch

/*
Doo Won Nam
Section B
dnam@andrew.cmu.edu
Project - 07
*/

function setup() {
createCanvas(400, 400);
ellipseMode(CENTER); //set center of ellipse to middle
stroke(255); //white lines
}

function draw() {
background(0); //black background, put it in draw so it resets while moving
var angle = 0; //set angle for ellipse and movement distance
var angle2 = 360 / mouseX; //set mouse interaction
for (var i = 0; i < 11 ;i ++) { //start loop, limit to 10 ellipses
angle = frameCount;
d = sin(radians(angle)) * 100;
var x = 200 + d * cos(radians(angle2*i + 200)); //set x to move/same x for both
var y = 200 + d * sin(radians(angle2*i + 10)); //set y to move/same y for both
  noFill(); //transparent ellipses
	ellipse(x, y, 100, 100); //small circle
	ellipse(x, y, 200, 200); //big circle
	}
}

While I had a hard time with the project due to my lack of knowledge in how cos and sin works due to not having taken math classes for a prolonged time, I used cos and sin to make the ellipses move in a cradle like fashion. The mouse interaction blooms the circles that are combined together. The location of the mouse alters the location and spread of the ellipses. This effect also alludes a display similar to those of springs.

Leave a Reply