Project 7, odh

odhP7

//Owen D Haft
//Section D
//odh@andrew.cmu.edu
//Project 7

var nPoints = 100;

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

function draw() {
    background(255);
    push();
        translate(0, mouseY); //Changes the height based on MouseY
        fill(111, 111, 222);
        drawCurve(); //Draws the curve
    pop();
}
    
function drawCurve() {

    beginShape();
    for (var i = 0; i < nPoints; i++) {
        var t = map(i, 0, nPoints, 0, TWO_PI); //maps the points of the equations
        strokeWeight(1);

        //The equations that generate the curve
        x = (mouseX/19)*((sin^3)*(t)); //Curve changes with mouseX
        y = 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t);
        
        vertex(x, y);
    }
    endShape(CLOSE);    
}

I attempted to use a Heart Curve in this project, but I came across an issue with using Sin^3. Therefore, I just went with the result I got leading to my current project. I chose to have the curve stretch with the mouseX and change heights with mouseY.

Leave a Reply