//Shannon Case
//Section D
//scase@andrew.cmu.edu
//Project 04
function setup() {
createCanvas(640,480);
background(200);
}
function draw() {
var x0 = 130; //initial x position
var y0 = height/2 - 60; //initial y position
var x1 = 130; //end initial x position
var y1 = height/2 + 60; //end initial y position
var incX = 22.5; //how much x moves by
var incY = 20; //how much y moves by
var nextBox = 180; //moves to next box
background('pink');
strokeWeight(3);
stroke('green');
for (i = 0; i<3; i++){
line(x0,y0,x1,y1);
x0 += nextBox; //moves to second gift box
x1 += nextBox;
}
//horizontal line
x0 = 130 + incX;
y0 = height/2 - 2*incY;
x1 = 130 - incX;
y1 = height/2 + 2*incY;
stroke('red');
for (i = 0; i<3; i++){
line(x0,y0,x1,y1);
x0 += nextBox; //moves to second gift box
x1 += nextBox;
}
//first red line
x0 = 130 + 2*incX; //moves to right by increment*2
y0 = height/2 - incY;
x1 = 130 - 2*incX;
y1 = height/2 + incY;
stroke('red');
for (i = 0; i<3; i++){
line(x0,y0,x1,y1);
x0 += nextBox;
x1 += nextBox;
}
//vertical green line
x0 = 130 + 3*incX;
y0 = height/2;
x1 = 130 - 3*incX;
y1 = height/2;
stroke('green');
for (i = 0; i<3; i++){
line(x0,y0,x1,y1);
x0 += nextBox;
x1 += nextBox;
}
//box
stroke('white')
noFill();
x0 = 0;
for (i = 0; i < 3; i++){
rect(60+x0, height/2 - 60, 140, 120);
x0 += nextBox;
}
noLoop();
println();
}
For this assignment I chose to use for loops to do a string drawing of some presents. I wanted to experiment with making string drawings that were representative of real things. I’m also super excited for the holidays to come and wanted to make a piece about it 🙂