gegl-0.0.0.5: src/GEGL/Rectangle.hs
-- | Rectangles from this module are used to specify areas for operations.
module GEGL.Rectangle
( FFI.GeglRectangle(..)
, gegl_rectangle_intersect
-- , gegl_rectangle_infinite_plane
) where
import Foreign.Marshal.Utils (new)
import Foreign.Marshal.Alloc (free)
import Foreign.Storable (peek)
import qualified GEGL.FFI.Rectangle as FFI
-- | Calculates the intersection of two rectangles.
gegl_rectangle_intersect
:: FFI.GeglRectangle -- ^ A rectangle
-> FFI.GeglRectangle -- ^ A rectangle
-> IO (Maybe FFI.GeglRectangle) -- ^ Returns a 'FFI.GeglRectangle' if
-- rectangles intersect, otherwise 'Nothing'
gegl_rectangle_intersect a b = do
pa <- new a
pb <- new b
res <- FFI.c_gegl_rectangle_intersect pa pa pb
ret <- if res
then do
iret <- peek pa
return $ Just iret
else
return Nothing
free pa
free pb
return ret
-- -- | returns a 'GeglRectangle' representing an inifinite plane
-- gegl_rectangle_infinite_plane
-- :: IO FFI.GeglRectangle -- ^ The infinite plane
-- gegl_rectangle_infinite_plane = do
-- rectPtr <- FFI.c_gegl_rectangle_infinite_plane
-- rect <- peek rectPtr
-- free rectPtr