xxxxxxxxxx
/*
Program Title: A2-2
Program Description:Write a procedure for drawing a simple character with at least two different parameters and use your
procedure at least three times with different values of its parameters.
By Jillian Warren, September 28, 2012
Comments: IAT 800 - Assignment 2
**Inspiration from: http://krazydad.com/tutorials/circles_js/
*/
//***Global variables
float goldenRatio = (sqrt(5)+1)/2 - 1; // golden ratio
float goldenAngle = goldenRatio * TWO_PI; // golden angle
float largeRadius;
float ratio;
float sinCosAngle;
float xCenter;
float yCenter;
float spiralRadius;
//***to be executed once
void setup () {
size (1200, 800);
background (255); // white
smooth();
frameRate (5);
ellipseMode (RADIUS);
fill (0);
}//end setup
//*** procedure to draw spiral characters. Arguements: numberofCircles used for # of circles that makes up spiral, circle size dictates
// size of circles that make up spiral, xPos and yPos are used in determination of location of circles and therefore overall spiral
void drawSpirals (int numberOfCircles, int circleSize, int xPos, int yPos) {
//initialize
largeRadius = width * random (.10, .30); // used for radius of the whole spiral
//create circles spiraling outward to create full spiral
for (int i = 1; i <= numberOfCircles; ++i) {
ratio = i/ (float) numberOfCircles;
sinCosAngle = i*goldenAngle;
spiralRadius = ratio * largeRadius;
xCenter = xPos + cos(sinCosAngle) * spiralRadius;
yCenter = yPos + sin(sinCosAngle) * spiralRadius;
ellipse (xCenter, yCenter, circleSize, circleSize);
}//end for
}//end drawSpirals
void draw () {
// changeColor();
noStroke();
fill(0, 40);
drawSpirals (400, 4, width/2, height/2);
// delay (100); //only works in processing on the desktop
}//end draw
void mousePressed () {
background (255);
}