/*Jeremy Turner (JOT) Assignment A2-07 #200024742 Create a dynamic animation using the cos() function as a generator for motion. */ //I plundered the example source code from //http://processing.org/learning/basics/sinecosine.html //...I analyzed bit by bit by modifying the number and... //taking out the sine functions and replacing them with cos() functions... //..I did a bit of this with my clock project... //this is reverse engineering at its most devious. //However, if you open up the original source code... //..you will notice how much I have changed and made it into.. //...my own style. int i = 5; int j = 111; float pos1 = 0; float pos2 = 0; float pos3 = 0; float pos4 = 0; int c = 536; // "536" was the name of my arts collective in Vancouver in 1999 ;-) //this int seems to affect the speed and frequency of the objects... //...appearing...since I changed my screen size, I knew that... //I had to up the number from 40 in order for more objects to be... //...visible on the screen... //it originally said "sc" instead of "c" so I realized that was for... //"...sine cosine"...and so, I changed all the variables below... //...to just say "c". void setup() { size(666, 266); //already by changing the window size, the original sketches //...balls moved in a different relation to the screen due to the.. //...cosine movement...however, I am not using balls anymore... //I removed noStroke as I wanted to see the object tracing itself //..although the difference is rather subtle, in retrospect frameRate(6); //I slowed the framerate in order to allow the movement... //..to be tracked while still upping the int c declaration.. //..above so that my objects appeared more frequently. smooth(); } void draw() { background(99, 202, 111); //I have made all the filled shapes oscillating at a "random" rate... //...but have blended the colours in a bit so the randomization... //effect did not look totally bland. fill(random(255), 66, 44); triangle(60, pos1, pos3, 88, pos2, 222); fill(random(255), 77, 88); ellipse(200, pos1, 32, pos1); fill(random(255)); ellipse(66, pos2, pos2, pos2); fill(random(255), 7, 66); ellipse(pos3, 164, 32, 32); fill(random(255), 17, 202); ellipse(pos4, pos4, 32, pos2); //I decided to insert the positions in more than one vertex point... //... i += 3; j -= 3; if(i > 536) { i = 66; j = 222; } //I changed the numbers of the if statement above to ensure that ... //I was still within the numerical limits of "i" float ang1 = radians(i); // convert degrees to radians float ang2 = radians(j); // convert degrees to radians pos1 = width/2 + (c * cos(ang1)); pos2 = height/2 + (c * cos(ang1)); pos3 = width/2 + (c * cos(ang2)); pos4 = height/2 + (c * cos(ang2)); //Instead of the sine fucntions in the original example, I decided... //...to modify the height for positions 2 and 4... //they were all modifying width before... //more of the shapes are visible this way }