jknip-Project-04-string-art

sketch

/*Jessica Nip
Section A
jknip@andrew.cmu.edu
Project-04
*/

function setup() {
    createCanvas(400, 300);
}

function draw() {
    background(240);

    //set mouseX and mouseY as controles of color change
    var mouseR = mouseX;
    var mouseG = mouseY;
    var mouseB = 150;

    //set up for loop and increments
    for (var i = 0; i < 30; i+=1) {

    //set line characteristics
        stroke(mouseR-50, mouseG-50, mouseB); //define stroke RGB in relation to mouseR, mouseG, mouseB
        strokeWeight(1); //define weight to 1
        noFill(); //set fill to colorless

    //draw lines from left to right
        line(0 , i*10, mouseX+i*10, height);
        line(width/3+10*i, i*10, mouseX+i*10, height);
        line(width/3+4*i , height, width, height-(mouseX+15*i));
        line(width/2+10*i, 0, width, mouseX+i*10);
    }
}

I wanted to generate different curves from different sides of the canvas, and have colors randomize by a factor through the movement of the mouse. The result was an abstract line piece.

Leave a Reply