Skip to content

Instantly share code, notes, and snippets.

@spion
Created November 13, 2014 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spion/982350f4b3d3464b1870 to your computer and use it in GitHub Desktop.
Save spion/982350f4b3d3464b1870 to your computer and use it in GitHub Desktop.
import Control.Apply
import Graphics.Canvas (getCanvasElementById, getContext2D)
import Graphics.Canvas.Free
closed path = beginPath *> path <* closePath
filled shape = shape <* fill
withContext shape = save *> shape <* restore
scene :: Graphics Unit
scene = withContext do
setFillStyle "#FF0000"
filled $ closed do
moveTo 0 0
lineTo 50 0
lineTo 25 50
main = do
canvas <- getCanvasElementById "canvas"
context <- getContext2D canvas
runGraphics context scene
import Data.DOM.Free
doc :: Element
doc = div [ _class := "image" ] $ do
elem $ img [ src := "logo.jpg"
, width := 100
, height := 200
]
text "Functional programming for the web!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment