void setup(){ size(500,500); } void draw() { //do some drawing background(0); int x1, x2, y1, y2; int boxWidth=250; int boxHeight=250; int boxX=100; int boxY=100; x1 = int(random(6)-3); x2 = int(random(6)-3); y1 = int(random(6)-3); y2 = int(random(6)-3); boxX += x1; boxY += y1; boxWidth += x2; boxHeight += y2; fill(255,0,0); rect(boxX,boxY,boxWidth,boxHeight); } // line(x1,y1,x2,y2); //first two coordinates are the top left corner (the origin)