// CS3451 Computer Graphics // P1 - Wheels // Catherine Herrington & Douglas Miller // http://www-static.cc.gatech.edu/grads/c/catyarr/wheels // Created on May 23, 2006 // Wheels // illusion of motion by J. Rossignac int n=20; //Number of tubes in rings boolean bSpiral = false; //Draw rings in spirals vs circles boolean bGrid = false; //Draws original grid configuration vs circular configuration void setup() //Executed at initialization { size(800, 800); //Size of screen in pixels rectMode(CENTER); //Sets the first two params of rect to specify the center }; void draw() //Executed continuously to refresh window { background(255); //Sets white background PFont fontA = loadFont("ScalaSans-Caps-32.vlw"); //Load the font textFont(fontA, 16); //Set the font and its pixel size fill(0); //Change color of the text text("Catherine Herrington", width-200, height-20);//Display team names text("Douglas Miller", width-150, height-40); //Display team names translate(width/2,height/2); //Sets the origin to center of the window int scaleFactor = 90; //Multiplier for x and y coordinates boolean bClockwise = true; //Determines if rings drift clockwise or counterclockwise if (bGrid) { //Display original configuration for (int x = -3; x <= 3; x += 2) { for (int y = -2; y <= 2; y += 2) { rings(x*scaleFactor, y*scaleFactor,bClockwise); bClockwise = ! bClockwise; } } for (int x = -2; x <= 2; x += 2) { for (int y = -1; y <= 1; y += 2) { rings(x*scaleFactor, y*scaleFactor,bClockwise); bClockwise = !bClockwise; } } } else { //Display circular configuration scale(1.3); rings(0, 0, bClockwise); for (int i = 0; i < 6; i++) { rotate(2*PI/6); rings((int)(1.9*scaleFactor), 0, bClockwise); bClockwise = ! bClockwise; //Alternate direction of drift } rotate(-2*PI/12); scale(0.6); for (int i = 0; i < 6; i++) { rotate(2*PI/6); rings((int)(2.0*scaleFactor), 0, bClockwise); bClockwise = ! bClockwise; //Alternate direction of drift } } }; void rings(int x, int y, boolean bClockwise) { //Draws rings pushMatrix(); //Save coordinates system translate(x,y); //Changes where the rings are drawn noStroke(); fill(255, 255, 255); if (bSpiral) //If mouse button is pressed, draw rings in swirl configuration { ellipse(-4, -4, 200, 191); //Clear area behind rings fill(0, 0, 0); //Change color to black ellipse(0, 0, 10, 10); //Draw small black dot in center of rings for (int j=1; j