Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. // The setup function runs ONCE at the BEGINNING of the program
  2. function setup() {
  3. createCanvas(500, 500);
  4. }
  5.  
  6. // The draw function runs OVER AND OVER right AFTER setup is finished
  7. function draw() {
  8. draw_clock();
  9. }
  10.  
  11. const spacing = 50;
  12. // I added a call to the draw function.
  13. // This function also doesn't need a parameter "obj"
  14. // function draw_clock(obj) { --> function draw_clock() {
  15. function draw_clock(obj) {
  16. background(0);
  17.  
  18. let h = hour();
  19. let m = minute();
  20. let s = second();
  21. let secAngle = map(s, 0, 60, 0, PI * 2);
  22. let minAngle = map(m, 0, 60, 0, PI * 2);
  23. let hourAngle = map(h % 12, 0, 12, 0, PI * 2);
  24.  
  25. // Variables width and height are the width and height of the drawing canvas
  26. translate(width / 2, height/2);
  27. rotate(PI * 1.5);
  28. strokeWeight(8);
  29. noFill();
  30. stroke(255, 0, 0);
  31. arc(0, 0, 300, 300, 0, secAngle);
  32. stroke(0, 255, 0);
  33. arc(0, 0, 280, 280, 0, minAngle);
  34. stroke(0, 0, 255);
  35. arc(0, 0, 260, 260, 0, hourAngle);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement