Victoria Reiter – Project 04 – String Art

sketch

/*
Victoria Reiter
Section B
vreiter@andrew.cmu.edu
Project-04
*/

// establishes canvas dimensions
function setup() {
    createCanvas(400, 300);
}

function draw() {
    // background color
    background(65);

    // gives values to some variables
    var x1 = 0;
    var x2 = 0;
    var y1 = 0;
    var y2 = 0;
    var g = 40;

    // angle for sin function
    var a = 0;

    // value of increment for angle in sin function
    var inc = PI / 32;

    // draws sin function
    for (var x1 = 0; x1 < width; x1 += 2) {

        // color blue
        stroke(0, 0, 255);

        line(x1 * 1.5, g, x1 * 1.5, g + sin(a + PI / 2) * 50);
        // calculates growth of angle
        a = a + inc;
        x1 += 1;
        g += 2.5;
    }

    // draws bottom left curve, the pretty lilac colored one
    for (x1 = 0; x1 < width; x1++) {
        x1 += 5;
        y2 += 5;

        // color lilac
        stroke(165, 125, 235);

        // draws curve
        line(x1, height, x2, y2);
    } 

    // draws sunset-colored curve on right side of screen
    for (x1 = 0; x1 < width; x1++) {
        x1 = x1 + 4;
        y2 += 5;

        // draws sunset-color
        stroke(244, 66, 0);

        // draws curve
        line(x1, y1, width, y2 - 75);
    } 

    // draws maroon-colored lines in middle of screen
    for (var i = 30; i < width; i += 10) {
        i += 8;

        // color maroon
        stroke(130, 9, 41);

        // draws curve
        line(width - i, height, i * .25, 0);
    }

}

Was able to create several curved lines, including using the sin function to draw a sin curve in blue. Able to draw the bottom left and the right curves as, well, curves, and the center cross of lines in maroon.

Leave a Reply