Project 04 – String Art

sketch
var dx1;
var dy1;
var dx2;
var dy2;
var numLines = 50;

function setup() {
    createCanvas(400, 300);
    background(200);
    line(0, 0, 0, 300);
    line(300, 300, 350, 100);
    dx1 = (0-0)/numLines;
    dy1 = (300-0)/numLines;
    dx2 = (550-100)/numLines;
    dy2 = (1)/numLines;
}

function draw() {
	background(0)
    var x1 = 40;
    var y1 = 0;
    var x2 = 0;
    var y2 = 300;
    var x4 = 0;
    var y4 = 400
    for (var i = 0; i <= numLines; i += 1) {
        stroke(0,0,255);
        line(mouseX/1.7, 0, 400, y1); //blue curves
        stroke(255,0,0)
        line(mouseX-30,y1,x2,y2); //red curves
        stroke(0,255,0)
        line(mouseX/1.2,y1,y4,y2) //green curves
        x1 +=dx1
        y1 += dy1;
        x2 += dx2;
        y2 += dy2;
    } 
}

Leave a Reply