Project 04 Line Art

The line art examples reminded me of space and warp patterns we would see in movies, so I decided to try to capture a sense of movement similar to a spaceship warp.

sketch
var dx1;
var dy1;
var dx2;
var dy2;
var tunnelW = 20;
var tunnelH = 20 ;
var xwall ;
var ywall;
var conNumLines = 20;
var numLines;
var x = 0;
var rb = 0;
var gb = 0;
var bb = 0;

function setup() {
    createCanvas(400, 400);
    background(200);
}
function draw(){
    var r = (random(0,255));
    var g = (random(0,255));

    numLines = random(15);
    xwall = max(dist(mouseX,0,0,0),dist(mouseX,0,width,0));
    ywall = max(dist(0,mouseY,0,0),dist(0,mouseY,0,height));
    //setupbackground
    background(rb,gb,bb);
    rb += random(0,1);
    gb += random(0,2);
    bb += random(0,2);
    if (rb>255 || gb>255 || bb>255){
        rb=0;
        gb=0;
        bb=0;
    }
    //setup end oof tunnel 
    rectMode(CENTER);
    noFill();
    push();
    translate(mouseX,mouseY);
    rect(0,0,tunnelW+x,tunnelH+x);
    x+=3;
    if ((tunnelW+x)> xwall || (tunnelH+x)> ywall) {
        x=0;
    }
    pop();
    fill(255);
    rect(mouseX,mouseY,2*tunnelW,2*tunnelH);
    
    //inner lines
    //top line
    line(mouseX-tunnelW,mouseY-tunnelH,mouseX+tunnelW,mouseY-tunnelH);
    //bottom line
    line(mouseX-tunnelW,mouseY+tunnelH,mouseX+tunnelW,mouseY+tunnelH);
    //left line
    line(mouseX-tunnelW,mouseY-tunnelH,mouseX-tunnelW,mouseY+tunnelH);
    //right line
    line(mouseX+tunnelW,mouseY-tunnelH,mouseX+tunnelW,mouseY+tunnelH);
    
    //outer lines 
    //top line
    line(0,0,width,0);
    //bottom line
    line(0,height,width,height);
    //left lin 
    line(0,0,0,height);
    //right lin
    line(width,0,width,height);

    //perspective line
    //top 
    dx1 = ((mouseX+tunnelW)-(mouseX-tunnelW))/numLines;
    dy1 = ((mouseY-tunnelH)-(mouseY-tunnelH))/numLines;
    dx2 = (width-0)/numLines;
    dy2 = (0-0)/numLines;
    stroke(r,g,0);
    strokeWeight(random(0.5,2));
    var topx1 = mouseX-tunnelW;
    var topy1 = mouseY-tunnelH;
    var topx2 = 0;
    var topy2 = 0;
    for (var i = 0; i <= numLines; i += 1) {
        line(topx1, topy1, topx2, topy2);
        topx1 += dx1;
        topy1 += dy1;
        topx2 += dx2;
        topy2 += dy2;
    }   
    //bottom 
    dx1 = ((mouseX+tunnelW)-(mouseX-tunnelW))/numLines;
    dy1 = ((mouseY+tunnelH)-(mouseY+tunnelH))/numLines;
    dx2 = (width-0)/numLines;
    dy2 = (height-height)/numLines;
    stroke(r,g,0);
    strokeWeight(random(0.5,2));
    var bottomx1 = mouseX-tunnelW;
    var bottomy1 = mouseY+tunnelH;
    var bottomx2 = 0;
    var bottomy2 = height;
    for (var i = 0; i <= numLines; i += 1) {
        line(bottomx1, bottomy1, bottomx2, bottomy2);
        bottomx1 += dx1;
        bottomy1 += dy1;
        bottomx2 += dx2;
        bottomy2 += dy2;
    }   
    //left 
    dx1 = ((mouseX-tunnelW)-(mouseX-tunnelW))/numLines;
    dy1 = ((mouseY+tunnelH)-(mouseY-tunnelH))/numLines;
    dx2 = (0-0)/numLines;
    dy2 = (height-0)/numLines;
    stroke(r,g,0);
    strokeWeight(random(0.5,2));
    var leftx1 = mouseX-tunnelW;
    var lefty1 = mouseY-tunnelH;
    var leftx2 = 0;
    var lefty2 = 0;
    for (var i = 0; i <= numLines; i += 1) {
        line(leftx1, lefty1, leftx2, lefty2);
        leftx1 += dx1;
        lefty1 += dy1;
        leftx2 += dx2;
        lefty2 += dy2;
    }   
    //right 
    dx1 = ((mouseX+tunnelW)-(mouseX+tunnelW))/numLines;
    dy1 = ((mouseY+tunnelH)-(mouseY-tunnelH))/numLines;
    dx2 = (width-width)/numLines;
    dy2 = (height-0)/numLines;
    stroke(r,g,0);
    strokeWeight(random(0.5,2));
    var rightx1 = mouseX+tunnelW;
    var righty1 = mouseY-tunnelH;
    var rightx2 = width;
    var righty2 = 0;
    for (var i = 0; i <= numLines; i += 1) {
        line(rightx1, righty1, rightx2, righty2);
        rightx1 += dx1;
        righty1 += dy1;
        rightx2 += dx2;
        righty2 += dy2;
    }   
    stroke(255);
    //side 1 
    dx1 = (width-0)/conNumLines;
    dy1 = (0-0)/conNumLines;
    dx2 = (0-0)/conNumLines;
    dy2 = (height-0)/conNumLines;
    strokeWeight(1);
    var sidex1 = 0;
    var sidey1 = 0;
    var sidex2 = 0;
    var sidey2 = height;
    for (var i = 0; i <= conNumLines; i += 1) {
        line(sidex1, sidey1, sidex2, sidey2);
        sidex1 += dx1;
        sidey1 += dy1;
        sidex2 -= dx2;
        sidey2 -= dy2;
    }
    //side 2
    dx1 = (width-0)/conNumLines;
    dy1 = (0-0)/conNumLines;
    dx2 = (width-width)/conNumLines;
    dy2 = (height-0)/conNumLines;
    strokeWeight(1);
    var sidex1 = 0;
    var sidey1 = 0;
    var sidex2 = width;
    var sidey2 = 0;
    for (var i = 0; i <= conNumLines; i += 1) {
        line(sidex1, sidey1, sidex2, sidey2);
        sidex1 += dx1;
        sidey1 += dy1;
        sidex2 += dx2;
        sidey2 += dy2;
    }
    //side 3
    dx1 = (width-width)/conNumLines;
    dy1 = (height-0)/conNumLines;
    dx2 = (width-0)/conNumLines;
    dy2 = (height-height)/conNumLines;
    strokeWeight(1);
    var sidex1 = width;
    var sidey1 = height;
    var sidex2 = 0;
    var sidey2 = height;
    for (var i = 0; i <= conNumLines; i += 1) {
        line(sidex1, sidey1, sidex2, sidey2);
        sidex1 -= dx1;
        sidey1 -= dy1;
        sidex2 += dx2;
        sidey2 += dy2;
    }
    //side 4
    dx1 = (width-0)/conNumLines;
    dy1 = (height-height)/conNumLines;
    dx2 = (0-0)/conNumLines;
    dy2 = (height-0)/conNumLines;
    strokeWeight(1);
    var sidex1 = width;
    var sidey1 = height;
    var sidex2 = 0;
    var sidey2 = height;
    for (var i = 0; i <= conNumLines; i += 1) {
        line(sidex1, sidey1, sidex2, sidey2);
        sidex1 -= dx1;
        sidey1 -= dy1;
        sidex2 += dx2;
        sidey2 -= dy2;
    }
}

