Project 4: String Art

sketch

/*Emma Shi
Section B
eyshi@andrew.cmu.edu
Project 4 String Art
*/

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

function draw() {
    background("navy");

        var a = 0;
        var b = 640;
        var c = 480;
        var r = atan2(mouseY-height/2, mouseX-width/2);

   for (var i = a; i < 640; i += 10) { //starts at 0, adds 10 to i until 640

        noFill();
        stroke("yellow");
        strokeWeight(1.5);

     translate(width/2, height/2);
        push();
        rotate(r);
        ellipse(a, a, 10, 10);
        pop();
        angleMode(RADIANS);
        rotate(r);//rotates lines around the center ellipse when mouse is moved

        line(a, a, width-c, b); //second line from the bottom left
        line(a, a, b, i); //line closest to the bottom right
        line(a, a, -30, i+300); //line closest to the bottom left
        line(a, a, i+600, b); //second line from the bottom right
    }
}

For this week’s project, my original idea was to make a string art “circle” where lines from all corners of the canvas would come together to outline an empty ellipse, similar to an eye of a hurricane. However, after playing around with it, I ended up making lines that spun around a center ellipse. When the user moves the mouse up or down, the lines rotate quickly and form an outline of another ellipse, which changes in diameter as the mouse moves along the canvas.

Leave a Reply