Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int wheelR = 300;
- float turn = 1; // wheel turns this 1/turn times per frame
- float rotation;
- void setup() {
- size(600,600);
- frameRate(24); //the rate the camera takes pictures at
- textAlign(CENTER);
- ellipseMode(CENTER);
- strokeWeight(20);
- }
- void draw() {
- fill(255);
- background(0);
- rotation = frameCount / turn; // if rotation is one, we did a full spin
- println(rotation);
- pushMatrix();
- translate(width/2, height/2);
- rotate(rotation * TWO_PI);
- ellipse(0,0, wheelR*2, wheelR*2);
- for (int i = 0; i < 5; i++) {
- // uncomment to draw the fist spoke in a different color
- // if (i == 0) {
- // stroke(255, 0, 200);
- // } else {
- // stroke(0);
- // }
- //
- line(0, 0, 0, -wheelR); //draws the first spoke upwards
- rotate(TWO_PI*1/5);
- }
- popMatrix();
- textSize(33);
- text("1/"+ int(turn), 63, 33);
- text(frameCount % 24, width-63, 33);
- }
- void mousePressed() {
- turn++; // increase turn every click so rotation gets slower
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement