Curran Zhang – Project 04 – String Art

sketch

/*Curran Zhang 
  curranz
  Project 4
  Section A
*/

function setup(){
  createCanvas(600,600);
  background(75);
  var rectH ;
  var rectW ;
  var smallH ;
  var x1 ;
  var y1 ;
  var x2 ;
  var y2 ;
  var x3 ;
  var y3 ;
  var x4 ;
  var y4 ;
  var l1 ;  
} 
var radius = 50;
var sx = 500;
var sy = 100;
var angle = 0;

function draw(){
  background(0);
   rectH = height - mouseY;
   rectW = rectH;
   smallH = rectH/4;
   x1 = width/2 - rectW/4;
   y1 = mouseY - 20;
   x2 = width/2 - rectW/4;
   y2 = mouseY -20;
   x3 = width/2 + rectW/4;
   y3 = mouseY - 20;
   x4 = width/2 + rectW/4;
   y4 = mouseY - 20;
   l1 = width/2 - rectW/2-4; 


//Bridge (RED) Lines
  for (var i = 0; i <= 600; i += 30) {
    stroke(40);
    line(0,i,width/2 - rectH  /2,mouseY );
    line(600,i,width/2 + rectH /2,mouseY );
  }

  for (var i = 0; i <= 600; i += 40) {
    stroke('red');
    line(0,i,width/2 - 10,mouseY );
    line(600,i,width/2 + 10,mouseY );
  }

  for (var i = 0; i <= 240; i += 40) {
    stroke('red');
    line(i,600,width/2 - 10,mouseY );
    line(i,0,width/2 - 10,mouseY );
  }

  for (var i = 360; i <= 600; i += 40) {
    stroke('red');
    line(i,600,width/2 + 10,mouseY );
    line(i,0,width/2 + 10,mouseY );
  }

//Bridge Structure
  for (var i = 0; i <= 100; i++) {
    stroke(230);
    x1 -= 4;
    if (x1 < width/2- rectW/2) {x1 = width/2- rectW/2};
    y1 += 30;
    line(x1,mouseY,width/2 - rectW/2,y1);
  }

  for (var i = 0; i <= 50; i++) {
    stroke(230);
    x2 += 4;
    if (x2 > width/2 ) {x2 = width/2 };
    y2 += 30;
    line(x2,mouseY,width/2,y2);
  }

  for (var i = 0; i <= 100; i++) {
    stroke(230);
    x3 -= 4;
    if (x3 < width/2) {x3 = width/2};
    y3 += 30;
    line(x3,mouseY,width/2 ,y3);
  }

  for (var i = 0; i <= 50; i++) {
    stroke(230);
    x4 += 4;
    if (x4 > width/2 + rectW/2) {x4 = width/2 + rectW/2};
    y4 += 30;
    line(x4,mouseY,width/2+rectW/2,y4);
  }

  for (var i = 50; i <= 200; i++) {
    stroke(230);
    l1+=4;
    if (l1 > width/2 + rectW/2) {l1 = width/2 + rectW/2};
    line(l1,mouseY-smallH,l1, mouseY);
  }

//Sun 
    for (var i = 0 ; i <360; i+=8) {
    push();
    translate(500, 100);
    rotate(radians(angle));
    stroke(255,200,21);
    line(0,0,50,0);
    line(0,0,radius * cos(radians(i)),radius* sin(radians(i)));
    pop();
    angle = angle + .01;
  }
}






At the beginning of the project, when I first thought of string art, I thought about the Brooklyn Bridge. The Brooklyn Bridge is supported through cables and create a wild variety of designs at different locations. Thus, I began making creating the drawing similarly to how to bridge itself is created.

Jisoo Geum – Project 04 – String Art

sketch

// Jisoo Geum
// Section B
// jgeum@andrew.cmu.edu 
// Project-04

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

