{-# LANGUAGE TypeApplications #-}
#if !defined(__HADDOCK_VERSION__)
#define ENABLE_OVERLOADING
#endif
module GI.Graphene.Structs.Point
(
Point(..) ,
newZeroPoint ,
#if defined(ENABLE_OVERLOADING)
ResolvePointMethod ,
#endif
pointAlloc ,
#if defined(ENABLE_OVERLOADING)
PointDistanceMethodInfo ,
#endif
pointDistance ,
#if defined(ENABLE_OVERLOADING)
PointEqualMethodInfo ,
#endif
pointEqual ,
#if defined(ENABLE_OVERLOADING)
PointFreeMethodInfo ,
#endif
pointFree ,
#if defined(ENABLE_OVERLOADING)
PointInitMethodInfo ,
#endif
pointInit ,
#if defined(ENABLE_OVERLOADING)
PointInitFromPointMethodInfo ,
#endif
pointInitFromPoint ,
#if defined(ENABLE_OVERLOADING)
PointInitFromVec2MethodInfo ,
#endif
pointInitFromVec2 ,
#if defined(ENABLE_OVERLOADING)
PointInterpolateMethodInfo ,
#endif
pointInterpolate ,
#if defined(ENABLE_OVERLOADING)
PointNearMethodInfo ,
#endif
pointNear ,
#if defined(ENABLE_OVERLOADING)
PointToVec2MethodInfo ,
#endif
pointToVec2 ,
pointZero ,
getPointX ,
#if defined(ENABLE_OVERLOADING)
point_x ,
#endif
setPointX ,
getPointY ,
#if defined(ENABLE_OVERLOADING)
point_y ,
#endif
setPointY ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import {-# SOURCE #-} qualified GI.Graphene.Structs.Vec2 as Graphene.Vec2
#else
import {-# SOURCE #-} qualified GI.Graphene.Structs.Vec2 as Graphene.Vec2
#endif
newtype Point = Point (SP.ManagedPtr Point)
deriving (Point -> Point -> Bool
(Point -> Point -> Bool) -> (Point -> Point -> Bool) -> Eq Point
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Point -> Point -> Bool
== :: Point -> Point -> Bool
$c/= :: Point -> Point -> Bool
/= :: Point -> Point -> Bool
Eq)
instance SP.ManagedPtrNewtype Point where
toManagedPtr :: Point -> ManagedPtr Point
toManagedPtr (Point ManagedPtr Point
p) = ManagedPtr Point
p
foreign import ccall "graphene_point_get_type" c_graphene_point_get_type ::
IO GType
type instance O.ParentTypes Point = '[]
instance O.HasParentTypes Point
instance B.Types.TypedObject Point where
glibType :: IO GType
glibType = IO GType
c_graphene_point_get_type
instance B.Types.GBoxed Point
instance B.GValue.IsGValue (Maybe Point) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_graphene_point_get_type
gvalueSet_ :: Ptr GValue -> Maybe Point -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Point
P.Nothing = Ptr GValue -> Ptr Point -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Point
forall a. Ptr a
FP.nullPtr :: FP.Ptr Point)
gvalueSet_ Ptr GValue
gv (P.Just Point
obj) = Point -> (Ptr Point -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Point
obj (Ptr GValue -> Ptr Point -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Point)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr Point)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Point)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newBoxed Point ptr
else return P.Nothing
newZeroPoint :: MonadIO m => m Point
newZeroPoint :: forall (m :: * -> *). MonadIO m => m Point
newZeroPoint = IO Point -> m Point
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point -> m Point) -> IO Point -> m Point
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Point)
forall a. GBoxed a => Int -> IO (Ptr a)
callocBoxedBytes Int
8 IO (Ptr Point) -> (Ptr Point -> IO Point) -> IO Point
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Point -> Point) -> Ptr Point -> IO Point
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Point -> Point
Point
instance tag ~ 'AttrSet => Constructible Point tag where
new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr Point -> Point) -> [AttrOp Point tag] -> m Point
new ManagedPtr Point -> Point
_ [AttrOp Point tag]
attrs = do
o <- m Point
forall (m :: * -> *). MonadIO m => m Point
newZeroPoint
GI.Attributes.set o attrs
return o
getPointX :: MonadIO m => Point -> m Float
getPointX :: forall (m :: * -> *). MonadIO m => Point -> m Float
getPointX Point
s = IO Float -> m Float
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Float -> m Float) -> IO Float -> m Float
forall a b. (a -> b) -> a -> b
$ Point -> (Ptr Point -> IO Float) -> IO Float
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Point
s ((Ptr Point -> IO Float) -> IO Float)
-> (Ptr Point -> IO Float) -> IO Float
forall a b. (a -> b) -> a -> b
$ \Ptr Point
ptr -> do
val <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek (Ptr Point
ptr Ptr Point -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO CFloat
let val' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
val
return val'
setPointX :: MonadIO m => Point -> Float -> m ()
setPointX :: forall (m :: * -> *). MonadIO m => Point -> Float -> m ()
setPointX Point
s Float
val = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Point -> (Ptr Point -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Point
s ((Ptr Point -> IO ()) -> IO ()) -> (Ptr Point -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Point
ptr -> do
let val' :: CFloat
val' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
val
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Point
ptr Ptr Point -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (CFloat
val' :: CFloat)
#if defined(ENABLE_OVERLOADING)
data PointXFieldInfo
instance AttrInfo PointXFieldInfo where
type AttrBaseTypeConstraint PointXFieldInfo = (~) Point
type AttrAllowedOps PointXFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint PointXFieldInfo = (~) Float
type AttrTransferTypeConstraint PointXFieldInfo = (~)Float
type AttrTransferType PointXFieldInfo = Float
type AttrGetType PointXFieldInfo = Float
type AttrLabel PointXFieldInfo = "x"
type AttrOrigin PointXFieldInfo = Point
attrGet = getPointX
attrSet = setPointX
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.x"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#g:attr:x"
})
point_x :: AttrLabelProxy "x"
point_x = AttrLabelProxy
#endif
getPointY :: MonadIO m => Point -> m Float
getPointY :: forall (m :: * -> *). MonadIO m => Point -> m Float
getPointY Point
s = IO Float -> m Float
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Float -> m Float) -> IO Float -> m Float
forall a b. (a -> b) -> a -> b
$ Point -> (Ptr Point -> IO Float) -> IO Float
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Point
s ((Ptr Point -> IO Float) -> IO Float)
-> (Ptr Point -> IO Float) -> IO Float
forall a b. (a -> b) -> a -> b
$ \Ptr Point
ptr -> do
val <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek (Ptr Point
ptr Ptr Point -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4) :: IO CFloat
let val' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
val
return val'
setPointY :: MonadIO m => Point -> Float -> m ()
setPointY :: forall (m :: * -> *). MonadIO m => Point -> Float -> m ()
setPointY Point
s Float
val = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Point -> (Ptr Point -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Point
s ((Ptr Point -> IO ()) -> IO ()) -> (Ptr Point -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Point
ptr -> do
let val' :: CFloat
val' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
val
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Point
ptr Ptr Point -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4) (CFloat
val' :: CFloat)
#if defined(ENABLE_OVERLOADING)
data PointYFieldInfo
instance AttrInfo PointYFieldInfo where
type AttrBaseTypeConstraint PointYFieldInfo = (~) Point
type AttrAllowedOps PointYFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint PointYFieldInfo = (~) Float
type AttrTransferTypeConstraint PointYFieldInfo = (~)Float
type AttrTransferType PointYFieldInfo = Float
type AttrGetType PointYFieldInfo = Float
type AttrLabel PointYFieldInfo = "y"
type AttrOrigin PointYFieldInfo = Point
attrGet = getPointY
attrSet = setPointY
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.y"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#g:attr:y"
})
point_y :: AttrLabelProxy "y"
point_y = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Point
type instance O.AttributeList Point = PointAttributeList
type PointAttributeList = ('[ '("x", PointXFieldInfo), '("y", PointYFieldInfo)] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "graphene_point_alloc" graphene_point_alloc ::
IO (Ptr Point)
pointAlloc ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Point
pointAlloc :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Point
pointAlloc = IO Point -> m Point
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point -> m Point) -> IO Point -> m Point
forall a b. (a -> b) -> a -> b
$ do
result <- IO (Ptr Point)
graphene_point_alloc
checkUnexpectedReturnNULL "pointAlloc" result
result' <- (wrapBoxed Point) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "graphene_point_distance" graphene_point_distance ::
Ptr Point ->
Ptr Point ->
Ptr CFloat ->
Ptr CFloat ->
IO CFloat
pointDistance ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> Point
-> m ((Float, Float, Float))
pointDistance :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Point -> Point -> m (Float, Float, Float)
pointDistance Point
a Point
b = IO (Float, Float, Float) -> m (Float, Float, Float)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Float, Float, Float) -> m (Float, Float, Float))
-> IO (Float, Float, Float) -> m (Float, Float, Float)
forall a b. (a -> b) -> a -> b
$ do
a' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
a
b' <- unsafeManagedPtrGetPtr b
dX <- allocMem :: IO (Ptr CFloat)
dY <- allocMem :: IO (Ptr CFloat)
result <- graphene_point_distance a' b' dX dY
let result' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
result
dX' <- peek dX
let dX'' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
dX'
dY' <- peek dY
let dY'' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
dY'
touchManagedPtr a
touchManagedPtr b
freeMem dX
freeMem dY
return (result', dX'', dY'')
#if defined(ENABLE_OVERLOADING)
data PointDistanceMethodInfo
instance (signature ~ (Point -> m ((Float, Float, Float))), MonadIO m) => O.OverloadedMethod PointDistanceMethodInfo Point signature where
overloadedMethod = pointDistance
instance O.OverloadedMethodInfo PointDistanceMethodInfo Point where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.pointDistance",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#v:pointDistance"
})
#endif
foreign import ccall "graphene_point_equal" graphene_point_equal ::
Ptr Point ->
Ptr Point ->
IO CInt
pointEqual ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> Point
-> m Bool
pointEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Point -> Point -> m Bool
pointEqual Point
a Point
b = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
a' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
a
b' <- unsafeManagedPtrGetPtr b
result <- graphene_point_equal a' b'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr a
touchManagedPtr b
return result'
#if defined(ENABLE_OVERLOADING)
data PointEqualMethodInfo
instance (signature ~ (Point -> m Bool), MonadIO m) => O.OverloadedMethod PointEqualMethodInfo Point signature where
overloadedMethod = pointEqual
instance O.OverloadedMethodInfo PointEqualMethodInfo Point where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.pointEqual",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#v:pointEqual"
})
#endif
foreign import ccall "graphene_point_free" graphene_point_free ::
Ptr Point ->
IO ()
pointFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> m ()
pointFree :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Point -> m ()
pointFree Point
p = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
p' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
p
graphene_point_free p'
touchManagedPtr p
return ()
#if defined(ENABLE_OVERLOADING)
data PointFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod PointFreeMethodInfo Point signature where
overloadedMethod = pointFree
instance O.OverloadedMethodInfo PointFreeMethodInfo Point where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.pointFree",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#v:pointFree"
})
#endif
foreign import ccall "graphene_point_init" graphene_point_init ::
Ptr Point ->
CFloat ->
CFloat ->
IO (Ptr Point)
pointInit ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> Float
-> Float
-> m Point
pointInit :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Point -> Float -> Float -> m Point
pointInit Point
p Float
x Float
y = IO Point -> m Point
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point -> m Point) -> IO Point -> m Point
forall a b. (a -> b) -> a -> b
$ do
p' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
p
let x' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
x
let y' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
y
result <- graphene_point_init p' x' y'
checkUnexpectedReturnNULL "pointInit" result
result' <- (newBoxed Point) result
touchManagedPtr p
return result'
#if defined(ENABLE_OVERLOADING)
data PointInitMethodInfo
instance (signature ~ (Float -> Float -> m Point), MonadIO m) => O.OverloadedMethod PointInitMethodInfo Point signature where
overloadedMethod = pointInit
instance O.OverloadedMethodInfo PointInitMethodInfo Point where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.pointInit",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#v:pointInit"
})
#endif
foreign import ccall "graphene_point_init_from_point" graphene_point_init_from_point ::
Ptr Point ->
Ptr Point ->
IO (Ptr Point)
pointInitFromPoint ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> Point
-> m Point
pointInitFromPoint :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Point -> Point -> m Point
pointInitFromPoint Point
p Point
src = IO Point -> m Point
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point -> m Point) -> IO Point -> m Point
forall a b. (a -> b) -> a -> b
$ do
p' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
p
src' <- unsafeManagedPtrGetPtr src
result <- graphene_point_init_from_point p' src'
checkUnexpectedReturnNULL "pointInitFromPoint" result
result' <- (newBoxed Point) result
touchManagedPtr p
touchManagedPtr src
return result'
#if defined(ENABLE_OVERLOADING)
data PointInitFromPointMethodInfo
instance (signature ~ (Point -> m Point), MonadIO m) => O.OverloadedMethod PointInitFromPointMethodInfo Point signature where
overloadedMethod = pointInitFromPoint
instance O.OverloadedMethodInfo PointInitFromPointMethodInfo Point where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.pointInitFromPoint",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#v:pointInitFromPoint"
})
#endif
foreign import ccall "graphene_point_init_from_vec2" graphene_point_init_from_vec2 ::
Ptr Point ->
Ptr Graphene.Vec2.Vec2 ->
IO (Ptr Point)
pointInitFromVec2 ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> Graphene.Vec2.Vec2
-> m Point
pointInitFromVec2 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Point -> Vec2 -> m Point
pointInitFromVec2 Point
p Vec2
src = IO Point -> m Point
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point -> m Point) -> IO Point -> m Point
forall a b. (a -> b) -> a -> b
$ do
p' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
p
src' <- unsafeManagedPtrGetPtr src
result <- graphene_point_init_from_vec2 p' src'
checkUnexpectedReturnNULL "pointInitFromVec2" result
result' <- (newBoxed Point) result
touchManagedPtr p
touchManagedPtr src
return result'
#if defined(ENABLE_OVERLOADING)
data PointInitFromVec2MethodInfo
instance (signature ~ (Graphene.Vec2.Vec2 -> m Point), MonadIO m) => O.OverloadedMethod PointInitFromVec2MethodInfo Point signature where
overloadedMethod = pointInitFromVec2
instance O.OverloadedMethodInfo PointInitFromVec2MethodInfo Point where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.pointInitFromVec2",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#v:pointInitFromVec2"
})
#endif
foreign import ccall "graphene_point_interpolate" graphene_point_interpolate ::
Ptr Point ->
Ptr Point ->
CDouble ->
Ptr Point ->
IO ()
pointInterpolate ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> Point
-> Double
-> m (Point)
pointInterpolate :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Point -> Point -> Double -> m Point
pointInterpolate Point
a Point
b Double
factor = IO Point -> m Point
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point -> m Point) -> IO Point -> m Point
forall a b. (a -> b) -> a -> b
$ do
a' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
a
b' <- unsafeManagedPtrGetPtr b
let factor' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
factor
res <- SP.callocBoxedBytes 8 :: IO (Ptr Point)
graphene_point_interpolate a' b' factor' res
res' <- (wrapBoxed Point) res
touchManagedPtr a
touchManagedPtr b
return res'
#if defined(ENABLE_OVERLOADING)
data PointInterpolateMethodInfo
instance (signature ~ (Point -> Double -> m (Point)), MonadIO m) => O.OverloadedMethod PointInterpolateMethodInfo Point signature where
overloadedMethod = pointInterpolate
instance O.OverloadedMethodInfo PointInterpolateMethodInfo Point where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.pointInterpolate",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#v:pointInterpolate"
})
#endif
foreign import ccall "graphene_point_near" graphene_point_near ::
Ptr Point ->
Ptr Point ->
CFloat ->
IO CInt
pointNear ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> Point
-> Float
-> m Bool
pointNear :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Point -> Point -> Float -> m Bool
pointNear Point
a Point
b Float
epsilon = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
a' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
a
b' <- unsafeManagedPtrGetPtr b
let epsilon' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
epsilon
result <- graphene_point_near a' b' epsilon'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr a
touchManagedPtr b
return result'
#if defined(ENABLE_OVERLOADING)
data PointNearMethodInfo
instance (signature ~ (Point -> Float -> m Bool), MonadIO m) => O.OverloadedMethod PointNearMethodInfo Point signature where
overloadedMethod = pointNear
instance O.OverloadedMethodInfo PointNearMethodInfo Point where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.pointNear",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#v:pointNear"
})
#endif
foreign import ccall "graphene_point_to_vec2" graphene_point_to_vec2 ::
Ptr Point ->
Ptr Graphene.Vec2.Vec2 ->
IO ()
pointToVec2 ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> m (Graphene.Vec2.Vec2)
pointToVec2 :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Point -> m Vec2
pointToVec2 Point
p = IO Vec2 -> m Vec2
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Vec2 -> m Vec2) -> IO Vec2 -> m Vec2
forall a b. (a -> b) -> a -> b
$ do
p' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
p
v <- SP.callocBoxedBytes 16 :: IO (Ptr Graphene.Vec2.Vec2)
graphene_point_to_vec2 p' v
v' <- (wrapBoxed Graphene.Vec2.Vec2) v
touchManagedPtr p
return v'
#if defined(ENABLE_OVERLOADING)
data PointToVec2MethodInfo
instance (signature ~ (m (Graphene.Vec2.Vec2)), MonadIO m) => O.OverloadedMethod PointToVec2MethodInfo Point signature where
overloadedMethod = pointToVec2
instance O.OverloadedMethodInfo PointToVec2MethodInfo Point where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Point.pointToVec2",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Point.html#v:pointToVec2"
})
#endif
foreign import ccall "graphene_point_zero" graphene_point_zero ::
IO (Ptr Point)
pointZero ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Point
pointZero :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Point
pointZero = IO Point -> m Point
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point -> m Point) -> IO Point -> m Point
forall a b. (a -> b) -> a -> b
$ do
result <- IO (Ptr Point)
graphene_point_zero
checkUnexpectedReturnNULL "pointZero" result
result' <- (newBoxed Point) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolvePointMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolvePointMethod "distance" o = PointDistanceMethodInfo
ResolvePointMethod "equal" o = PointEqualMethodInfo
ResolvePointMethod "free" o = PointFreeMethodInfo
ResolvePointMethod "init" o = PointInitMethodInfo
ResolvePointMethod "initFromPoint" o = PointInitFromPointMethodInfo
ResolvePointMethod "initFromVec2" o = PointInitFromVec2MethodInfo
ResolvePointMethod "interpolate" o = PointInterpolateMethodInfo
ResolvePointMethod "near" o = PointNearMethodInfo
ResolvePointMethod "toVec2" o = PointToVec2MethodInfo
ResolvePointMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePointMethod t Point, O.OverloadedMethod info Point p) => OL.IsLabel t (Point -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolvePointMethod t Point, O.OverloadedMethod info Point p, R.HasField t Point p) => R.HasField t Point p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolvePointMethod t Point, O.OverloadedMethodInfo info Point) => OL.IsLabel t (O.MethodProxy info Point) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif