Project 5

sketch
//Keng Pu (Paul) Li
//section A 
//9/27/22
var numLines = 50;
var dx3;
var dy3;
var dx4;
var dy4;

function setup() {
    createCanvas(500,500);
   
}

function draw() {
    var backG = random(100,200);
    background(250,0,20,random(50,backG));
    for(var w = 0; w<7; w++){
        for(var i = 0; i<18; i++){
            push();
            scale(0.15);
            translate(390+w*525,-350+i*510);
            stringArt();
            pop();
        }

         for(var i = 0; i<18; i++){
            push();
            scale(0.15);
            translate(290+w*525,350+i*510);
            stringArtFlipped();
            pop();
        }
    }
    noLoop();
}

function stringArt(){
//string art like the ones from week 4 but tranformed
//most left
    dx3 = 5;
    dy3 = 1;
    dx4 = 5;
    dy4 = 5;

//most left 
    x3 = 0;
    y3 = width/2+100;
    x4 = width/2;
    y4 = width/2+100;
    for(var i = 0; i<40; i++){
        strokeWeight(4);
        stroke(255,90,180);
        line(x3,y3,x4,y4);
        x3 += dx3;
        y3 += dy3;
        x4 -= dx4;
        y4 += dy4;
    }
    push();
    translate(0,200);
     for(var i = 0; i<40; i++){
        strokeWeight(2);
        stroke(25,255,100);
        line(x3,y3,x4/4,y4/5);
        x3 -= dx3;
        y3 += dy3;
        x4 -= dx4;
        y4 += dy4;
    }
    pop();
}


function stringArtFlipped(){
//string art like the ones from week 4 but tranformed
//most left
    dx3 = 5;
    dy3 = 1;
    dx4 = 5;
    dy4 = 5;

//most left 
    x3 = 0;
    y3 = width/2+100;
    x4 = width/2;
    y4 = width/2+100;
    push();
    rotate(radians(180));
    for(var i = 0; i<40; i++){
        strokeWeight(2);
        stroke(0,90,180);
        line(x3,y3,x4,y4);
        x3 += dx3;
        y3 += dy3;
        x4 -= dx4;
        y4 += dy4;
    }
    push();
    translate(0,200);
     for(var i = 0; i<40; i++){
        strokeWeight(1);
        stroke(255,20,10);
        line(x3,y3,x4/4,y4/5);
        x3 -= dx3;
        y3 += dy3;
        x4 -= dx4;
        y4 += dy4;
    }
    pop();
    pop();
}

Leave a Reply