//Yinjie Tian
//Section B
//yinjiet@andrew.cmu.edu
//Assignment-07-A
function setup() {
createCanvas(480, 480);
frameRate(10);
}
function draw() {
background(0);
noFill();
stroke(255, random(150,255), 255)
var nPoints = 20;
var radius = width / 2 - mouseX;
var radius2 = width / 2 - mouseX * random(0.4, 0.9)
var radius3 = width / 2 - mouseX * random(0.4, 0.9)
var radius4 = width / 2 - mouseX * random(0.4, 0.9)
var radius5 = width / 2 - mouseX * random(0.4, 0.9)
var radius6 = width / 2 - mouseX * random(0.4, 0.9)
// draw the circle as a wiggly circle
push();
translate(width / 2, height / 2);
beginShape();
for (var a = 0; a < nPoints; a++) { //circle 1
var theta = map(a, 0, nPoints, 0, TWO_PI);
var px = radius * cos(theta);
var py = radius * sin(theta);
vertex(px + random(-5, 5), py + random(-5, 5));
}
noFill();
stroke(random(150,255), 255, 255)
for (var b = 0; b < nPoints; b++) { //circle 2
var theta = map(b, 0, nPoints, 0, TWO_PI);
var px = radius2 * cos(theta);
var py = radius2 * sin(theta);
vertex(px + random(-5, 5), py + random(-5, 5));
}
noFill();
stroke(random(150,255), random(150,255), random(150,255))
for (var c = 0; c < nPoints; c++) { //circle 3
var theta = map(c, 0, nPoints, 0, TWO_PI);
var px = radius3 * cos(theta);
var py = radius3 * sin(theta);
vertex(px + random(-5, 5), py + random(-5, 5));
}
for (var d = 0; d < nPoints; d++) { //circle 4
var theta = map(d, 0, nPoints, 0, TWO_PI);
var px = radius4 * cos(theta);
var py = radius4 * sin(theta);
vertex(px + random(-5, 5), py + random(-5, 5));
}
noFill();
stroke(random(150,255), 255, 255)
for (var e = 0; e < nPoints; e++) { //circle 5
var theta = map(e, 0, nPoints, 0, TWO_PI);
var px = radius5 * cos(theta);
var py = radius5 * sin(theta);
vertex(px + random(-5, 5), py + random(-5, 5));
}
noFill();
stroke(random(150,255), random(150,255), random(150,255))
for (var f = 0; f < nPoints; f++) { //circle 6
var theta = map(f, 0, nPoints, 0, TWO_PI);
var px = radius6 * cos(theta);
var py = radius6 * sin(theta);
vertex(px + random(-5, 5), py + random(-5, 5));
}
endShape(CLOSE);
pop();
}
For this project, I first choose the ellipse as the base geometry. Then I use vertex to make each of the ellipse to wiggle. The radius for the ellipse are selected randomly based on the mouseX position. Colors for the curves are also selected randomly.