Project-04 String Art

string art
var angle = 0;

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

function draw() {
   background(89, 190, 209);

  var waveLx1 = 0;
  var waveLx2 = 0;
  var waveLy = height/40;

  var dy1 = height/40;
  var dx1 = width/30;
  var dx2 = height/150;
  var i = 0;

  stroke(43, 58, 140);
  line(0, 300, 101, 55);    //for second wave
  stroke(27, 85, 145);
  line(125, 300, 200, 105);    //for third wave

  //first wave
  for (i = 0; i < 400; i += 1) {
    stroke(37, 36, 94);
    line(waveLx1, 300, waveLx2, waveLy);
    // x moves in opposite directions
    waveLx1 += dx1;
    waveLx2 -= dx2;
    waveLy += dy1;    // increase y value
  }

  push();

  //second wave
  translate(100, 50);

  waveLx1 = 0;
  waveLx2 = 0;
  waveLy = height/40;
  dy1 = height/40;
  dx1 = width/10;
  dx2 = height/100;
  i = 0;

  for (i = 0; i < 400; i += 1) {
    stroke(43, 58, 140);
    line(waveLx1, 300, waveLx2, waveLy);
    // x moves in opposite directions
    waveLx1 += dx1;
    waveLx2 -= dx2;
    waveLy += dy1;    // increase y value
  }

  pop();

  push();

  //third wave
  translate(200, 100);

  waveLx1 = 0;
  waveLx2 = 0;
  waveLy = height/40;
  dy1 = height/40;
  dx1 = width/5;
  dx2 = height/100;
  i = 0;

  for (i = 0; i < 400; i += 1) {
    stroke(27, 85, 145);
    line(waveLx1, 300, waveLx2, waveLy);
    // x moves in opposite directions
    waveLx1 += dx1;
    waveLx2 -= dx2;
    waveLy += dy1;    // increase y value
  }

  pop();

  push();

  //rotating sun 
  translate(335, 70);
  noStroke();
  fill(240, 180, 87);
  ellipse(0, 0, 40, 40);

   for (var i = 0 ; i <360; i+=10) {
    rotate(radians(angle));
    stroke(240, 180, 87);
    strokeWeight(2);
    line(0, 0, 50, 0);
    line(0, 0, 50*cos(radians(i)), 50*sin(radians(i)));
    angle = angle + 1;
  }

  pop();

  //clouds
  noStroke();
  ellipse(265, 100, 35, 35);
  ellipse(245, 105, 25, 25);
  ellipse(285, 105, 25, 25);

  ellipse(345, 135, 35, 35);
  ellipse(360, 140, 35, 35);
  ellipse(375, 140, 25, 25);
  ellipse(330, 140, 25, 25);

  
}

I was inspired by the string art image of a beach below. I drew out the basic shapes on illustrator which helped determine the points of the initial lines. The most challenging part was figuring out how to keep the sun rotating.

Initial inspiration image
Initial basic sketch of shapes illustrator

Project04: String Art

sketch
/*
Bon Bhakdibhumi
bbhakdib
Section D
*/
var dx1;
var dy1;
var dx2;
var dy2;
var dx3;
var dy3;
var dx4;
var dy4;
var dx5;
var dy5;
var dx6;
var dy6;
var dx7;
var dy7;
var dx8;
var dy8;
var numLines = 15;

function setup() {
  createCanvas(400, 300);
  text("p5.js vers 0.9.0 test.", 10, 15);
}

function draw() {
  background(255);
   
  var backLines = 20;
  // green and yellow green rays
  strokeWeight(2.5);
  stroke(39, 183, 121);
  line(-24, 171, 30, -2); // green reference line
  stroke(158, 191, 67);
  line(31, -13, 277, 36); // yellow reference line
  
  var dx15 = (30+24)/backLines;
  var dy15 = (-2-171)/backLines;
  var dx16 = (277-31)/backLines;
  var dy16 = (36+13)/backLines;
  var x15 = -24;
  var y15 = 171;
  var x16 = 31;
  var y16 = -13;
  for (var i = 0; i <= backLines; i ++) {
    strokeWeight(0.7);
    // if statement for equal amout of green and yellow green rays
    if (i < backLines/2) {
    stroke(39, 183, 121);
    } else {
      stroke(158, 191, 67);
    }
    line(x15, y15, x16, y16);
    x15 += dx15;
    y15 += dy15;
    x16 += dx16;
    y16 += dy16;
  }
  // lines that make up the octagon
  strokeWeight(3);
  stroke(0, 144, 85);
  line(25, 90, 101, 15); // green line
  
  stroke(241, 233 , 2);
  line(108, 12, 220, 12); // yellow line
  
  stroke(246, 137, 31);
  line(224, 13, 303, 92); // orange line 
  
  stroke(237, 28 ,36);
  line(306, 100, 306, 212); // red line
  
  stroke(122, 53, 148);
  line( 304, 216, 224, 295,); // purple line
  
  stroke(73, 78, 161);
  line(220, 296, 107, 296); // indigo line
  
  stroke(0, 114, 185);
  line(102, 292, 22, 213); // blue line 
  
  stroke(0, 153, 192);
  line(22, 205, 22, 92); // blue green
  
  // delta x & y for all the lines that make up the octagon
  dx1 = (101-25)/numLines;
  dy1 = (15-90)/numLines;
  dx2 = (220-108)/numLines;
  dy2 = (12-12)/numLines;
  dx3 = (303-224)/numLines;
  dy3 = (92-13)/numLines;
  dx4 = (306-306)/numLines;
  dy4 = (212-100)/numLines;
  dx5 = (224-304)/numLines;
  dy5 = (295-216)/numLines;
  dx6 = (107-220)/numLines;
  dy6 = (296-296)/numLines;
  dx7 = (22-102)/numLines;
  dy7 = (213-292)/numLines;
  dx8 = (22-22)/numLines;
  dy8 = (92-205)/numLines;
  
  // x & y coordinates for all the lines that make up the octagon
  var x1 = 25;
  var y1 = 90;
  var x2 = 108;
  var y2 = 12;
  var x3 = 224;
  var y3 = 13;
  var x4 = 306;
  var y4 = 100;
  var x5 = 304;
  var y5 = 216;
  var x6 = 220;
  var y6 = 296;
  var x7 = 102;
  var y7 = 292;
  var x8 = 22;
  var y8 = 205;
  
  // lines that make up the outer layer of the octagon
  strokeWeight(1);
  for (var i = 0; i <= numLines; i ++) {
    // green
    stroke(0, 144, 85);
    line(x1,y1, x2, y2);
    x1 += dx1;
    y1 += dy1;
    x2 += dx2;
    y2 += dy2;
  }
   
  x2 = 108;
  y2 = 12;
  for (var i = 0; i <= numLines; i ++) {
  // yellow
    stroke(241, 233 , 2);
    line(x2, y2, x3, y3);
    x2 += dx2;
    y2 += dy2;
    x3 += dx3;
    y3 += dy3;
   }
  
  x3 = 224;
  y3 = 13;
  for (var i = 0; i <= numLines; i ++) {
    // orange
    stroke(246, 137, 31);
    line(x3, y3, x4, y4);
    x3 += dx3;
    y3 += dy3;
    x4 += dx4;
    y4 += dy4;
  }
  
  x4 = 306;
  y4 = 100;
  for (var i = 0; i <= numLines; i ++) {
    // red
    stroke(237, 28 ,36);
    line(x4, y4, x5, y5);
    x4 += dx4;
    y4 += dy4;
    x5 += dx5;
    y5 += dy5;
  }
  
  x5 = 304;
  y5 = 216;
  for (var i = 0; i <= numLines; i ++) {
    // purple
    stroke(122, 53, 148);
    line(x5, y5, x6, y6);
    x5 += dx5;
    y5 += dy5;
    x6 += dx6;
    y6 += dy6;
  }
  
  x6 = 220;
  y6 = 296;
  for (var i = 0; i <= numLines; i ++) {
    // indigo
    stroke(73, 78, 161);
    line(x6, y6, x7, y7);
    x6 += dx6;
    y6 += dy6;
    x7 += dx7;
    y7 += dy7;
  }
  
  x7 = 102;
  y7 = 292;
  for (var i = 0; i <= numLines; i ++) {
    // blue
    stroke(0, 114, 185);
    line(x7, y7, x8, y8);
    x7 += dx7;
    y7 += dy7;
    x8 += dx8;
    y8 += dy8;
  }
  
  // Lines that make up the inner layer of the octagon
  x1 = 25;
  y1 = 90;
  x5 = 304;
  y5 = 216;
  for (var i = 0; i <= numLines; i ++) {
    // green
    strokeWeight(1);
    stroke(0, 144, 85);
    line(x1, y1, x5, y5);
    x1 += dx1;
    y1 += dy1;
    x5 += dx5;
    y5 += dy5;
  }
 
  x2 = 108;
  y2 = 12;
  x6 = 220;
  y6 = 296;
  for (var i = 0; i <= numLines; i ++) {
    // yellow
    strokeWeight(2);
    stroke(241, 233 , 2);
    line(x2, y2, x6, y6);
    x2 += dx2;
    y2 += dy2;
    x6 += dx6;
    y6 += dy6;
  }
 
  x3 = 224;
  y3 = 13;
  x7 = 102;
  y7 = 292;
  for (var i = 0; i <= numLines; i ++) {
    //red
    strokeWeight(1);
    stroke(237, 28 ,36);
    line(x3, y3, x7, y7);
    x3 += dx3;
    y3 += dy3;
    x7 += dx7;
    y7 += dy7;
  }
 
  x4 = 306;
  y4 = 100;
  x8 = 22;
  y8 = 205;
  for (var i = 0; i <= numLines; i ++) {
    // blue
    stroke(0, 114, 185);
    line(x4, y4, x8, y8);
    x4 += dx4;
    y4 += dy4;
    x8 += dx8;
    y8 += dy8;
  }
  
  // rays coming out of the octagon
  var frontLines = 25;
  
  // yellow and orange rays
  push();
  translate (-30, 0);
  strokeWeight(2.5);
  stroke(255, 199, 9);
  line(202, -25, 450, 100); // yellow
  stroke(241, 90, 34);
  line(450, 120, 198, 340); //orange
  var dx9 = (450-202)/frontLines;
  var dy9 = (100+25)/frontLines;
  var dx10 = (198-404)/frontLines;
  var dy10 = (340-149)/frontLines;
  var x9 = 202;
  var y9 = -25;
  var x10 = 450;
  var y10 = 120;
  for (var i = 0; i <= frontLines; i ++) {
    strokeWeight(0.7);
    if (i < numLines/2) {
    stroke(255, 199, 9);
    } else {
      stroke(241, 90, 34);
    }
    line(x9, y9, x10, y10);
    x9 += dx9;
    y9 += dy9;
    x10 += dx10;
    y10 += dy10;
  }
  pop();
  
  //dark blue and light blue rays
  push();
  rotate(radians(-2));
  strokeWeight(2.5);
  stroke(49, 192, 211); 
  line(17, 88, -16, 258); // dark blue
  stroke(82, 92, 193);
  line(-25, 287, 255, 308); // light blue
  var dx11 = (-16-17)/frontLines;
  var dy11 = (258-88)/frontLines;
  var dx12 = (255+25)/frontLines;
  var dy12 = (308-287)/frontLines;
  var x11 = 17;
  var y11 = 88;
  var x12 = -25;
  var y12 = 287;
  for (var i = 0; i <= frontLines; i ++) {
    strokeWeight(0.7);
    if (i < numLines/2) {
    stroke(49, 192, 211);
    } else {
      stroke(82, 92, 193);
    }
    line(x11, y11, x12, y12);
    x11 += dx11;
    y11 += dy11;
    x12 += dx12;
    y12 += dy12;
  }
  pop();
  
  // red violet and purple rays
  push();
  translate(-65, 210);
  rotate(radians(-50));
  strokeWeight(2.5);
  stroke(210, 18, 131);
  line(326, 196, 249, 346); // red violet
  stroke(115, 54, 232);
  line(314, 348, 76, 276); // purple
  var dx13 = (249-326)/frontLines;
  var dy13 = (346-196)/frontLines;
  var dx14 = (76-314)/frontLines;
  var dy14 = (276-348)/frontLines;
  var x13 = 326;
  var y13 = 196;
  var x14 = 314;
  var y14 = 348;
  for (var i = 0; i <= frontLines; i ++) {
    strokeWeight(0.7);
    if (i < numLines/2) {
    stroke(210, 18, 131);
    } else {
      stroke(115, 54, 232);
    }
    line(x13, y13, x14, y14);
    x13 += dx13;
    y13 += dy13;
    x14 += dx14;
    y14 += dy14;
  }
  pop();
  noLoop();
}

For this project, I reinterpreted Itten’s color wheel. I created the main octagon out of primary and secondary colors. I then added in the rest of the string drawings to show the various outcomes of mixing different colors together.

Itten’s Color Wheel

Project – String Art

My String Art project is heavily inspired by the installation art of the Japanese artist Chiharu Shiota. The String Art assignment reminded me of her intricate installations of spaces and objects clad in an intricate weaving of thread. My process began with me drawing the setting, a dingy gallery space with an ominous void. Afterwards, I decided to make the drawing interactive and have the string art appear after the user clicks into the void.

sketchDownload
// String Art
var dx1;
var dy1;
var dx2;
var dy2;
var dx3;
var dy3;
var dx4;
var dy4;
var dx5;
var dy5;
var numLines = 200;
var glowSize = 0;
function setup() {
    createCanvas(400, 300);
    background(0);
    text("p5.js vers 0.9.0 test.", 10, 15);
    
  
}

function draw() {
	var voidX = width/2 - 40;
	var voidY = height/2 - 40;
	background(0);
	fill(220);
	stroke(220);
	rect(0,0,width,height); // room wall
	stroke(255,0,0);
	fill(0);
	circle(voidX, voidY, 125); //sinister void
	noStroke();
	fill(255,0,0,20);
	circle(voidX, voidY, 140 + glowSize); //glow around void
	fill(100);
	rect(0, height/2 + 70, width, height); //room floor
	//wall lights
	fill(255,255,0,70);
	circle(50,0,30);
	circle(120,0,30);
	circle(190,0,30);
	circle(260,0,30);
	circle(330,0,30);
	fill(255,255,0,100);
	circle(50,0,40);
	circle(120,0,40);
	circle(190,0,40);
	circle(260,0,40);
	circle(330,0,40);
	//reflection on floor
	fill(255,255,0,20);
	ellipse(190,height/2 + 90,300,10);
	fill(255,255,0,45);
	ellipse(190,height/2 + 90,200,5);
	//if user clicks in void eye and string art appears
	if (mouseIsPressed & abs(mouseX - voidX) <= 62.5 && abs(mouseY -voidY)<=62.5){
		//eye
		fill(255);
		noStroke();
		circle(voidX,voidY,60);
		fill(255,0,0);
		circle(voidX,voidY,20);
		fill(0);
		circle(voidX,voidY,10);
		//string art
		noFill();
		strokeWeight(.1);
		stroke(255,0,0);
		line(width, 0, 0, 10);
		line(10,0,width,30);
		line(40,height,100,0);
		line(300,0,350,height);
		line(230,0,200,height);
		dx1 = -width/numLines;
		dy1 = 10/numLines
		dx2 = (width-10)/numLines;
		dy2 = -height/numLines;
		dx3 = 60/numLines;
		dy3 = -height/numLines;
		dx4 = 50/numLines;
		dy4 = height/numLines;
		dx5 = -30/numLines;
		dy5 = height/numLines;
		var x1 = width;
		var y1 = 0;
		var x2 = 10;
		var y2 = 0;
		var x3 = 40;
		var y3 = height;
		var x4 = 300;
		var y4 = 0;
		var x5 = 230;
		var y5 = 0;
		for(var drawLine = 0; drawLine <= numLines; drawLine += 1){
			line(x1,y1,x2,y2);
			line(x1,y1,x3,y3);
			line(x1,y1,x4,y4);
			line(x1,y1,x5,y5);
			line(x2,y2,x3,y3);
			line(x2,y2,x4,y4);
			line(x2,y2,x5,y5);
			line(x3,y3,x4,y4);
			line(x3,y3,x5,y5);
			line(x4,y4,x5,y5);
			x1 += dx1;
			x2 += dx2;
			x3 += dx3;
			y1 += dy1;
			y2 += dy2;
			y3 += dy3;
			x4 += dx4;
			y4 += dy4;
			x5 += dx5;
			y5 += dy5;
		}

	}
	if(glowSize == 60){
		glowSize = 0;
	} else {
		glowSize += 1;
	}
}

