Created
May 24, 2015 23:12
-
-
Save zcstarr/0f0fa9082550e4520849 to your computer and use it in GitHub Desktop.
Quick fix for elm-lang example Stamper Gist
This file contains hidden or 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
<html> | |
<head> | |
<title>Embedding Elm in HTML!</title> | |
<script type="text/javascript" src="elm.js"></script> | |
</head> | |
<body> | |
<h1>Stamper</h1> | |
<div id="stamper" style="width:50%; height:400px;"></div> | |
</body> | |
<script type="text/javascript"> | |
var stamperDiv = document.getElementById('stamper'); | |
Elm.embed(Elm.Stamper, stamperDiv); | |
</script> | |
</html> |
This file contains hidden or 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
module Stamper where | |
import Color exposing (..) | |
import Graphics.Collage exposing (..) | |
import Graphics.Element exposing (..) | |
import List | |
import List exposing ((::)) | |
import Mouse | |
import Signal | |
import Window | |
main : Signal Element | |
main = | |
Signal.map2 renderStamps Window.dimensions clickLocations | |
clickLocations : Signal (List (Int,Int)) | |
clickLocations = | |
Signal.foldp (::) [] (Signal.sampleOn Mouse.clicks Mouse.position) | |
renderStamps : (Int,Int) -> List (Int,Int) -> Element | |
renderStamps (w,h) locs = | |
let pentagon (x,y) = | |
ngon 5 20 | |
|> filled (hsla (toFloat x) 0.9 0.6 0.7) | |
|> move (toFloat x - toFloat w / 2, toFloat h / 2 - toFloat y) | |
|> rotate (toFloat x) | |
in | |
layers | |
[ collage w h (List.map pentagon locs) | |
, show "Click to stamp a pentagon." | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a quick fix for an elm example referencing
http://elm-lang.org/edit/examples/Intermediate/Stamps.elm