Introduction:
For this recitation, we were tasked with creating animations in processing. This was a skill I particularly struggled with so my animation is not too entertaining to look at.
My Animation:
This animation is simply a ball bouncing around the canvas.
Code:
int rad = 60; float xpos, ypos; float xspeed = 2.8; float yspeed = 2.2; int xdirection = 1; int ydirection = 1; void setup() { size(500, 500); noStroke(); frameRate(60); ellipseMode(RADIUS); xpos = width/2; ypos = height/2; } void draw() { background(0); xpos = xpos + ( xspeed * xdirection ); ypos = ypos + ( yspeed * ydirection ); if (xpos > width-rad || xpos < rad) { xdirection *= -1; } if (ypos > height-rad || ypos < rad) { ydirection *= -1; } ellipse(xpos, ypos, rad, rad); }
Homework:
I struggled with the homework but I was able to make something along the lines of what it was supposed to look like with the help of a fellow.
Code:
int high; int low; float c; void setup() { fullScreen(); colorMode(HSB); strokeWeight(20); high = height/3; low = 50; } void draw() { background(255); if (c >= 255) c=0; else c++; fill(c, 255, 255); high = max(high, mouseY); translate(width/2, height/2); int mid = (high+low)/2; float p = sin( PI*millis() / (1000-high) ); int dia = mid + int( p*(high-mid) ); ellipse(0, 0, dia, dia); }