function draw(){
	var x1 = 0;
	var y1 = 0;
	var x2 = 0;
	var y2 = 0;
	var circS = 10;
	//var ix = 1.2;
	var iy = 1.1;
//rectangle 
	fill(255,150,143);
	noStroke();
	rect(190,0,215,190);

//ellipses 
     for (circX = 0; circX <= width; circX += 15 ){
     	for (circY = 0; circY <= height; circY +=10){
     		if (circY>180){break;} // makes the loop stop at a certain point 
     		if (circX>180){break;}
     	circY = circY * iy;
     	//draw circles 
     	stroke(255,126,143);
     	strokeWeight(.5);
     	// circles at top left
     	noFill();
     	ellipse(circX ,circY , circS ,circS );
     	// circles at the bottom right 
     	push();
     	translate(200,200);
     	ellipse(circX ,circY , circS ,circS );
     	pop();		
 		}	
 	}
    //point loops from top left  
    for (var i = 0; i < 80; i++){ // assign increment value as i 
        x1 += i+10;
        y1 += i;
        x2 += 20;
        y2 += 10; 
        // grey lines 
        stroke(90);
        line(100, 0, width, y1); 
        if (x1 > 500){break;}
        line(width, height, 90+x1, 0); 
        // light blue lines
        stroke(109,145,255);
        line(0, y1, x1, height); 
        // dark blue lines lines
        stroke(40,90,255);
        line(100, y1, x1+100, height);      
    }

}

 

This project was very experimental for me since the process was different from the previous ones. I usually draw my ideas in my sketchbook or illustrator, and then translate it into javascript. For the string art, however, I began straight from javascript and then decided on the other elements such as shapes and color. I think using the line loop was very difficult to me because I often got confused with the x and y coordinates.

John Legelis Project-04 String Art

sketch

// John Legelis

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

function draw() {

    // Set size of square 
    var size
    size = 100

    // Itterate rows and columns of squares
    for(s = 0; s < (width/size); s++) {
        for(d = 0; d < (height/size); d++) {
            // Width and height of the square are the same making it an actual square
            square(s*size, d*size, size, size)
        }
    }    
}


// Stop changing colors when mouse is held down
function mousePressed() {
    noLoop()
}

// Resume changing colors when mouse is released
function mouseReleased() {
    loop()
}

// Function that draws line square given top left x,y and width,height
function square(lx, ty, w, h) {
    
    // Insert parameters into variables
    var width
    width = w
    var height
    height = h

    var leftX
    leftX = lx
    var rightX
    rightX = leftX + width
    var topY
    topY = ty
    var bottomY
    bottomY = topY + height

    // Loop through to make lines
    for (i = 0; i <= width; i = i + 5) {

        //Line-1 X,Y coordinates for beginning and end
        var l1xb
        l1xb = leftX
        var l1yb
        l1yb = topY + i  
        var l1xe
        l1xe = leftX + i
        var l1ye
        l1ye = bottomY

        //Line-2 X,Y coordinates for beginning and end
        var l2xb
        l2xb = leftX + i
        var l2yb
        l2yb = bottomY  
        var l2xe
        l2xe = rightX
        var l2ye
        l2ye = bottomY - i

        //Line-3 X,Y coordinates for beginning and end
        var l3xb
        l3xb = rightX
        var l3yb
        l3yb = bottomY - i  
        var l3xe
        l3xe = rightX - i
        var l3ye
        l3ye = topY

        //Line-4 X,Y coordinates for beginning and end
        var l4xb
        l4xb = leftX
        var l4yb
        l4yb = topY + i  
        var l4xe
        l4xe = rightX - i
        var l4ye
        l4ye = topY

        //draw lines with random greyscale color from black to white 
        stroke(random(0,255))
        
        line(l1xb, l1yb, l1xe, l1ye)
        line(l2xb, l2yb, l2xe, l2ye)
        line(l3xb, l3yb, l3xe, l3ye)
        line(l4xb, l4yb, l4xe, l4ye)
    }

}

[Note: original submission was either sketch-347.js or sketch-342.js. I swapped in sketch-364.js with minor edits to work around a pt-embed limitation. -RBD]

I found this project rather intuitive and easy to implement using a for loop which iterated x and y values incrementally for the endpoints of the lines. I liked the textured effect the randomized line shading created. The lines stop changing colors when the mouse is pressed amd resume when released.

Julie Choi – Project 04 – String Art

julie_choi_string_art

/*Julie Choi
15-104 Section E
jjchoi@andrew.cmu.edu
Project-04
*/

function setup() {
	// setup canvas
    createCanvas(400, 300);
}

