/*Jeremy Turner (JOT) Assignment A2-09 #200024742 "Biden vs. Palin" (2008). Move two visual elements across the screen using the random() function as a generator of movement. Give each element a unique (and smooth) nonlinear motion.*/ float i = (PI/2); float j = random(536.0); //had to convert from ints to float numbers to randomize. float pos1 = (33); //I have used these 2 ints to be randomized... //I learned about the use of these int and float declarations... //..from both the previous assignment steps and Pooya's //..after-class lecture. float pos2 = (300); //I figure out that I can use the float positions... //...as the fields where I can insert the random movement... //one moves at float pos3 = random(PI); float pos4 =random(PI); float sc = random(88); void setup() { size(536, 333); strokeWeight(8); //I made the strokeWeight visible but fairly thin in order to... //..occasionally reveal the colours inside. //this strokeWeight also adds a "cartoon-y" flavour... //..to these shapes/// frameRate(11); //at this somewhat speedy framerate, it almost appears... //...like each shape co-locates in a quasi-quantum manner... //as you know from previous assignments, I like optical illusions smooth(); } void drawTriangle () //function made to store the triangle's behavior... { fill(random(255), 66, 44); triangle(pos3, 200, pos3, 330, 360, 400); //position 2 has been assigned to this triangle } void drawCircle () //function made to store the circle's (ellipse's) behavior... { fill(random(255), 7, 66); ellipse(pos1, pos4, pos4, pos1); //positions 2 & 3 has been assigned to this ellipse } void draw() { background(59, 17, 152); drawCircle(); drawTriangle(); i += 33; j -= PI/4; if(i > 536) { i = 500; j = 88; } //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 pos3 = height/random(2) + (sc * sin(ang1)); pos4 = width/random(PI) + (sc * cos(ang1)); //The sine and cosine movements are also responding... //..to randomization. }