Last active
August 29, 2015 14:06
-
-
Save neotrinity/da336ba1b9d0079e2a82 to your computer and use it in GitHub Desktop.
elm clock tutorial
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
main = lift clock (every second) | |
number n = let angle = degrees (90 - 6 * (n * 5)) | |
in move (100 * cos angle, 100 * sin angle) (toForm (asText n)) | |
displayNumbers = group (map number [1..12]) | |
clock t = collage 400 400 [ outlined (solid blue) (circle 110) | |
, filled lightGrey (circle 110) | |
, displayNumbers | |
, hand orange 90 t | |
, hand charcoal 90 (t/60) | |
, hand charcoal 50 (t/720) ] | |
hand clr len time = | |
let angle = degrees (90 - 6 * inSeconds time) | |
in traced (solid clr) <| segment (0,0) (len * cos angle, len * sin angle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment