/*
*Sadie Johnson
*15-104 Section C
*sajohnso@andrew.cmu.edu
*Project-04-String-Art
*This program draws art with lines
*/
function setup() {
createCanvas(640, 480);
background(225);
}
function draw() {
var nop = 20; //nop = Number of Points
var spaceX = width/nop;
var spaceY = height/nop;
background('#2C9F88');
for (i = 0; i < nop/2; i++) {
//larger,central form
stroke('#2C8791'); //dark blue
strokeWeight(2);
//quadrants III & I
line(i*spaceX, height/2, width/2, height/2+((i+1)*spaceY));
line(width/2, height/2-((i+1)*spaceY), (width)-(i*spaceX), height/2);
//quadrants II & IV
stroke('#91CDD4'); //light blue
line(width/2, height/2+((i+1)*spaceY), (width)-(i*spaceX), height/2);
line(i*spaceX, height/2, width/2, height/2-((i+1)*spaceY));
}
for (k = 0; k < 7; k++) {
//smaller forms
stroke('#91460C');
//quadrant IV
line(width-(7*spaceX)+(spaceX*k),height,width-spaceX*k,height-(spaceY*k));
line(width,height-(7*spaceY)+(spaceY*k),width-spaceX*k,height-(spaceY*k));
//quadrant III
line(0,height-(7*spaceY)+(spaceY*k),spaceX*k,height-spaceY*k);
line(spaceX*7-(spaceX*k),height,spaceX*k,height-spaceY*k);
//quadrant II
line(spaceX*7-(spaceX*k),0,spaceX*k,spaceY*k);
line(0,(7*spaceY)-(spaceY*k),spaceX*k,spaceY*k);
//quadrant I
line(width-(7*spaceX)+(spaceX*k),0,width-(spaceX*k),spaceY*k);
line(width,(spaceY*7)-(spaceY*k),width-(spaceX*k),spaceY*k);
}
}
My goal in this assignment was to recreate a fourth grader’s string art from the blog post linked to in the assignment (it’s shown below). I spent roughly half my time on this assignment trying to figure out how to create “curves”. Once I did, however, I was able to finish the assignment very quickly.