function draw() {
    background(255);
    // declare varables along the edges 
    var x1 = width/4;
    var x2 = width/2;
    var y1 = height/2;
    var y2 = height/3;
    
    // start a for loop for lines
    for (var i = 0; i < 35; i++) {
        strokeWeight(1.5);
        stroke(255, 0, 0);
        line(width - x1, 0, 0, height - y1);
        stroke(0, 0, 255);
        line(width, height - y1, width - x2, height);
        stroke(0, 255, 54);
        line(x1, 0, width, height - y2);
        stroke(255, 0, 234);
        line(0, height - x1, y2, height);
        stroke(90, 0, 255);
        line(x1, 0, 0, y2);
        stroke(174, 255, 0);
        line(0, height - y2, width - y2, width - x1);
        stroke(255, 0, 0);
        line(height - x1, 0, width, y1);
        x1 += 6;
        y1 -= 6;
        y2 -= 6;
        x2 += 6;
    }
    
    // draw eye shape
    stroke(255);
    strokeWeight(1);
    translate(-10, 10);
    beginShape();
    vertex(130, 150);
    bezierVertex(130, 150, 200, 70, 270, 150);
    vertex(130, 150);
    bezierVertex(130, 150, 200, 230, 270, 150);
    endShape(); 
    stroke(0);
    strokeWeight(1.5);
    line(130, 150, 270, 150);

    // draw pupil
    fill(0);
    stroke(255);
    ellipse(width / 2, height / 2, 50, 50);
    ellipse(width / 2, height / 2, 30, 30);
}

I enjoyed creating consecutive lines in different positions through this project. I ended up creating an Illuminati sign as I explored different compositions. I am satisfied with my final result and learned a lot from this exercise.

Romi Jin – Project-04-String-Art-Section B

sketch

 /*
Romi Jin
Section B
rsjin@andrew.cmu.edu
Project-04
*/

// spacing variables
var space1 = 5; 
var space2 = .01;

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

function draw() {

// middle mouse strokes
    stroke(180);
    strokeWeight(0.1);
    line(mouseX, height, 0, mouseY);


// bottom left
    for (var y = 0; y < width; y += space1) {
        stroke(245,195,194);
        strokeWeight(0.1);
        line(y, height, 0, y);
    }

// top right
    for (var z = 0; z < width; z += space1) {
        stroke(253,185,200);
        strokeWeight(0.1);
        line(z, 0, width, z);
    }

// top left
    for (var a = 0; a < 10; a +=space2) {
        stroke(254,127,156);
        strokeWeight(0.1);
        push();
        var x = lerp(width, 0, a);
        var y = 0;
        var x2 = 0;
        var y2 = lerp(0, height, a);
        line(x, y, x2, y2);
        pop();
    }

// bottom right
    for (var b = 0; b < 10; b += space2) {
        stroke(253,171,159);
        strokeWeight(0.1);
        push();
        var x = width;
        var y = lerp(0, height, b);
        var x2 = lerp(width, 0, b);
        var y2 = height;
        line(x, y, x2, y2);
        pop();
    }



}

I wanted to make a several pink curves at each corner and interactive strokes in the middle (if you move your mouse over the image, it will draw gray lines in the center of the four curves).

Elena Deng-Project 04-String Art

sketch

/*Elena Deng
Section E
  edeng1@andrew.cmu.edu
  Project-04
}
*/
function setup() {
    createCanvas(400, 300);
    background(70);
}

function draw() {
  var x = 0;
  var y = 0;
  var x1 = width/6;
  var x2 = width/2;
  var y1 = height/6;
  var y2 = height/2;


  for (var i=0;i<54;i++){
      strokeWeight(3);
      stroke(90,120,180);
      line(width-x2, height, x2, height - y2);
      line(x2, height-y2, width+x2, height);

      x2+=12;
      y2+=12;
  }

  for (var i = 0; i < 60; i++) {
        strokeWeight(1);
        stroke(255,255,255,10);
        line(width-x1, height, 0, height - y1);
        line(x1, height, width, height - y1);
        line(width-x1, 0, 0, 0+y1);
        line(x1, 0, width, 0+y1);

        x1 += 10;
        y1 += 10;
     }

}

This project was interesting to do! Excited to discover new ways to implement the new skills I learned through this exercise. I hope to be able to create actual shapes in the future.

Jason Zhu-Project-04-String-Art

sketch

/* Jason ZHu
Section E
http://jlzhu.cmu.edu
Project-04-String-Art
*/