A Chiharu Shiota installation that helped inspire my work

Project 4 – String Art

click!

mountainsnowstorm
// Yoo Jin Kim
// 15104 - section D
// yoojink1@andrew.cmu.edu
//Project-04

//gradience variables
var yaxis = 1;
var xaxis = 2;
let c1, c2;

function setup() {
    createCanvas(400, 300);

    //variables for gradient background colors
    c1 = color(240); //whitegray
    c2 = color(113, 178, 200); //light blue
}

function draw() {
  //gradient background 
  setGradient(0, 0, 400, 300, c1, c2, yaxis);
  setGradient(0, 0, 400, 700, c2, c1, xaxis);

  //full moon
  noStroke();
  fill(255,255,255,200);
  ellipse(330,80,85);

  //mountains (line shapes)
  for (var i = 0; i <= 330; i += 3) {
    stroke(255);
    strokeWeight(0.35);
    line(0, i, i, 300); //first left mountain
    line(50, i, i + 50, 330); //second left mountain
    line(100, i + 50, i + 100, 300); //third left mountain
    line(200, i + 80, i + 200, 330); //fourth left mountain
  }

  //random repetition of background snowflakes (ellipses) every time you refresh the page
  for (var e = 0; e <= 50; e += 1) {
    stroke(255);
    fill(255, 255, 255, 100);
    strokeWeight(0.5);
    ellipse(random(50, 400), random(0, 300), 5);
  }

  //front snowflakes (line shapes)
  stroke(255);
  strokeWeight(0.5);

  //random repetition of the front snowflakes every time you refresh the page
  for (xx = 0; xx <= 50; xx += 1) {
    push();
    translate(random(10,400), random(10,400));
    points = 20;
    pAngle = 360 / points;
    radius = width / 75;

    for (angle = 100; angle < 500; angle += pAngle) {
      x = cos(radians(angle)) * radius;
      y = sin(radians(angle)) * radius;
      line(radius, radius, x + radius, y + radius);
    }
    pop();
  }
  noLoop();
}

//gradient background
function setGradient(x, y, w, h, c1, c2, axis) {
  if (axis == yaxis) {
    //gradience from top to bottom
    for (let i = y; i <= y + h; i += 1) {
      let int = map(i, y, y + h, 0, 1);
      let c3 = lerpColor(c1, c2, int);
      stroke(c3);
      line(0, i, 400, i);
      //reference/inspiration for gradient background: https://p5js.org/examples/color-linear-gradient.html
    }
  } 
}

function mousePressed () {
  //snow icicles attack as you click mouse (line shapes)
  stroke(255);
  strokeWeight(0.2);
  for (xx = 0; xx <= 10; xx += 1) {
    push();
    translate(random(10, 400), random(10, 400));
    points = 20;
    pAngle = 360 / points;
    radius = width / 75;

    for (angle = 100; angle < 500; angle += pAngle) {
      x = cos(radians(angle)) * radius;
      y = sin(radians(angle)) * radius;
      line(radius + mouseX, radius, x + radius, y + radius);
    }
    pop();
  }
}

At first, I wanted to create waves, but as I moved forward with the project, I changed to creating an interactive snowstorm in the mountains. I visualized from the hikers’ perspective, so the idea is for the view to get blurrier (whiter) as I keep clicking the mouse.

snapshots of progress

Project-04

For this project, I started with a basic pattern I wanted to achieve, then kept modifying it and exploring what I could do with mouse movements as well. Move your mouse around to reveal the hidden face 😀

zimmy string



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

}

