sketch
/* Austin Garcia
Section C
aegarcia@andrew.cmu.edu
Project 07
*/
var pointsN = 100;
function setup() {
createCanvas(480, 480);
}
function draw() {
background(0);
stroke(mouseX / 2, mouseY / 2, 0);
noFill();
//map to mouse
strokeWeight(.5);
push();
var xMouse = mouseX;
var yMouse = mouseY;
translate(xMouse, yMouse);
drawHypocycloid();
pop();
}
function drawHypocycloid() {
//set variables
var x;
var y;
var mX = map(mouseX, 0, width, 0, width / 2);
var mY = map(mouseY, 0, height, 0, height / 2);
//draw lines
beginShape();
for (var i = 0; i < pointsN; i++) {
var m = map(i, 0, pointsN, 0 ,PI / 2);
vx = (mX - mY) * cos(m) - mX * cos((mX - mY) * m);
vy = (mX - mY) * sin(m) - mX * sin((mX - mY) * m);
vertex(vx, vy);
}
endShape();
}