Austin Treu – Project 04 – String Art

atreu – project04

//Austin Treu
//atreu
//Project 04
//Section C

var x1, y1, x2, y2;

function setup() {
    createCanvas(400, 300);
    background(0);

    //for loop to generate points and draw lines
    for(var i = 0; i < 100; i++){
        //new points
        x1 = lerp(width,0, i/100);
        y1 = lerp(0,height, i/100);
        x2 = lerp(0,width, i/50);
        y2 = lerp(height,0, i/50);
        //draw red lines
        stroke(255, 0, 50);
        line(x1, height/i, 0, y1);
        line(width-x1, height/i, width,y1);

        //generate points
        x1 = lerp(width/2,0, i/100);
        y1 = lerp(height/2,0, i/100);
        x2 = lerp(width/2,0, i/50);
        y2 = lerp(height,0, i/50);
        //draw blue lines
        stroke(50, 0, 255);
        line(x1, y1, x2, y2);
        line(x2, y1, x1, y2);
        line(width-x1, y1, width-x2, y2);
        line(width-x2, y1, width-x1, y2)

        //generate new points
        x1 = lerp(width/i,width, i/100);
        y1 = lerp(height/i,height, i/100);
        x2 = lerp(0,width, i/75);
        y2 = lerp(0,height, i/75);
        //draw yellow lines
        stroke(175, 150, 0);
        line(x2, y2, x1, height);
        line(width-x2, y2, width-x1, height);

        //new points
        x1 = lerp(0,width/2, i/100);
        y1 = lerp(0,height/2, i/100);
        x2 = lerp(0,width-width/7.5, i/200);
        y2 = lerp(0,height/2, i/200);
        //draw green lines
        stroke(0, 255, 150);
        line(x2, y2, x1, y1);
        line(width-x2, y2, width-x1, y1);
    }
}

Learning how to properly utilize lerp() was an interesting process to experiment with, as it offered a huge variety of different options once I understood. I spent the time I worked on this completely focused on making it symmetrical, which changed my focus throughout the project.

Leave a Reply