Skip to content

Instantly share code, notes, and snippets.

@Qata
Created May 18, 2015 06:39
Show Gist options
  • Save Qata/e952c5880108a3977f4b to your computer and use it in GitHub Desktop.
Save Qata/e952c5880108a3977f4b to your computer and use it in GitHub Desktop.
import Text
import Color exposing (..)
import Mouse
import Window
import Time exposing (inSeconds, fps)
import Signal exposing (..)
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
sampleWithFPS frames signal = sampleOn (inSeconds <~ fps frames) signal
sampleWithDelta signal = sampleWithFPS 35 signal
main =
scene <~ (sampleWithDelta Mouse.position) ~ (sampleWithDelta Mouse.isDown) ~ Window.dimensions
scene : (Int, Int) -> Bool -> (Int, Int) -> Element
scene (x,y) held (w, h) =
let (dx,dy) =
(toFloat x - toFloat w / 2, toFloat h / 2 - toFloat y)
in
collage w h
[
circle 60
|> filled (if held then grey else (rgb 255 150 230))
|> move (dx, dy)
, oval 30 45
|> filled (if held then grey else black)
|> move (dx - 20, dy + 20)
, oval 30 45
|> filled (if held then grey else black)
|> move (dx + 20, dy + 20)
, circle 10
|> filled (if held then grey else white)
|> move (dx + 20, dy + 30)
, circle 10
|> filled (if held then grey else white)
|> move (dx - 20, dy + 30)
, circle 10
|> filled (if held then grey else (rgb 255 50 255))
|> move (dx, dy - 30)
, oval 25 10
|> filled (if held then grey else (rgb 255 100 255))
|> move (dx - 23, dy - 10)
, oval 25 10
|> filled (if held then grey else (rgb 255 100 255))
|> move (dx + 23, dy - 10)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment