rfarn-Project-04-StringArt

My string art design is fairly simple. Once understanding the concept of a for loop, I was able to quickly apply it to the creation of this string art. There were only a few small problems I faced, such as having to reverse the direction of the increments by subtracting them from the height. Besides little technical/syntax troubles, the overall project was quick and straight forward.

sketch

var yincrement = 15; //increments along y-axis
var xincrement = 20; //increments along x-axis
var x1position = 1; //points constantly flush left
var y1position = 299; //points constantly flush bottom
var x2position = 399; //points constantly flush right
var y2position = 1; //points constantly flush top

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

function draw() {
	for(var i = 0; i < 21; i += 1) {
		strokeWeight(0.5);
		stroke(255); //white
		line(x1position, yincrement * i, xincrement * i, y1position); //lines between left and bottom
		stroke(255, 0, 0); //red
		line(x2position, yincrement * i, xincrement * i, y2position); //lines between right and top
		stroke(0, 255, 0); //green
		line(xincrement * i, y1position, x2position, height - yincrement * i); //lines between bottom and right
		stroke(0, 0, 255); //blue
		line(x1position, height - yincrement * i, xincrement * i, y2position); //lines between top and left
	}
}

Leave a Reply