Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The setup function runs ONCE at the BEGINNING of the program
- function setup() {
- createCanvas(500, 500);
- }
- // The draw function runs OVER AND OVER right AFTER setup is finished
- function draw() {
- draw_clock();
- }
- const spacing = 50;
- // I added a call to the draw function.
- // This function also doesn't need a parameter "obj"
- // function draw_clock(obj) { --> function draw_clock() {
- function draw_clock(obj) {
- background(0);
- let h = hour();
- let m = minute();
- let s = second();
- let secAngle = map(s, 0, 60, 0, PI * 2);
- let minAngle = map(m, 0, 60, 0, PI * 2);
- let hourAngle = map(h % 12, 0, 12, 0, PI * 2);
- // Variables width and height are the width and height of the drawing canvas
- translate(width / 2, height/2);
- rotate(PI * 1.5);
- strokeWeight(8);
- noFill();
- stroke(255, 0, 0);
- arc(0, 0, 300, 300, 0, secAngle);
- stroke(0, 255, 0);
- arc(0, 0, 280, 280, 0, minAngle);
- stroke(0, 0, 255);
- arc(0, 0, 260, 260, 0, hourAngle);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement