Ammar Hassonjee – Project 04 – String Art

Project 04 – String Art

/* Ammar Hassonjee
   Section C
   ahassonj@andrew.cmu.edu
   Project 04 - String Art
   */

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

function draw() {
    // For loop that allows for reiterations of the line
    // Loop runs 90 times to generate specific shapes
    for (i = 0; i < 90; i++) {
        // Multiple variables declared that are used in line function
        x1 = i * 10;
        y1 = -x1;
        x2 = width / 2 - x1;
        y2 = height / 2 - y1;
        y3 = 0;
        y3 += i * 5;
        y4 = height;
        y4 -= i * 5;

        // Alternating the color of lines to create an intersting composition
        if (i < 50) {
            stroke(0);
        }
        else {
            stroke(255);
        }
        strokeWeight(.5);

        // First pair of top triangles
        line(width / 2, height / 2, x1, y1);
        line(width / 2, height / 2, width - x1, height - y1);

        // Second pair of the side triangles
        line(width / 2, height / 2, width, y4);
        line(width / 2, height / 2, 0, y3);

        // Second series of variables declared to allow for curves to be developed
        stroke(255);
        a1 = width;
        a2 = 0;
        a3 = -100;
        a4 = 0;

        a1 -= i * 4;
        a3 += i * 1.2;
        a4 += i * 5;
        // Top left curve drawn
        line(a1, a2, a3, a4);

        b1 = width;
        b2 = height;
        b3 = width;
        b4 = -5;

        b1 -= i * 4;
        b3 += i * 3;
        b4 += i * 5;
        // Bottom right curve drawn
        line(b1, b2, b3, b4);


    }


}

My inspiration for this project started with testing what combinations of lines resulted from varying the parameters in a for loop. I found interesting patterns where lines clustered together represent shadows, and by alternating colors, I was able to make an interesting composition.

Author: Ammar Hassonjee

I am a third year architecture student.

Leave a Reply