//hamza qureshi
//section e
//project 04
//hqq@andrew.cmu.edu
var x1;
var y1 = 1;
var x2 = 1;
var y2 = 1;
var yDes = 400;
function setup(){
createCanvas(300,400);
}
function draw(){
background(30); //dark gray background
//create a single loop that sets the limits
//within the x1 variable to allow the curves
//to stretch horizontally
for (var x1 = 0; x1 < 4*width; x1 += 5){
strokeWeight(0.3);
var y1 = x1 * 0.50;
var yDev = height/4 + y1;
//outermost lines that are brightest in color
stroke(180);
line(x1*4, y1, x1-yDes, y2*0.5);
line(x1*.10, height, x2, yDev);
//next ring
stroke(130);
line(x1*0.4, y1*0.6, x1-yDes, y2*0.5);
line(x1*2, height*2, x2, yDev);
//next ring
stroke(80);
line(x1*0.4, y1, x1-yDes, y2*0.5);
line(x1*.90, height, x2, yDev);
///next ring
stroke(60);
line(x1*0.3, y1, x1-yDes, y2*0.5);
line(x1*1.7, height, x2, yDev);
//next ring
stroke(50);
line(x1*0.2, y1, x1-yDes, y2*0.5);
line(x1*2.5, height, x2, yDev);
//final ring
stroke(40);
line(x1*0.1, y1, x1-yDes, y2*0.5);
line(x1*3.2, height, x2, yDev);
}
}
//voila!
For this piece of string art, I wanted to create a piece that used a tunneling effect to show depth. To do this, I used the for loop to change the size, orientation, and stroke color to make it appear as if the sections are getting deeper and deeper. After a few projects where the code became so long, I’m glad that this one uses a much more refined syntax.