Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.00 KB | None | 0 0
  1. int wheelR = 300;
  2. float turn = 1; // wheel turns this 1/turn times per frame
  3. float rotation;
  4.  
  5. void setup() {
  6.   size(600,600);
  7.   frameRate(24); //the rate the camera takes pictures at
  8.   textAlign(CENTER);
  9.   ellipseMode(CENTER);
  10.   strokeWeight(20);
  11. }
  12.  
  13. void draw() {
  14.   fill(255);
  15.   background(0);
  16.   rotation = frameCount / turn; // if rotation is one, we did a full spin
  17.   println(rotation);
  18.   pushMatrix();
  19.   translate(width/2, height/2);
  20.   rotate(rotation * TWO_PI);
  21.   ellipse(0,0, wheelR*2, wheelR*2);
  22.   for (int i = 0; i < 5; i++) {
  23.     // uncomment to draw the fist spoke in a different color
  24.     // if (i == 0) {
  25.     //   stroke(255, 0, 200);
  26.     // } else {
  27.     //   stroke(0);
  28.     // }
  29.     //
  30.     line(0, 0, 0, -wheelR); //draws the first spoke upwards
  31.     rotate(TWO_PI*1/5);
  32.   }
  33.   popMatrix();
  34.   textSize(33);
  35.   text("1/"+ int(turn), 63, 33);
  36.   text(frameCount % 24, width-63, 33);
  37. }
  38.  
  39. void mousePressed() {
  40.   turn++; // increase turn every click so rotation gets slower
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement