Skip to content

Instantly share code, notes, and snippets.

@nebuta
Created September 3, 2014 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nebuta/0f9891e085bdbd0ac64f to your computer and use it in GitHub Desktop.
Save nebuta/0f9891e085bdbd0ac64f to your computer and use it in GitHub Desktop.
Circles zooming
import Mouse
main = lift scene v
scene : Float -> Element
scene v = collage 600 600 (objs v ++ [
toForm <| plainText (show v)])
objs : Float -> [Form]
objs factor = map (render factor) <| filter (pred factor) [30,20,10,5]
render : Float -> Float -> Form
render f x = filled (hsla (x/50*pi) 0.5 0.5 (min 1 (f*x/100))) <| circle (f*x)
pred n f = n * f >= 30
v : Signal Float
v = lift (f . toFloat . fst) Mouse.position
f x = range 0 10 . (\x -> x / 20) <| (x - 50)
min x y = if x < y then x else y
max x y = if x > y then x else y
range x y v = max x (min v y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment