Project 4

String Art!

sketch
var numlines =18;
var dx = (240/2)/numlines;
var dy = (240/2)/numlines;

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

function draw() {
    strokeWeight(0.5);
    var x1 = 30;
    var y1 = 200;
    var x2 = 150;
    var y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    line(30,200,270,200);
    line(150,80,150,320);
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 += dx;
        y2 -= dy;
    }
    x1 = 270;
    y1 = 200;
    x2 = 150;
    y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 -= dx;
        y2 -= dy;
    }
    x1 = 30;
    y1 = 200;
    x2 = 150;
    y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 += dx;
        y2 += dy;
    }
    x1 = 270;
    y1 = 200;
    x2 = 150;
    y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 -= dx;
        y2 += dy;
    }
    translate(0,200)
    var x1 = 30;
    var y1 = 200;
    var x2 = 150;
    var y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    line(30,200,270,200);
    line(150,80,150,320);
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 += dx;
        y2 -= dy;
    }
    x1 = 270;
    y1 = 200;
    x2 = 150;
    y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 -= dx;
        y2 -= dy;
    }
    x1 = 30;
    y1 = 200;
    x2 = 150;
    y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 += dx;
        y2 += dy;
    }
    x1 = 270;
    y1 = 200;
    x2 = 150;
    y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 -= dx;
        y2 += dy;
    }
    translate(0,-400)
    var x1 = 30;
    var y1 = 200;
    var x2 = 150;
    var y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    line(30,200,270,200);
    line(150,80,150,320);
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 += dx;
        y2 -= dy;
    }
    x1 = 270;
    y1 = 200;
    x2 = 150;
    y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 -= dx;
        y2 -= dy;
    }
    x1 = 30;
    y1 = 200;
    x2 = 150;
    y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 += dx;
        y2 += dy;
    }
    x1 = 270;
    y1 = 200;
    x2 = 150;
    y2 = 200;
    var r = 255;
    var g = 192;
    var b = 203;
    for (var i = 0; i <= numlines; i += 1) {
        r -= i*3;
        g -= i*10;
        b -= i*6;
        stroke(r,g,b);
        line(x1,y1,x2,y2);
        x1 -= dx;
        y2 += dy;
    }
}

Leave a Reply