Skip to content

Instantly share code, notes, and snippets.

@neotrinity
Last active August 29, 2015 14:06
Show Gist options
  • Save neotrinity/da336ba1b9d0079e2a82 to your computer and use it in GitHub Desktop.
Save neotrinity/da336ba1b9d0079e2a82 to your computer and use it in GitHub Desktop.
elm clock tutorial
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