Skip to content

Instantly share code, notes, and snippets.

@skrat
Last active April 6, 2016 01:42
Show Gist options
  • Save skrat/927ea4da8948717487f6b2b128020c29 to your computer and use it in GitHub Desktop.
Save skrat/927ea4da8948717487f6b2b128020c29 to your computer and use it in GitHub Desktop.
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Mouse
import Window
import Time
import Signal
main : Signal Element
main =
Signal.map2 scene dmouse Window.dimensions
ease : (Float,Float) -> (Float,Float) -> (Float,Float)
ease (nx,ny) (px,py) = ((px + (nx - px) * 0.1),(py + (ny - py) * 0.1))
fmouse : Signal (Float,Float)
fmouse = Signal.map (\(x,y) -> (toFloat x, toFloat y)) Mouse.position
dmouse : Signal (Float,Float)
dmouse = Signal.foldp ease (0,0) fmouse
scene : (Float,Float) -> (Int,Int) -> Element
scene (x,y) (w,h) =
let
(dx,dy) =
(x - toFloat w / 2, toFloat h / 2 - y)
in
collage w h
[ ngon 3 100
|> filled blue
|> rotate (atan2 dy dx)
, ngon 6 30
|> filled orange
|> move (dx, dy)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment