//Brandon Jarvis //Assignment #2 //9-8-09 //This is an animation of a transitional grayscale background with an //opposite transitional grayscale triangle. Multi-colored circles are //generated at random on the display as well. int x = 150; // Assigns value 150 to variable x int increment = 1; //Assignes value 1 to variable "increment" void setup() { //setup statement declares what is drawn/calculated only once size (600,600); //Sets display size to 600 by 600 frameRate(50); //Sets framRate to 50 fps strokeWeight(4); //Sets strokeWeight to 4 colorMode(HSB, 360, 100, 100); //Sets colorMode to HSB with Hue of 360, //Saturation of 100, and Brightness of 100 } void draw() { //draws commands at the pace of the frameRate background (x); //Sets background color to value x fill (x); //Sets fill value to x int x1 = (int)(random(height)); //variable x1 is assigned a random integer height int y1 = (int)(random(width)); //variable y1 is assigned a random integer width stroke (x1,y1,y1); //Sets stroke color for ellipses ellipse(x1, y1, width*.25, height*.25); //ellipse command draws ellipses based on width and height stroke (255-x); //stroke color is changed to "oppositely=match" the background grayscale value triangle (width*.5,height/5, width/3,height*.75, width*.66,height*.75); //Draws a triangle based on the width and height values entered in size command if ((x >= 255) || (x <= 0)) { //if statement (conditional) changes the value of x to keep the stroke above contrasting with the background increment *= -1; } x+=increment; println(x); //prints the current value of x in the output below }