Project 4: String Art

sketch

//Elise Chapman
//ejchapma
//Section D

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

var dx1;
var dy1;
var dx2;
var dy2;

function draw() {
    background(30,50,49); //periwinkle
    var dist=100; //distance from center of spiral
    var angle=5;
    var y=100;
    var x=100;
    push();
    //intricate purple
    translate(width/2+25,height/2+25); //sets center of spiral
    for(y=100; y<=200; y+=0.5) {
        strokeWeight(2);
        stroke(153,141,160); //purple
        rotate(radians(angle*10));
        line(mouseX/15,mouseY/15,mouseX+dist,y);
        dist-=0.5;
    }
    //star
    for (y=10;y<=300;y+=5) {
        strokeWeight(5);
        stroke(196,231,212); //grey
        rotate(radians(-angle+180)); //creates the spiral
        line(x+dist, y+dist, min(mouseX/2,300), min(mouseY/2,50));
        dist-=1;
    }
    //straight line spread
    pop();
    var numLines=20;
    dx1=0/numLines;
    dy1=mouseY/numLines;
    dx2=mouseX/numLines;
    dy2=0/numLines;
    var x1=0;
    var y1=100;
    var x2=500;
    var y2=250;
    for (var i=0; i<=numLines; i+=1) {
        stroke(300);
        strokeWeight(3);
        line(x1,y1,x2,y2);
        x1+=dx1;
        y1+=dy1;
        x2+=dy2;
        y2+=dy2;
    }
}

I wasn’t too sure about my string art going into programming. I didn’t really have a clear vision and in the end I kept playing around with the code until I reached a point I like. In the future, I think I’m going to try to redo this code on my own – I think it would be an engaging entrance piece for my website.

Leave a Reply