Skip to content

Instantly share code, notes, and snippets.

@mungojelly
Created September 17, 2015 11:01
Show Gist options
  • Save mungojelly/d6b959a2cd2fbb11e03a to your computer and use it in GitHub Desktop.
Save mungojelly/d6b959a2cd2fbb11e03a to your computer and use it in GitHub Desktop.
import Graphics.Element exposing (..)
import Mouse
import Color exposing (..)
import Graphics.Collage exposing (..)
import Window
main : Signal Element
main =
Signal.map2 scene Mouse.position Window.dimensions
scene : (Int,Int) -> (Int,Int) -> Element
scene (x,y) (w, h) =
let
(dx,dy) =
(toFloat x - toFloat w / 2, toFloat h / 2 - toFloat y)
in
collage w h
[ blueSquare |> move (dx, dy) ]
blueSquare : Form
blueSquare =
traced (dashed blue) square
square : Path
square =
path [ (50,50), (50,-50), (-50,-50), (-50,50), (50,50) ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment