Skip to content

Instantly share code, notes, and snippets.

@RudolfVonKrugstein
Created July 16, 2012 12:44
Show Gist options
  • Save RudolfVonKrugstein/3122489 to your computer and use it in GitHub Desktop.
Save RudolfVonKrugstein/3122489 to your computer and use it in GitHub Desktop.
UHC get context2d
data Document
data Context2D
data Canvas
foreign import js "document"
    document :: IO Document
foreign import js "%1.getElementById(%2)"
    jsGetElementById :: Document -> JSString -> IO Canvas
getElementById doc = jsGetElementById doc . toJS
foreign import js "%1.getContext('2d')"
    getContext2dFromCanvas :: Canvas -> IO Context2D
getContext2d :: String -> IO Context2D
getContext2d canvasName = do
  d <- document
  c <- getElementById d canvasName
  getContext2dFromCanvas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment