# hdw – Project 7 – Curves

``````//Helen Wu
//Section A
//hdw@andrew.cmu.edu
//Project 7

function setup() {
createCanvas(480,480);
background(255, 71, 123)
}

function draw() {
push();

//this is to call the centers of which the sextic functions will be called from
translate(width/2, height/2);
beginShape();
for(var i = 0; i < 25; i++){
//25 sets the direction of which the curves draw
var t = map(i,0,100,0,360);
//t = angle
var a = map(mouseY, 0, 480, -5, 5);
//a = control the curvature of the loops
var x = 4*a*(Math.pow(cos((1/3)*t),3))*cos(t);
var y = 4*a*(Math.pow(cos((1/3)*t),3))*sin(t);
//centerX and centerY = center of smaller curves
var centerX = 10*x
var centerY = 10*y
}
endShape(CLOSE);
pop();

//drawing below sextics on points along above sextic
cayleysSextic(centerX, centerY);
}

function cayleysSextic(centerX,centerY) {
push();
//placement of sextics along center
translate(width/2+centerX,height/2+centerY);
beginShape();
for(var i = 0; i < 50; i++){
//t = angle
var t = map(i,0,100,0,360);
//a = control the curvature of the loops
var a = map(mouseX, 0, 400, -10,10);
var x = 4*a*(Math.pow(cos((1/3)*t),3))*cos(t);
var y = 4*a*(Math.pow(cos((1/3)*t),3))*sin(t);
//center of smaller loop's smaller curves
noStroke()
fill(255,255,255,30);
ellipse(x*3,y*3,1,1);
//drawing ellipses along the curve
}
endShape(CLOSE);
pop();
}
``````

This project was based on Cayley’s Sextic, which coincidentally looks like a butt. 👀👀

I mapped Cayley’s Sextic along another Cayley’s Sextic, just to see how it would look. I kind of like how cute the final product turned out to be. The centers of one are along the next, both mapped to the mouse position on the canvas.