The most difficult part of this project is to find out how which curve formula to use for my design. I played around with different colors and shape overlapping and I like the flower shape it makes.
sketch
//Jenny Wang
//sectionB
//jiayiw3@andrew.cmu.edu
//project - 07 - curves
var nPoints = 150;
function setup() {
createCanvas(480, 480);
background(29,7,79);//dark purple
frameRate(10);
}
function draw() {
push();
//make the center of canvas the origin
translate(width/2,height/2);
//draw loop for the curves 1 & 2
background(29,7,79);//dark purple
curve1();
curve2();
curve3();
pop();
}
function curve1(){
//Epicycloid Involute
//https://mathworld.wolfram.com/EpicycloidInvolute.html
//set varibale
var x;
var y;
var a = mouseX/8
var b = mouseY/8
beginShape();
noFill();
stroke(247,246,208);//light yellow
for(var i=0; i<nPoints; i++){
var t = map(i,0,nPoints,0,TWO_PI);
x = (a+b)*cos(t)-b*cos(((a+b)/b)*t);
y = (a+b)*sin(t)-b*sin(((a+b)/b)*t);
vertex(x,y);
endShape(CLOSE);
}
}
function curve2(){
//Epicycloid Involute
//https://mathworld.wolfram.com/EpicycloidInvolute.html
//set variable
var x;
var y;
var a = mouseX/5
var b = mouseY/5
beginShape();
noFill();
stroke("white");//white
for(var i=0; i<nPoints; i++){
var t = map(i,0,nPoints,0,PI+QUARTER_PI);
x = (a+b)*cos(t)-b*cos(((a+b)/b)*t);
y = (a+b)*sin(t)-b*sin(((a+b)/b)*t);
vertex(x,y);
endShape(CLOSE);
}
}
function curve3(){
//Epicycloid Involute
//https://mathworld.wolfram.com/EpicycloidInvolute.html
//set variable
var x;
var y;
var a = mouseX/3
var b = mouseY/3
beginShape();
noFill();
stroke("pink");//pink
for(var i=0; i<nPoints; i++){
var t = map(i,0,nPoints,0,PI);
x = (a+b)*cos(t)-b*cos(((a+b)/b)*t);
y = (a+b)*sin(t)-b*sin(((a+b)/b)*t);
vertex(x,y);
endShape(CLOSE);
}
}