Project-07-Curves

sketch
//Ian Lippincott
//ilippinc
//Section D


//orange
//fill(240, 147, 109);
//blue
//fill(49, 57, 75);
//cream
//fill(255, 255, 226


var nPoints = 500;
var angle = 30;

function setup() {
    createCanvas(480, 480);
}

function draw() {
    background(49, 57, 100);
    //draw 2 sets of 36 hypotrochoids 
    for (var x = 80; x <= 400; x += 64) {
        for (var y = 80; y <= 400; y += 64) {
            push();
            translate(x, y);
            rotate(mouseX/20);
            drawEpitrochoid();
            pop();
        }
    }
}

function drawEpitrochoid() {
    var a = map(mouseX, 0, 480, 0, 120); 
    var b = map(mouseX, 0, 480, 0, 40); 
    var h = map(mouseY, 0, 480, 0, 40); 
    strokeWeight(4);
    //Cream Stroke
    stroke(255, 255, 226);
    //Orange Fill
    fill(240, 147, 109); 
    //Draw Epitrochoid
    beginShape(); 
    for (var i=0; i<nPoints; i++) {
        var angle = map(i, 0, 80, 0, TWO_PI);
        x = (a+b) * cos(angle) - h * cos(((a+b)/b) * angle);
        y = (a+b) * sin(angle) - h * sin(((a+b)/b) * angle);
        vertex(x, y);
    }
    endShape();
}

Leave a Reply