function draw() {
	var xL1 = 0;
	var xL2 = 0;
	var y1 = 0;
	var y2 = 400;
    
    stroke(255, 131, 100);
    var y = 0
    for(var x = 0; x <= 400; x += 10){
        line(x, y, mouseX, mouseY);
    } // orange lines that follow mouse and fill in the background

    noStroke();
    fill(0);
    circle (130, 130, 10);
    circle(150, 130, 10);
    arc(140, 140, 30, 30, 0, PI, CHORD);
    // hidden smiley face :D

    stroke(255, 210, 235);
    for (var y1 = 0; y1 <= 300; y1 +=10) {
    	line(xL1, y1, xL2, y2);
    	xL2 += 40;
    } // pink lines in bottom left corner

    var xR1 = 400;
    var xR2 = 400;
	var y1 = 0;
	var y2 = 400;
    for (var y1 = 0; y1 <= 300; y1 +=10) {
    	line(xR1, y1, xR2, y2);
    	xR2 -= 40;
    } // pink lines in bottom right corner

    stroke(255);
    xL2 = 0;
    for (var y1 = 0; y1 <= 300; y1 +=10) {
    	line(xL1, y1, xL2, y2);
    	xL2 += 30;
    } // white lines in bottom left corner
    
    stroke(200, 0, 200);
    xR2 = 400;
    for (var y1 = 0; y1 <= 300; y1 +=10) {
    	line(xR1, y1, xR2, y2);
    	xR2 -= 30;
    } // purple lines in bottom right corner
    
    stroke(239, 29, 255);
    xR2 = 400;
    y2 = 0;
    for (var y1 = 300; y1 >= 0; y1 -=10) {
    	line(xR1, y1, xR2, y2);
    	xR2 -= 10;
    } // purple lines in top right corner
    
    stroke(255, 131, 199);
    xL2 = 0;
    y2 = 0;
    for (var y1 = 300; y1 >= 0; y1 -=10) {
    	line(xR1, y1, xR2, y2);
    	xR2 -= 10;
    } // pink lines in top right
    

}

Project-04: String Art

For my project, I was inspired by some string art I had seen a while ago at the beach. I remember seeing how lines would give the sails of a sailboat depth, and almost make it look slightly 3-D. I thought that making the sails were challenging because the sails are all different shapes and face different directions, and it took me a while to figure out how to perfectly layer the lines.

If you move the mouse around the screen, the lighthouse light will follow it around the page. Though this assignment focuses mostly on lines, I also incorporated other shapes and features in order to give the overall project that “finished” look.

sketch
//Annie Kim
//anniekim
//SectionB
var dx1;
var dy1;
var dx2;
var dy2;

var numLines = 30;
var boatLines = 40;

var mx1;
var my1;
var mx2;
var my2;

var bx1;
var by1;
var bx2;
var by2;

var angle = 0;


function setup() {
    createCanvas(400, 300);
    background(100, 200, 255);;
    stroke(255);
    //left side sail lines
    line(60, 185, 150, 190); //left side sail horizontal
    line(150, 190, 210, 70); //left side sail vertical
    dx1 = (150 - 60)/numLines;
    dy1 = (190 - 185)/numLines;
    dx2 = (210 - 150)/numLines;
    dy2 = (70 - 190)/numLines;

    //middle sail lines
    line(230, 40, 155, 191); // vertical
    line(155, 191, 245, 195); //horizontal
    mx1 = (155-230)/numLines;
    my1 = (191-40)/numLines;
    mx2 = (245-155)/numLines;
    my2 = (195-191)/numLines;

    
    //right sail lines
    stroke(255);
    line(270, 70, 250, 195);
    line(250, 195, 310, 196);
    bx1 = (250-270)/numLines;
    by1 = (195-70)/numLines;
    bx2 = (310-250)/numLines;
    by2 = (196-195)/numLines;

    //water lines
    stroke(74, 152, 168);
    line(0, 150, 400, 150);
    line(0, 300, 400, 150);
    line(0, 150, 0, 300);
    line(400, 150, 400, 300);


}

