-
-
Save spion/982350f4b3d3464b1870 to your computer and use it in GitHub Desktop.
This file contains 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
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 |
This file contains 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
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