Project 07: Composition with Curves

sketch
//Julianna Bolivar
//jbolivar@andrew.cmu.edu
//Section D
//Project 07: Composition with Curves

var x;
var y;

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

function draw() {
    background(0);
    for (var curveLines = 1; curveLines < 10; curveLines++){ //draw slinky
        for (var amtLines = 1; amtLines < 5; amtLines++){
            push();
            translate(curveLines * 10, amtLines * 10);
            drawEpiTri(); 
        }
    }
}

function drawEpiTri() {
    var a = map(mouseX, 0, width, 15, 100); 
    var b = map(mouseY, 0, height, 15, 50);
    noFill();
    stroke(mouseX, mouseY, 0); //color changes with mouse
    push();

    var a = map(mouseY, 0, width, 10, 50); 
    var b = map(mouseX, 0, height, 10, 50);
    var h = constrain(mouseY, 0, b);
    var ph = mouseY/50;

    beginShape(); 
    for (var i = 0; i <= 500; i ++) { //shape equation
        var theta = map(i, 0, 50, 0, TWO_PI);
        x = (a+b)*cos(theta)-h*cos(ph+theta*(a+b)/b);
        y = (a+b)*sin(theta)-h*sin(ph+theta*(a+b)/b);
        vertex(x, y);
    }
    endShape();
    pop();
}

Red circles.

Yellow spirals.

Green spirals.

Yellow Spaghetti.

Leave a Reply