Project 04: String Art

hcsaDownload
//Hayoon Choi
//hayoonc
//Section C

var numLines = 50; 

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

function draw() {
    background(0);
    var x1 = 200;
    var x2 = 400;
    var y1 = 0;
    var y2 = 400;
    var sf = constrain(mouseY, 150, 255); //line color change
    stroke(sf); 
    strokeWeight(0.75); 
    for (var i = 0; i <= numLines; i++){
	    strokeWeight(0.75); 
        line(i, i, i * 8, 170); //top left section
        line(mouseX, i * 6, i, i); //moving left section
    }
    for (var i = 0; i <= numLines; i++){
	    strokeWeight(0.75); 
        line(400 - i, i, 400 - i * 8, 170); //top right section
        line(mouseX, i * 6, 400 - i, i); //moving right section
    } 
    for (var y1 = 0; y1 <= 400; y1 += 5) {
    	line(x1, y1 , x2, y2); //right section 
    	x2 += 35;
    }
    x2 = 0;
    y2 = 400;
    for (var y1 = 0; y1 <= 400; y1 += 5) {
        line(x1, y1 , x2, y2); //left section 
    	x2 -= 35;
    }
    stroke(244, 106, 78);
    fill(100, 23, 94, 50);
    push();
    translate(mouseX, 160);
    //rotating orange lines
    for (var j = 0; j < 60; j++){
        push();
        strokeWeight(1);
        rotate(radians(6 * j));
        line(0, 0, 0, 1000); //orange lines
        pop();
    }
    pop();
    
}

Leave a Reply