/** * Animating a square. * *

Elie Zananiri
* CART 253, Winter 2008

*/ /* global variables */ int rectX = 0; int rectY = 50; int rectSize = 50; /* built-in functions */ void setup() { size(300, 300); noStroke(); smooth(); } void draw() { background(0); moveSquare(); drawSquare(); } /* custom functions */ // moves the square one unit to the right void moveSquare() { rectX = rectX + 1; } // draws the square void drawSquare() { fill(255, 128, 0); // orange rect(rectX, rectY, rectSize, rectSize); }