function draw() {

    //skyline & waterline
    stroke(179, 213, 244);
    strokeWeight(1.2);
    fill(179, 213, 244); //light blue sky
    rect(0, 0, 400, 150); //top rect sky
    //sun rising
    push();
    translate(100, 150);
    rotate(radians(angle));
    fill(242, 244, 190);
    noStroke();
    circle(50, 150, 120);
    pop();
    angle = angle + 1;
    //waters/waterline
    fill(74, 152, 168); //teal waters
    rect(0, 150, 400, 150); //bottom rect - waterline

    stroke(44, 122, 138); //waves webbing
    for (var i = 0; i <= 50; i ++) {
    	line(0, 300, 0 + 8*i, 151);
    }
    for (var i = 0; i <= 50; i ++) {
    	line(400, 300, 400 - 8*i, 151);
    }
    for (var i = 0; i <= 30; i ++) {
    	line(0, 150, 0 + 13.333*i, 300);
    }
    for (var i = 0; i <= 30; i ++) {
    	line(400, 150, 400 - 13.3333*i, 300);
    }
    //lighthouse building
    stroke(200);
    fill(200); //light grey color
    quad(370, 150, 375, 70, 385, 70, 390, 150); //base of lighthouse

    rect(374, 50, 12, 10); // the part of the lighthouse where the light will come from

    stroke(52, 54, 76); //dark navy color
    fill(52, 54, 76);
    quad(375, 70, 372, 60, 388, 60, 385, 70); //walk base of lighthouse

    triangle(372, 50, 380, 40, 388, 50); //top of lighthouse


    //hill
    fill(127, 105, 91); //brown color for sand under lighthouse
    stroke(127, 105, 91);
    strokeWeight(1);
    point(328, 151); //making lighthouse hill points
    point(331, 146);
    point(334, 143);
    point(336, 142);
    point(339, 140);
    point(345, 138);
    point(350, 136);
    point(355, 136);
    point(360, 136);
    point(365, 135);
    point(370, 134);
    point(375, 134);
    point(380, 133);
    point(385, 133);
    point(390, 132);
    point(400, 130);
    point(400, 151);

    beginShape();
    curveVertex(328, 151); //connecting hill points
    curveVertex(328, 151);
    curveVertex(331, 146);
    curveVertex(334, 143);
    curveVertex(336, 142);
    curveVertex(339, 140);
    curveVertex(345, 138);
    curveVertex(350, 136);
    curveVertex(355, 135);
    curveVertex(360, 136);
    curveVertex(365, 135);
    curveVertex(370, 134);
    curveVertex(375, 134);
    curveVertex(380, 133);
    curveVertex(385, 133);
    curveVertex(390, 132);
    curveVertex(400, 130);
    curveVertex(400, 151);
    curveVertex(400, 151);
    endShape();
    
    //lights of lighthouse
    fill(248, 226, 94);
    stroke(248, 226, 94);
    quad(374, 51, 374, 59, mouseX, mouseY + 12, mouseX, mouseY - 8);

    //birds
    stroke(40);
    strokeWeight(2);
    point(88, 63);
    point(96, 65);
    point(100, 70);
    point(104, 65);
    point(112, 63);

    point(138, 33);
    point(146, 35);
    point(150, 40);
    point(154, 35);
    point(162, 33);
    
    strokeWeight(1);
    line(88, 63, 96, 65);
    line(96, 65, 100, 70);
    line(100, 70, 104, 65);
    line(104, 65, 112, 63);

    line(138, 33, 146, 35);
    line(146, 35, 150, 40);
    line(150, 40, 154, 35);
    line(154, 35, 162, 33);

    stroke(255);
    strokeWeight(1.2);
	//left side sail
	var x1 = 60; 
	var y1 = 185;
	var x2 = 150;
	var y2 = 190;

	for (var i = 0; i <= numLines; i += 1) { //connecting webs of left sail
		line(x1, y1, x2, y2);
		x1 += dx1;
		y1 += dy1;
		x2 += dx2;
		y2 += dy2;
	}
	//noLoop();
    
    for (var i = 0; i <= 15; i++) { //adding vertical lines for left sail
    	line(60 + 6*i, 185 + 0.33333*i, 210 - 4*i, 70 + 8*i);
    }

	//middle sail
	var m1 = 230;
	var m2 = 40;
	var m3 = 155;
	var m4 = 191;

		for (var i = 0; i <= numLines; i += 1) { //connecting webs of middle sail
		line(m1, m2, m3, m4);
		m1 += mx1;
		m2 += my1;
		m3 += mx2;
		m4 += my2;
		
	}
	//noLoop();

	for (var i = 0; i <= 20; i ++) { //adding vertical lines for middle sail
		line(155 + 4.5*i, 191 + 0.2*i, 155 + 3.75*i, 191 - 7.505*i);
	}
	
    
    //right sail
    var b1 = 270;
    var b2 = 70;
    var b3 = 250;
    var b4 = 195;

    for (var i = 0; i <= numLines; i += 1) { //connecting webs of right sail
    	line(b1, b2, b3, b4);
    	b1 += bx1;
    	b2 += by1;
    	b3 += bx2;
    	b4 += by2;
    }
    //noLoop();
	
	for (var i = 0; i <= 10; i ++) { //adding vertical lines for right sail
		line(250 + 6*i, 197 - 0.2*i, 250 + 2*i, 195 - 12.5*i);
	} 

    //boat waves lines
    stroke(14, 92, 108);
    line(260, 243, 375, 220);
    line(260, 245, 370, 240);
    line(260, 250, 400, 250);
    line(260, 255, 390, 260);
    line(270, 260, 375, 280);

    //the bottom of the sailboat 
    stroke(230, 150, 50);
    strokeWeight(1);

    //bottom of sail boat

    //first horizontal line
    line(60, 190, 310, 200); 
    //second horizontal 
    line(100, 260, 270, 260);
    //left side of lower boat
    line(60, 190, 100, 260);
    //right side of lower boat 
    line(310, 200, 270, 260);

    fill(250, 180, 100);
    quad(60, 190, 310, 200, 270, 260, 100, 260);

    for (var i = 0; i <= 30; i ++) {
    	    line(60, 190, 100 + 5.66666*i, 260); //hatching from left top corner to bottom line

    }
    
    for (var i = 0; i <= 30; i++) {
    	line(310, 200, 270 - 5.66666*i, 260); //hatching from top right corner to bottom line 
    }

    stroke(210, 140, 30);
    for (var i = 0; i <= 15; i++) { //hatching from top left corner to right side
    	line(60, 190, 270 + 2.6666*i, 260 - 4*i);
    }

    for (var i = 0; i <= 15; i++) { //hatching from top right corner to left side
    	line(310, 200, 100 - 2.666*i, 260 - 4.6666*i);
    }

 


}

Project – 04 – String Art

sketch
/* 
 * Amy Lee 
 * amyl2
 * Section B 
 */ 

//* INSPIRED BY ORIGAMI FORTUNE TELLING GAME *//

var db2;
var dd2; 
var x; 
var y; 
var numLines = 30; 

