Shannon Case Project 07 – Curves

sketch

//Shannon Case
//Section D
//scase@andrew.cmu.edu
//assignment 07-A

var nPoints = 100;
//var valE = 2.718; // This is the value of # 'e'

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


function draw() {
   
    
    // draw the frame
    fill((mouseY/height)*100,(mouseY/height)*200,(mouseY/height)*255);
    rect(0, 0, width-1, height-1); 
    
    // draw the curve
    push();
    translate(width / 2, height / 2);
        drawEllipseEvoluteCurve();

    pop();

}

function drawEllipseEvoluteCurve() {
    // Ellipse Evolute
    // http://mathworld.wolfram.com/EllipseEvolute.html
    
    var x;
    var y;

    var a = constrain((mouseX / width), 0.1, 0.5);
    var b = constrain((mouseY / height), 0.1, 0.5);
    
    fill((mouseX/width)*255,(mouseX/width)*100,(mouseX/width)*255);
    strokeWeight(5);
    stroke((mouseX/width)*200,(mouseX/width)*55,(mouseX/width)*255);
    beginShape();
    for(var i = 0; i < nPoints; i++) {
        var t = map(i, 0, nPoints, 0, TWO_PI);

        x = ((Math.pow(a+(mouseX/45), 2) - Math.pow(b, 2)) / a * (Math.pow(cos(t), 3)));
        y = ((Math.pow(b+(mouseY/48), 2) - Math.pow(a, 2)) / b * (Math.pow(sin(t), 3)));
        vertex(x, y);

    }
            endShape(CLOSE);

}


    

For this project I really struggled with choosing a curve that worked. I chose a bunch that weren’t really able to move well with both the x and y values, but eventually decided on the Ellipse Evolute because it was more easily able to stretch and shrink with my mouseX and mouseY. I chose to have the background color evolve with the mouseY values and the color of the shape change with the mouseX values.

Leave a Reply