{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.HTMLCanvasElement
(getContext, getContext_, getContextUnsafe, getContextUnchecked,
toDataURL, toDataURL_, toBlob', captureStream, captureStream_,
setWidth, getWidth, setHeight, getHeight, HTMLCanvasElement(..),
gTypeHTMLCanvasElement)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
getContext ::
(MonadDOM m, ToJSString contextId, ToJSVal arguments) =>
HTMLCanvasElement ->
contextId -> [arguments] -> m (Maybe RenderingContext)
getContext self contextId arguments
= liftDOM
((self ^. jsf "getContext"
[toJSVal contextId, toJSVal (array arguments)])
>>= fromJSVal)
getContext_ ::
(MonadDOM m, ToJSString contextId, ToJSVal arguments) =>
HTMLCanvasElement -> contextId -> [arguments] -> m ()
getContext_ self contextId arguments
= liftDOM
(void
(self ^. jsf "getContext"
[toJSVal contextId, toJSVal (array arguments)]))
getContextUnsafe ::
(MonadDOM m, ToJSString contextId, ToJSVal arguments,
HasCallStack) =>
HTMLCanvasElement -> contextId -> [arguments] -> m RenderingContext
getContextUnsafe self contextId arguments
= liftDOM
(((self ^. jsf "getContext"
[toJSVal contextId, toJSVal (array arguments)])
>>= fromJSVal)
>>= maybe (Prelude.error "Nothing to return") return)
getContextUnchecked ::
(MonadDOM m, ToJSString contextId, ToJSVal arguments) =>
HTMLCanvasElement -> contextId -> [arguments] -> m RenderingContext
getContextUnchecked self contextId arguments
= liftDOM
((self ^. jsf "getContext"
[toJSVal contextId, toJSVal (array arguments)])
>>= fromJSValUnchecked)
toDataURL ::
(MonadDOM m, ToJSString type', FromJSString result) =>
HTMLCanvasElement -> Maybe type' -> m result
toDataURL self type'
= liftDOM
((self ^. jsf "toDataURL" [toJSVal type']) >>= fromJSValUnchecked)
toDataURL_ ::
(MonadDOM m, ToJSString type') =>
HTMLCanvasElement -> Maybe type' -> m ()
toDataURL_ self type'
= liftDOM (void (self ^. jsf "toDataURL" [toJSVal type']))
toBlob' ::
(MonadDOM m, ToJSString type', ToJSVal quality) =>
HTMLCanvasElement ->
BlobCallback -> Maybe type' -> Maybe quality -> m ()
toBlob' self callback type' quality
= liftDOM
(void
(self ^. jsf "toBlob"
[toJSVal callback, toJSVal type', toJSVal quality]))
captureStream ::
(MonadDOM m) => HTMLCanvasElement -> Maybe Double -> m MediaStream
captureStream self frameRequestRate
= liftDOM
((self ^. jsf "captureStream" [toJSVal frameRequestRate]) >>=
fromJSValUnchecked)
captureStream_ ::
(MonadDOM m) => HTMLCanvasElement -> Maybe Double -> m ()
captureStream_ self frameRequestRate
= liftDOM
(void (self ^. jsf "captureStream" [toJSVal frameRequestRate]))
setWidth :: (MonadDOM m) => HTMLCanvasElement -> Word -> m ()
setWidth self val = liftDOM (self ^. jss "width" (toJSVal val))
getWidth :: (MonadDOM m) => HTMLCanvasElement -> m Word
getWidth self
= liftDOM (round <$> ((self ^. js "width") >>= valToNumber))
setHeight :: (MonadDOM m) => HTMLCanvasElement -> Word -> m ()
setHeight self val = liftDOM (self ^. jss "height" (toJSVal val))
getHeight :: (MonadDOM m) => HTMLCanvasElement -> m Word
getHeight self
= liftDOM (round <$> ((self ^. js "height") >>= valToNumber))