void setup(){ size(800,500); } void draw() { //do some drawing background(0); // Box widths and positions. int x1, x2, y1, y2; x1 = int(random(width)); x2 = int(random(width/2)); y1 = int(random(height)); y2 = int(random(height/2)); stroke(255,255,0); strokeWeight(5); fill(255,0,0); rect(x1,y1,x2,y2); } // line(x1,y1,x2,y2); //first two coordinates are the top left corner (the origin)