Sammie Kim – Project 04 – String Art

sketch

//Sammie Kim
//sammiek@andrew.cmu.edu
//Section D
//Project 4

function setup() {
    createCanvas(400, 300);
    //Variables to modify the coordinates of line sets
    //pink lines set a
    aY1Gap = 50;
    aY2Gap = 0.9;
    //light blue lines set b
    bY2Gap = 0.5;
    //Purple lines set c
    cY1Gap = 300;
    cX2Gap = 100;
    cY2Gap = 0.8;
    //Green lines set d
    dY1Gap = 200;
    dY2Gap = 0.75;
}

function draw() {
    background("black");
    //for loop to create series of lines with increments of 10
    for (var i = 0; i < 400; i += 10) {
        //Red line sets a
        stroke(255, 112, 112);
        line(i, mouseY / 2 - aY1Gap, width, i * aY2Gap);
        //light blue lines sets b
        stroke(181,255,221);
        line(i, mouseY, 0, i * bY2Gap);
        //Purple lines sets c
        stroke(122, 114, 240);
        line(i, -mouseY + cY1Gap, width / 3 + cX2Gap, i * cY2Gap);
        //Green lines set d
        stroke(28, 151, 45);
        line(i, -mouseY + dY1Gap, width, i * dY2Gap);
    }
  }

This project was challenging as I had to visualize the lines coordinates to create the curves. Sketching the picture first really helped me, since I got to picture the starting and ending points. By utilizing the “for function” to repeatedly create the line sets, I realized once more how much more convenient it is rather than writing a ton of line codes. 

Leave a Reply