sketch
//TERESA LOURIE
//SECTION D
//PROJECT: INTERACTIVE CURVES
var x = 2;
var y = 2;
function setup() {
createCanvas(480, 480);
background(255);
}
function draw() {
background(255);
//figureeight();
push();
//for (i=0; i<500; i++){
devilscurve();
//}
devilscurve2(); //draw both curves at once on white background
}
function figureeight(){
push();
translate(width/2, height/2);
background(255);
beginShape();
stroke(0);
strokeWeight(1);
noFill();
//loop for curves
for(var i =0; i < 750; i++){
stroke(map(mouseY, 0, 480, 0, 255), 0 ,0);
var t = map(i, 0, 750, 0, 2*PI);
var a = mouseX;
var b = 1;
x = a*sin(t);
y = a*sin(t)*cos(t);
vertex(x, y);
}
endShape();
pop();
}
function devilscurve () { //devils curve function
push();
translate(width/2, height/2); //put it in the center
beginShape(); //beginshape, using vertices along the equation
strokeWeight(3);
noFill();
//loop for curves
for(var i =0; i < 3000; i++){
stroke(0, 255, map(mouseY, 0, 480, 0, 255));
var t = map(i, 0, width, -50, 100);
var a = map(mouseX, 0, width, -50, 10);
var b = map(mouseY, 0, height, -50, 50);
x = cos(t)*sqrt((pow(a, 2)*(t)-pow(b, 2)*pow(cos(t),2)/(pow(sin(t),2)-pow(cos(t),2))));
y = sin(t)*sqrt((pow(a, 2)*(t)-pow(b, 2)*pow(cos(t),2)/(pow(sin(t),2)-pow(cos(t),2))));
vertex(x, y);
}
endShape();
pop();
}
function devilscurve2 () { //devils curve function
push();
translate(width/2, height/2); //put it in the center
beginShape(); //beginshape, using vertices along the equation
strokeWeight(3);
noFill();
//loop for curves
for(var i =0; i < 3000; i++){
stroke(255, map(mouseY, 0, 480, 0, 255), 0);
var t = i
var a = map(mouseX, 0, width, -50, 100);
var b = map(mouseY, 0, height, -50, 50);
x = cos(t)*sqrt((pow(a, 2)*(t)-pow(b, 2)*pow(cos(t),2)/(pow(sin(t),2)-pow(cos(t),2))));
y = sin(t)*sqrt((pow(a, 2)*(t)-pow(b, 2)*pow(cos(t),2)/(pow(sin(t),2)-pow(cos(t),2))));
vertex(x, y);
}
endShape();
pop();
}