sketch
//Evette LaComb
//section D
//deliverable 7 project
var Cardioid= 0; // Astroid Inovulte oarametric
var nPoints = 100; // points manipulted on the shape
function setup() {
frameRate(5);
createCanvas(400, 400);
background(220);
}
function draw() {
background("lightBLue")
// if mouse is above or below the monster backgrounf red:
if (dist(width/2, mouseY, width/2, height/2) > 100) {
background("red");
}
//Draw the astroid monster
fill("white");
draw_cardioid(width/2, 150);
}
function draw_cardioid(x, y) {
// transformations for esthetics
push();
translate(x, y);
rotate(radians(90));
// set variables
var x;
var y;
//set esthetics
stroke("red");
fill("blue");
//draw monster occording to the cardioid equations
beginShape();
for (var i = 0; i < nPoints; i++) {
var manipulate = mouseX/20;
var t = map(i, 0, nPoints, 0, TWO_PI);
var a = mouseX/8 +50;
var p = random(mouseY/350, .5);
var q = random(mouseY/350, .5);
x = a *(1+ cos(t)) *(cos(t) * 1.5 * p);
y = a *(1+ cos(t)) *(sin(t)* 1.5 *q);
vertex(x, y);
}
endShape(CLOSE);
pop();
}