Project 04: String Art

For this project I chose to draw a series of four triangles around a circle that somewhat resembles light emanating from a bright white circle into the dark background.

sketch

//Helen Cheng
//helenc1
//Section C

var numLines = 50;
var canvasX = 400;
var canvasY = 300;

function setup() {
    createCanvas(400, 300);
    background(0);
    strokeWeight(0.5);
}

function draw() {
    fill(232, 231, 227);
    circle(200, 150, 200);
    line(canvasX/2, 0, 0, canvasY);
    line(canvasX/2, 0, canvasX, canvasY);
    //initilizing spacing for lines drawn
    var dist = canvasX/(numLines);
    for (var i = 0; i <= numLines; i += 1) {
      //upright triangle
      stroke(163, 66, 199)
      line(canvasX/2, 0, dist*i, canvasY);
      //upside down triangle
      stroke(232, 221, 60);
      line(canvasX/2, canvasY, dist*i, 0);
      //left triangle
      stroke(47, 255, 0);
      line(300, 150, 0, dist*i);
      //right triangle
      stroke(255, 0, 0);
      line(100, 150, canvasX, dist*i);  
    }
    noLoop();
}

Leave a Reply