Project4: String Art

string art
function setup() {
    createCanvas(300, 400);
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);
    rectMode(CENTER)
}
function draw() {
    background(40,30,60);
    stroke(150, 160, 255);
    for (var x = 0; x <= 50; x += 1) {
        line(300, 50, 300/50 * x - 3, 0); //right upwards lines
    }
    for (var x = 20; x <= 80; x += 1) {
        line(300, 50, 300/40 * x, 400); //right downwards lines
    }
    for (var x = 0; x <= 30; x += 1) {
        line(0, 350, 300/60 * x, 0); //left upwards lines
    }
    for (var x = 0; x <= 30; x += 1) {
        line(0, 350, 300/30 * x, 400); //left downwards lines
    }

//spiraling lines (very short)
    var angle = 70
    var angle2 = 50
    var x = 30
    var y = 50
    translate(150,200) //origin = center
    push();
    for (y = 50; y <= 300; y += .7){
        rotate (radians(angle));
        stroke (180, 168, 218);
        line (30, y, x+2, y);
    }
    pop();
//spiraling lines (short)
    push();
    for (x = 30; x <= 400; x += .8){
        rotate (radians(angle2));
        stroke (190, 210, 240);
        line (x-25, x-40, x-40, 0.8*40);
    }
    pop();
//black hole in the middle
    push();
    stroke(30,10,70)
    strokeWeight(3)
    fill(0)
    circle(0,0,30) 
    pop();
}
    

I drew star trails with a black hole in the middle.

Leave a Reply