Created
September 3, 2014 02:06
-
-
Save nebuta/0f9891e085bdbd0ac64f to your computer and use it in GitHub Desktop.
Circles zooming
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
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