function setup() {
    createCanvas(400, 300);
    background(240,30,30);

    //twisted white lines
    for (var a = 0; a <300; a += 10){
        stroke(255);
        var x1 = 0 - a * 10
        var y1 = height - a * 10
        var x2 = a + 300
        var y2 = a + height/2
        line(x1,y1,x2,y2);
    }

    //blue curved lines
    for (var b = 50; b < width; b += 10) {
        strokeWeight(5);
        stroke(65,101,172);
        line(b, 0, 150, b);
    }

    // light orange rectangle
    for (var c = 250; c < 400; c += 5){
        strokeWeight(2);
        stroke(150,150,30);
        line(c,75,c,height);
    }

    //orange rays
    for (var d = 0; d < width; d += 15) {
        strokeWeight(1);
        stroke(241,157,56);
        line(250,75, d, 0);
    }

    // yellow lower left warp
    for (var e = width; e > 0; e -= 15) {
        strokeWeight(1);
        stroke(241,240,56);
        line(e,300, 0, e);
    }

     // yellow lower left warp
    for (var f = width; f > 0; f -= 15) {
        strokeWeight(1);
        stroke(241,240,56);
        line(400,f, f, 0);
    }
}

For this assignment, I wanted to push my boundaries by exploring variations in color and form. As someone who tends to be more conservative and narrowed in my thinking (aesthetically speaking), I wanted to see what I could come up with if those preconditions were tossed aside. I contrasted blues with reds and mixed in some yellows as well. I also wanted the white lines to serve to divide the campus and create a dynamic centerpiece that underlaid the red and yellow portions. In this way, I think I pushed myself further in terms of coding and aesthetics. By going against my norms, I was able to reinforce what I thought looks good while also exploring new means.

Project-04-String-Art-Veronica

sketch

/*
Veronica Wang
Section B
yiruiw@andrew.cmu.edu
Project-04
*/

var r = 125; //radius of circle
var inc = 100; //increments on the circle
var stepDif = inc;//each step increases one increment
var stepNum = 0;//step number count


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

function draw() {

    var centerX = width / 2; //center x of circle
    var centerY = height / 2; //center y of circle
    var step = 2 * PI / inc; //increment size

    //main ellipse to be divided
    stroke(120);
    strokeWeight(0.5);
    noFill();
    ellipse(centerX, centerY, r * 2, r * 2);
    

    for (i = 0; i < inc / 2; i += 1){
        var currNum = stepNum; //current iteration number
        //x and y coordinates of starting points equally divided increments along ellipse
        var x1 = centerX + r * cos(step * currNum); 
        var y1 = centerY - r * sin(step * currNum);
        //for every increment in starting point,
        //step two increaments for destination point 
        var nextNum = (inc / 2 + 2 * (currNum)) % inc; 
        //x and y coordinates of the destination points on the ellipse
        var x2 = centerX + r * cos(step * nextNum);
        var y2 = centerY - r * sin(step * nextNum);
        //step number increase
        stepNum += 1;
        stroke(220, 20, 60);
        line(x1, y1, x2, y2);
    }

    var offset = 0; //offset to create layers
    var repeats = 7; //how many layers
    var op = 100; //opacity of layer color to create depth

    for (i = 0; i < repeats; i += 1) {
        op -= i * 4; //opacity decrease
        stepNum = 0; //step number
        offset += 8; //offset by 8 increments each time
        
        //same as the for loop above
        for (j = 0; j < inc / 2; j += 1){ 
            var currNum = stepNum + offset;
            var x1 = centerX + r * cos(step * currNum);
            var y1 = centerY - r * sin(step * currNum);
            var nextNum = ((inc / 2 + 2 * (currNum - offset)) + offset) % inc;
            var x2 = centerX + r * cos(step * nextNum);
            var y2 = centerY - r * sin(step * nextNum);
            stepNum += 1;
            stroke(220, 20, 60, op);
            line(x1, y1, x2, y2);
        }
    }

    noLoop();

}

In this project I looked up string art and found inspiration from Demir String art. I decided to make a project similar to this art piece they made:

It took me some time to figure out how to extract points from a circle, as well as stepping in different increments for the two ends of a line. But I am happy with the output and had fun doing this project.

Eunice Choe – Project-04 – String Art

sketch

/*Eunice Choe
Section E
ejchoe@andrew.cmu.edu
Project-04*/

