Joseph Zhang – Project 04 – E

sketch

// Joseph Zhang
// Section E
// haozhez@andrew.cmue.edu
// Project-04: String Art

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

function draw(){

    // formation 1 (center)
    push();
    translate(50,0);
    lineArt();
    pop();

    // formation 2 (right)
    push();
    translate(350,0);
    lineArt();
    pop();

    // formation 3 (left)
    push();
    translate(-250,0);
    lineArt();
    pop();
}

//creates one 300x300 square formation
function lineArt(){
    blue = 0;
    green = 20;
    red = 170;
    strokeWeight(.3);

    // create top right and bottom left lines
    for(i = 0; i < 300; i = i + 10){
        stroke(red, green, blue);
        line( 0, i, i, 300);
        line( 300, i, i, 0);

            // randomize colors
        red = random(0,100);
        green = random(0,255);
    }
    
    // create top left and bottom right lines
    oppCount = 0;
    for(i = 300; i > 0; i = i - 10){
        stroke(red, green, blue);   
        line( i, 0, 0, oppCount);
        line( 300, i, oppCount, 300);
        oppCount += 10;
        blue +=10;
    }
}

In this project, I wanted to experiment with how form, color and temporal speed can interact with each other to create something that feels electric. The algorithm was pretty simple; depending on the position, I increased/decreased the x and y positions at the same speed to create a consistent web effect. More detail can be seen in the file comments.

Leave a Reply