Yingying Yan – Project 4 – String Art

sketch

/*
Yingying Yan
Section E
yingyiny@andrew.cmu.edu
Project-04
*/
var x; //x1 of the line
var y; //y1 of the line
var x2; //x2 of the line
var y2; // y2 of the line

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

function draw() {
	//bottom right curve
	for( var a = 0; a < 10; a += .03){
		push();
		//assign color n weight
		stroke(255,255,161);
		strokeWeight(0.003);
		//draw from bottom left corner to top right corner
		x = lerp(0, width, a);
		y = height;
		x2 = width;
		y2 =lerp(height,0,a);
		line(x, y, x2, y2);
		pop();
	}

    //bottom left curve
	for( var b = 0; b < 30; b += .03){
		push();
		stroke(250,170,113);
		strokeWeight(0.003);
		//draw from top left corner to bottom right corner
		x = 0
		y = lerp(0, height, b)
		x2 = lerp(0, width, b);
		y2 = height;
		line(x, y, x2, y2);
		pop();

	}
    //background curve from bottom left corner to top right corner
	for(var e = 0; e < 10; e += 0.04){
		push();
		stroke(255, 244, 200);
		strokeWeight(0.001);
		//just testing what it looks like if all var are lerp
		x = lerp(0, width / 4, e);
		y = lerp(height, 3 * height / 4, e);
		x2 = lerp(3 * width / 4, width, e);
		y2 = lerp(0, height / 4, e);
		line(x, y, x2, y2);
		pop();
	}


    //draw the lighting from one point
	for ( var c = 0; c < 200; c += 10 ){

		push();
		stroke(236, 138,82);
		strokeWeight(0.09);
		// the space and height of the end of the lines
		//change consistently with + and -
		var x = width - c
		var y = height/ 2 + c
		line(0, 0, x, y)
		pop();
	}

    //draw the green lighting from a point
    //the spread of the lines froms a curve
	for (var d = 0; d < 30; d += 1){
			push();
			stroke(133,152,221);
			strokeWeight(0.003);
			//by using exponential function, the end of the lines 
			//do not have to be a straight cut
			var x = Math.pow( d, 2);
			var y = height/ 2 + Math.pow(d,2);
			line( 3 * width / 4, 0, x, y)
			pop();
	}


}







I think it was very interesting testing out lerp. Playing around with line weight and color to create a foreground and background composition was fun. Although I did not carry that all the way. I did not aim to draw a certain image. I was deciding where the curves will be as the project develops. That’s why the composition is weird. If I would have to this again, I think I will try to sketch something first, then draw it.

Leave a Reply