Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Color exposing (..)
- import Graphics.Collage exposing (..)
- import Graphics.Element exposing (..)
- import Mouse
- import Window
- main : Signal Element
- main =
- Signal.map3 scene Mouse.position anchor Window.dimensions
- scene : (Int,Int) -> (Int,Int) -> (Int,Int) -> Element
- scene (x,y) (z,a) (w,h) =
- let (dx,dy) =
- (toFloat x - toFloat w / 2, toFloat h / 2 - toFloat y)
- (dz,da) =
- (toFloat z - toFloat w / 2, toFloat h / 2 - toFloat a)
- in
- collage w h
- [ ngon 3 100
- |> filled blue
- |> rotate (atan2 (da - dy) (dz - dx))
- |> move (dz, da)
- , ngon 6 30
- |> filled orange
- |> move (dx, dy)
- ]
- anchor : Signal (Int, Int)
- anchor =
- Signal.foldp
- avera
- (0,0)
- Mouse.position
- avera : (Int, Int) -> (Int, Int) -> (Int, Int)
- avera (newx, newy) (oldx, oldy) =
- ( round (toFloat oldx * 0.99 + toFloat newx * 0.01)
- , round (toFloat oldy * 0.99 + toFloat newy * 0.01)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement