/* drawSquare_v2.pde Created by Justin Hsia Draw "square art" using lines, variables, functions, randomization */ void setup() { size(500,500); // set drawing canvas size strokeWeight(5); // make lines thicker } void draw() { drawSquare(int(random(1,300)),int(random(1,300)),int(random(100,200)),color(0,random(0,255),0)); //drawSquare(50,50,200,color(255,0,0)); //drawSquare(350,350,100,color(0,0,255)); frameRate(5); // slow down drawing rate } // parameterized version of drawSquare() // draws a square of specified length and color at (x,y) void drawSquare(int x, int y, int len, color c) { stroke(c); line(x, y, x, y+len); // left vertical line line(x, y, x+len,y ); // top horizontal line line(x, y+len,x+len,y+len); // bottom horizontal line line(x+len,y, x+len,y+len); // right vertical line }