SHARE
TWEET

Untitled

thedaver64 Apr 21st, 2019 86 in 17 hours
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; simlib example
  2. (define centre-x 400)
  3. (define centre-y 400)
  4. (define hours-length 250)
  5. (define minutes-length 300)
  6. (define seconds-length 350)
  7.  
  8. (define (get-seconds)
  9.     (vector-ref (get-time) 0))
  10.  
  11. (define (get-minutes)
  12.     (vector-ref (get-time) 1))
  13.  
  14. (define (get-hour)
  15.     (vector-ref (get-time) 2))
  16.  
  17. (define (get-seconds-angle)
  18.     (* (/ (get-seconds) 60) 360))
  19.  
  20. (define (get-minutes-angle)
  21.     (* (/ (get-minutes) 60) 360))
  22.  
  23. (define (get-hours-angle)
  24.     (* (/ (modulo (get-hour) 12) 12) 360))
  25.  
  26. (define (seconds-theta)
  27.     (* (get-seconds-angle) 0.01745329252))
  28.  
  29. (define (minutes-theta)
  30.     (* (get-minutes-angle) 0.01745329252))
  31.  
  32. (define (hours-theta)
  33.     (* (get-hours-angle) 0.01745329252))
  34.  
  35. (define (seconds-x)
  36.     (round (+ centre-x (* seconds-length (sin (seconds-theta))))))
  37.  
  38. (define (seconds-y)
  39.     (round (+ centre-y (* -1 seconds-length (cos (seconds-theta))))))
  40.  
  41. (define (minutes-x)
  42.     (round (+ centre-x (* minutes-length (sin (minutes-theta))))))
  43.  
  44. (define (minutes-y)
  45.     (round (+ centre-y (* -1 minutes-length (cos (minutes-theta))))))
  46.  
  47. (define (hours-x)
  48.     (round (+ centre-x (* hours-length (sin (hours-theta))))))
  49.  
  50. (define (hours-y)
  51.     (round (+ centre-y (* -1 hours-length (cos (hours-theta))))))
  52.  
  53.  
  54. (define (draw-second-hand)
  55.     (pencolour 1 1 0)
  56.     (line centre-x centre-y (seconds-x) (seconds-y) )
  57.     (show))
  58.  
  59. (define (draw-minute-hand)
  60.     (pencolour 1 0 0)
  61.     (line centre-x centre-y (minutes-x) (minutes-y)))
  62.  
  63. (define (draw-hour-hand)
  64.     (pencolour 0 1 0)
  65.     (line centre-x centre-y (hours-x) (hours-y)))
  66.  
  67.  
  68. (define (draw-clock)
  69.     (clear-to-colour 0.1 0.1 0.2)
  70.     (draw-second-hand)
  71.     (draw-minute-hand)
  72.     (draw-hour-hand)
  73.     (show))
  74.  
  75. (set-timer-callback "(draw-clock)" 100)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top