/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://friendscentral.sketchpad.cc/sp/pad/view/ro.ocBC7ULK8aB/rev.2
*
* authors:
* Colin Angevine
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
float angle;
float angularAcc;
float angularVel;
float THRESHOLD;
void setup() {
angle = 0;
angularAcc = 0.001;
angularVel = 0;
THRESHOLD = 0.25;
size(400, 400);
}
void draw() {
angularVel = angularVel + angularAcc;
angle = angle + angularVel;
pushMatrix();
translate(width/2, height/2);
rotate(angle);
rect(0, 0, 50, 50);
popMatrix();
if(angularVel > THRESHOLD || angularVel < -THRESHOLD) {
angularAcc = angularAcc * -1;
fill(random(255), random(255), random(255));
}
}