/*Jeremy Turner (JOT) Assignment A2-08 #200024742 Create a dynamic animation using the cos() and sin() function as a generator for motion.*/ //Call me shameless, but I have resorted to ripping-off... //my own ripped-off code (see JOTA2_07) from //http://processing.org/learning/basics/sinecosine.html ;-) //this is a form of reverse-reverse engineering? //So, I have thrown back in the Sine functions and flipped //..the variables around again. //mouseX and mouseY can also control the sizes of the shapes... float i = 55; float j = 536; float pos1 = 0; float pos2 = 0; float pos3 = 0; float pos4 = 0; float sc = 88; //I have reverted back to "float sc" since I am using sine... //...as well as cosine... void setup() { size(536, 666); strokeWeight(18); //the first version had noStroke..I wanted some strokeWeight. frameRate(5); //the result of this mod started to look more contemplative... //...so I slowed down the frameRate even more to enhance this... smooth(); } void drawTriangles () { triangle(60, pos1, pos3, mouseX, pos2, 222); fill(random(255), mouseY, 88); triangle(mouseX, pos1, 32, pos1, pos3, pos4); triangle(pos1, pos2, pos3, pos4, pos1, pos2); //I found it amusing that I could flatten out a triangle... //into a moving line by replacing all the variables... //..with positions... //I have taken out the fill command for this shape... //since the colour was not showing anyway. } void drawEllipses () { fill(random(255), 7, 66); ellipse(pos3, 164, mouseX, 32); fill(random(255), 17, 202); ellipse(pos4, pos4, mouseY, pos2); //I decided to insert the positions in more than one vertex point... //...I have also assigned mouseX and MouseY to some coordinates. } //...a more circular/radial motion} void mouseDragged () //Pooya mentioned that I should add another function call to make this animation more dynamic //now mouseDragged also responds to mouseX and mouseY in a "circular" way. { i = i +1; if (i> 22) { i = mouseX/PI; } j = j +1; if (j>111) { j = mouseY/PI; } } void draw() { background(198, 76, 4); //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); drawTriangles (); drawEllipses(); 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/PI + (sc * cos(ang1)); pos2 = height/2 + (sc * sin(ang1)); pos3 = width/2 + (sc * cos(ang2)); pos4 = height/PI + (sc * sin(ang2)); //now, I have decided that I would assign sine to height //...and cosine to width //I have added PI in the position fields in order to give it... }