sketch">
/* Mari Kubota
49-104 Section D
mkubota@andrew.cmu.edu
Assignment 4
*/
function setup(){
createCanvas(400,300);
background (0);
//left white crossed lines
stroke(255);
var yl = height*(5/6);
var ym1 = height*(6/8);
for(var i=0; i < 15; i++){
line(0, yl, width/2, ym1);
yl *=0.97;
ym1 *= 1.02+mouseX;
};
//right white crossed lines
var yr = height*(5/6);
var ym2 = height*(6/8);
for(var i=0; i < 15; i++){
line(width, yr, width/2, ym2);
yr *=0.97;
ym2 *= 1.02;
};
//diamond
stroke(255);
//bottom vertical lines
var w1= width/4;
for (var x=w1; x<width*(3/4); x+=14){
line (x,height/2,width/2,height*(5/6));
}
//upper left lines
var w2= width/3;
var w4= width/2;
for (var y=height/3; y<height/2; y+=7){
line (width/4,height/2, w2, y);
w2+=5;
line (width/2-30,height/2, w2-5, height/3);
line (width/2-30, height/2, w4, height/3);
w4-=4;
}
//upper right lines
var w3= width*(2/3);
var w5= width/2;
for (var y=height/3; y<height/2; y+=7){
line (width*(3/4),height/2, w3, y);
w3-=5;
line (width/2+30, height/2, w3+5, height/3);
line (width/2+30, height/2, w5, height/3);
w5+=4;
}
//upper center criss cross lines
var w6= width/2;
for (var y=height/3; y<height/2; y+=7){
line (width/2-30, height/2, w6, y);
w6+=4;
}
var w7= width/2;
for (var y=height/3; y<height/2; y+=7){
line (width/2+30, height/2, w7, y);
w7-=4;
}
//top of diamond
line (width/3, height/3, width*(2/3),height/3);
}
In this project I created a diamond out of string out. The numerous lines were made from for loops and line shapes. The challenging part of this project was making the lines in the diamond match up into a cohesive shape.