Last active
March 14, 2018 01:58
-
-
Save ampersanda/733fd8c6f59304a013fc267c19a94741 to your computer and use it in GitHub Desktop.
Medium - Quil-cljs - binding all values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn draw-state [state] | |
(q/background 51) | |
(let | |
[max-scale-h (- 1 (/ 1 12)) ;; get percentage of current hour, range value from 0-1 | |
max-scale-m (- 1 (/ 1 60)) ;; get percentage of current minute, range value from 0-1 | |
max-scale-s (- 1 (/ 1 60)) ;; get percentage of current seconds, range value from 0-1 | |
;; above values are half of the actual values, so we need to multiply it with 2π | |
;; mappings | |
h (q/map-range | |
(if (> (q/hour) 12) (- (q/hour) 12) (q/hour)) ;; if hour more than 12, subtract with 12 | |
0 11 | |
0 max-scale-h) | |
m (q/map-range | |
(q/minute) | |
0 59 | |
0 max-scale-m) | |
s (q/map-range | |
(q/seconds) | |
0 59 | |
0 max-scale-s) | |
;; multiply values above with 2π | |
h-a (* q/TWO-PI h) | |
m-a (* q/TWO-PI m) | |
s-a (* q/TWO-PI s)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment