packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/Point2D.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from image-capture (webref). Do not edit.
module JSDOM.Generated.Point2D
       (newPoint2D, setX, getX, getXUnsafe, getXUnchecked, setY, getY, getYUnsafe, getYUnchecked, Point2D(..), gTypePoint2D)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums

-- | <https://w3c.github.io/mediacapture-image/#dictdef-point2d Point2D specification>
newPoint2D :: (MonadDOM m) => m Point2D
newPoint2D = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))

-- | <https://w3c.github.io/mediacapture-image/#dom-point2d-x Point2D.x specification>
setX :: (MonadDOM m) => Point2D -> Double -> m ()
setX self val = liftDOM (void (self ^. jss "x" (toJSVal val)))

-- | <https://w3c.github.io/mediacapture-image/#dom-point2d-x Point2D.x specification>
getX :: (MonadDOM m) => Point2D -> m (Maybe Double)
getX self = liftDOM (((self ^. js "x") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/mediacapture-image/#dom-point2d-x Point2D.x specification>
getXUnsafe :: (MonadDOM m, HasCallStack) => Point2D -> m Double
getXUnsafe self = liftDOM ((((self ^. js "x") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/mediacapture-image/#dom-point2d-x Point2D.x specification>
getXUnchecked :: (MonadDOM m) => Point2D -> m Double
getXUnchecked self = liftDOM (((self ^. js "x") >>= valToNumber))

-- | <https://w3c.github.io/mediacapture-image/#dom-point2d-y Point2D.y specification>
setY :: (MonadDOM m) => Point2D -> Double -> m ()
setY self val = liftDOM (void (self ^. jss "y" (toJSVal val)))

-- | <https://w3c.github.io/mediacapture-image/#dom-point2d-y Point2D.y specification>
getY :: (MonadDOM m) => Point2D -> m (Maybe Double)
getY self = liftDOM (((self ^. js "y") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/mediacapture-image/#dom-point2d-y Point2D.y specification>
getYUnsafe :: (MonadDOM m, HasCallStack) => Point2D -> m Double
getYUnsafe self = liftDOM ((((self ^. js "y") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/mediacapture-image/#dom-point2d-y Point2D.y specification>
getYUnchecked :: (MonadDOM m) => Point2D -> m Double
getYUnchecked self = liftDOM (((self ^. js "y") >>= valToNumber))