sketch
//hollyl
//composition with curves
//section D
var nPoints = 150;
function setup(){
createCanvas(480, 480);
}
function drawCartiod(){
var x;
var y;
var a = 15;
var b = a/2;
var h = constrain(mouseY/50, 0, b);
var ph = mouseX/50;
fill(200, 255, 200);
beginShape();
for(var i=0; i<nPoints; i++){
var t=map(i, 0, nPoints, 0, TWO_PI);
x = (a+b)*cos(t) * (h-cos(ph+t*(a+b)/b));
y = (a+b)*sin(t) * (h-cos(ph+t*(a+b)/b));
vertex(x, y);
}
endShape(CLOSE);
}
function draw(){
background(255);
push();
translate(width/2, height/2);
drawCartiod();
pop();
}
I really enjoyed the examples for this project, as they were very soothing to play with, so I decided to create a form that I enjoyed the most. I played around with epicycliod forms in desmos until I landed on one that I enjoyed that coded it.