curveDownload
function setup() {
createCanvas(480, 480);
background(220);
text("p5.js vers 0.9.0 test.", 10, 15);
}
function drawAgnesiCurve() {
var x; //x position of the curve
var y; //y position of the curve
var a = mouseX; //honestly not sure what a does
stroke(max(mouseX, 255), max(mouseY, 255), 0);
strokeWeight(4);
beginShape();
for (var i = 0; i < 65; i++) {
var t = map(i, 0, 65, 0, TWO_PI);
x = (2*a)*sin(t);
y = a*(1-cos(2*t));
vertex(x, y);
}
endShape();
}
function draw() {
background(0, 0, min(mouseX, mouseY))
for (var nLine = 0; nLine < 48; nLine++) {
translate(width/2, 0);
drawAgnesiCurve();
translate(0, 10);
}
}