// global variables to create curves
var spacing = 4;// spacing between the strings
var x1 = 0;
var y1 = 300;
var x2 = 400;
var y2 = 0;


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

function draw() {
    // changing color of strings depending on mouseX and mouse Y position
    background(255);
    strokeWeight(0.2);
    var r = map(mouseX, 0, width, 100, 255);
    var g = map(mouseY, 0, width, 200, 255);
    var b = map(mouseX, 0, height, 0, 100);
    for (var i = 0; i < width; i++){
    // outermost section of strings
        stroke(r, g, b);
        line (x1, spacing * i, spacing * i, y1); // bottom left
        line (x2, spacing * i, spacing * i, y2); // top right
        line (spacing * i, y1, x2, height - spacing * i); // bottom right
        line(x1, height - spacing * i, spacing * i, y2); // top left
    // innermost section of strings
        stroke(g, r, b);
        line (x1 + 100, spacing * i, spacing * i, y1 - 100); // inner bottom left
        line (x2 - 100, spacing * i, spacing * i, y2 + 100); // inner top right
        line (spacing * i, y1 - 100, x2 - 100, height - spacing * i); // inner bottom right
        line(x1 + 100, height - spacing * i, spacing * i, y2 + 100); // inner top left
    // middle section of strings
        stroke(r, b, g);
        line (x1 + 50, spacing * i, spacing * i, y1 - 50); // middle bottom left
        line (x2 - 50, spacing * i, spacing * i, y2 + 50); // middle top right
        line (spacing * i, y1 - 50, x2 - 50, height - spacing * i); // middle bottom right
        line(x1 + 50, height - spacing * i, spacing * i, y2 + 50); // middle top left
        }
}

For my string art project, I wanted to create a series of repeating curves overlapped on top of each other. I liked the appearance of having several thin strings that create sheer and transparent colors. I did have some difficulties figuring out how to use the for loop and coordinates, but later I realized the loop makes life much easier!

Lingfan Jiang – Project 04 – String Art

lingfanj-04

//Lingfan Jiang
//Section B
//lingfanj@andrew.cmu.edu
//Project-04


var dx; //x coordinate for points on curve
var dy; //y coordinate for points on curve
var circleDiameter; //diameter of the center circle


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

}

function draw(){
    background(0);
    angleMode(DEGREES);
    strokeWeight(0.1); //set a lineweight for the bottom curves
    circleDiameter = 75;


    stroke(255,104,107); //red lines
    for (var x = 0; x < 95; x += 5) {
        dx = 200 + (circleDiameter * cos(x));
        dy = 150 + (circleDiameter * sin(x));
        //connect first quarter of the points on the circle with the points on the top
            for (var i = 0; i < 400; i += 5){
            line(i,0,dx,dy);  
        }
    }
    strokeWeight(0.08);
    stroke(27,179,244); //light blue lines
    for (var x = 90; x < 275; x += 5) {
        dx = 200 + (circleDiameter * cos(x));
        dy = 150 + (circleDiameter * sin(x));
        //connect half quarter of the points on the circle with the points on the left
            for (var i = 0; i < 300; i += 5){
            line(0,i,dx,dy);  
        }
    }
    strokeWeight(0.05);
    stroke(0,40,255); // dark blue lines
    for (var x = 180; x < 275; x += 5) {
        dx = 200 + (circleDiameter * cos(x));
        dy = 150 + (circleDiameter * sin(x));
        //connect quarter of the points on the circle with the points on the bottom
            for (var i = 0; i < 400; i += 5){
            line(i,300,dx,dy);  
        }
    }
    stroke(143,113,255);
    strokeWeight(0.04); // purple lines
    for (var x = 270; x < 455; x += 5) {
        dx = 200 + (circleDiameter * cos(x));
        dy = 150 + (circleDiameter * sin(x));
        //connect half quarter of the points on the circle with the points on the right
            for (var i = 0; i < 300; i += 5){
            line(400,i,dx,dy);  
        }
    }

    noLoop();
}

In this project, I had some difficulties to picture the final form at first. However, after looking through some of the string art examples, I became particularly interested in the circle from. Different from architectural modeling software, you cannot evaluate curves and find points on them. Therefore, the coordinates of the points that form a circle gave me a little bit of trouble. After understanding how “cos” and “sin” could help form it, here is the final result.