function setup() {
    createCanvas(400,400);

    x = width; 
    y = height; 

    // Outer Square Outline 
    //leftmost, upwards slope line 
    line(200,0,0,200); 
    //rightmost, upwards slope line
    line(200,0,400,200); 
    //leftmost, downwards slope line
    line(0,200,200,400);
    //rightmost, upwards slope line  
    line(400,200,200,400); 

	// Middle Square Outline 
	// left vertical
    line(100,100,100,300); 
    // right vertical 
    line(300,100,300,300); 
    // top horizontal 
    line(100,100,300,100); 
    // bottom horizontal 
    line(100,300,300,300); 

    // Setting variables for spacing between lines 
	db2 = (250-50)/numLines;
	dd2 = (250-50)/numLines; 
	df2 = (50-250)/numLines; 

}

function draw() {

	background(255); 

	// Setting initial values & variables for lines of outer square
	var b2 = 0; 
	var d2 = 0; 
	var f2 = 400; 
	var h2 = 400; 

	// Setting inital values & variables for lines of inner square 
	var i2 = 100; 
	var j2 = 100;
	var k2 = 100;
	var l2 = 100;
	var m2 = 100;
	var n2 = 100;
	var o2 = 100; 
	var p2 = 100; 

	for (var i = 0; i <= numLines; i += 1){
	// Lines connecting canvas to outer square 
	stroke(168,179,236); 
	strokeWeight(1); 

		line(x/2,y,x,f2); 
		f2 += df2; 
		line(x/2,y,0,h2); 
		h2 += df2; 
		line(x/2,0,0,b2); 
		b2 += db2; 
		line(x/2,0,x,d2); 
		d2 += db2; 

	// Lines connecting outer square to inner square  
	stroke(168,179,236); 
	strokeWeight(1); 

		line(0,y/2,100,i2);
		i2 += db2; 
		line(x,y/2,300,j2); 
		j2 += db2; 
		line(x/2,0,k2,100); 
		k2 += db2; 
		line(x/2,y,l2,300); 
		l2 += db2;

	// Lines inside smallest innermost square 
	stroke(120,129,178); 
	strokeWeight(1); 

		line(x/2,y/2,100,m2); 
		m2 += db2; 
		line(x/2,y/2,300,n2); 
		n2 += db2;  
		line(x/2,y/2,o2,100);
		o2 += db2; 
		line(x/2,y/2,p2,300); 
		p2 += db2; 

	// Colored circles 
	noStroke(); 
	fill(253,87,120); 
	ellipse(200,50,25); 
	fill(255,178,100)
	ellipse(350,200,25); 
	fill(169,255,166); 
	ellipse(200,350,25); 
	fill(81,104,255); 
	ellipse(50,200,25); 

	// Dynamic element that follows the mouse 
	//bottom "triangle"
   for(var a = 0; a < 400; a += 15) {
    	var d = 0; 
    	d += a; 
        stroke(255);
        strokeWeight(0.5);
        line(mouseX, mouseY, d, 400);
	}

    //top "triangle"
    for(var a = 0; a < 400; a += 15) {
    	var dd = 0;
    	dd += a;
        stroke(255);
        strokeWeight(0.5);
        line(mouseX,mouseY,dd,0);
	}

	//right "triangle"
    for(var a = 0; a < 400; a += 15) {
        stroke(255);
        strokeWeight(0.5);
        line(mouseX,mouseY,396,a);
	}

	//left "triangle"
	for(var a = 0; a < 400; a += 15) {
     	var dd2 = 0; 
    	dd2 += a;
        stroke(255);
        strokeWeight(0.5);
        line(mouseX,mouseY,0,a);
    }
    }
}


I was inspired by an aerial view of the fortune-teller origami game that I used to make when I was younger. I also added a moving element to give off a hypnotizing/dynamic appearance.

Project 4 – String Art

sketch
var dx1;
var dy1;
var dx2;
var dy2;
var numLines = 100;
var angle = 0;

function setup() {
    createCanvas(400, 400);
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);
}

function draw() {
    background(0);
    stroke(255);
    strokeWeight(0.25);

    dx1 = (0)/numLines;
    dy1 = (400)/numLines;
    dx2 = (400)/numLines;
    dy2 = (0)/numLines;
    var x1 = 0;
    var y1 = 10;
    var x2 = 0;
    var y2 = 400;

    for (var i = 0; i <= numLines; i += 1) {

        //bottom left
        line(x1, y1, x2, y2);
        //top right
        line(x1 + 400, y1, x2, y2 - 400);
        //bottom left 2
        line(x1 + 400, y1 + 400, x2 - 400, y2 - 400);
        //top right 2
        line(x1, y1 - 400, x2 + 400, y2);
        //mouse movement  
        line(x2, y1, x1, mouseY);
        line(x2, y1, x1 + 400, mouseY);

        //opacity change
        if(mouseX > 0) {
            stroke(max(mouseX, 0));
        }
        x1 += dx1;
        y1 += dy1;
        x2 += dx2;
        y2 += dy2;

    }

    
}

I was inspired by geometric lines, and parabolic curves.

Project 4-String Art

I wanted to make this look trippy

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

function draw() {
    stroke(255);
    for (var i = 0; i <= 50; i += 1) { //border pattern
        stroke(random(0, 256), random(0, 256), random(0, 256), 150); //rainbow colors
        //line(0, 10*i, 10*i, 300);
        //line(10*i, 0, 400, 10*i);
        line(0, 150+(4*i), 10*i, 300); //bottom left
        line(400, 150+(4*i), 400-(10*i), 300); //bottom right
        line(400-(10*i), 0, 0, 4*i); //top right
        line(10*i, 0, 400, 4*i);
    }
    stroke(0, 0, 255);
    noFill();
    square(150, 100, 100);
    for (var n=0; n<=10; n+=1) {
        var shade=200-12*n;
        stroke(shade, 0, 0);
        line(250-(10*n), 100, 150+(10*n), 200);
    }
    noLoop();
}