Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
GI.Gsk.Structs.Transform
Description
Describes a 3D transform.
Unlike graphene_matrix_t
, GskTransform
retains the steps in how
a transform was constructed, and allows inspecting them. It is modeled
after the way CSS describes transforms.
GskTransform
objects are immutable and cannot be changed after creation.
This means code can safely expose them as properties of objects without
having to worry about others changing them.
Synopsis
- newtype Transform = Transform (ManagedPtr Transform)
- transformEqual :: (HasCallStack, MonadIO m) => Maybe Transform -> Maybe Transform -> m Bool
- transformGetCategory :: (HasCallStack, MonadIO m) => Maybe Transform -> m TransformCategory
- transformInvert :: (HasCallStack, MonadIO m) => Maybe Transform -> m (Maybe Transform)
- transformMatrix :: (HasCallStack, MonadIO m) => Maybe Transform -> Matrix -> m Transform
- transformNew :: (HasCallStack, MonadIO m) => m Transform
- transformParse :: (HasCallStack, MonadIO m) => Text -> m (Bool, Transform)
- transformPerspective :: (HasCallStack, MonadIO m) => Maybe Transform -> Float -> m Transform
- transformPrint :: (HasCallStack, MonadIO m) => Maybe Transform -> String -> m ()
- transformRef :: (HasCallStack, MonadIO m) => Maybe Transform -> m (Maybe Transform)
- transformRotate :: (HasCallStack, MonadIO m) => Maybe Transform -> Float -> m (Maybe Transform)
- transformRotate3d :: (HasCallStack, MonadIO m) => Maybe Transform -> Float -> Vec3 -> m (Maybe Transform)
- transformScale :: (HasCallStack, MonadIO m) => Maybe Transform -> Float -> Float -> m (Maybe Transform)
- transformScale3d :: (HasCallStack, MonadIO m) => Maybe Transform -> Float -> Float -> Float -> m (Maybe Transform)
- transformSkew :: (HasCallStack, MonadIO m) => Maybe Transform -> Float -> Float -> m (Maybe Transform)
- transformTo2d :: (HasCallStack, MonadIO m) => Transform -> m (Float, Float, Float, Float, Float, Float)
- transformTo2dComponents :: (HasCallStack, MonadIO m) => Transform -> m (Float, Float, Float, Float, Float, Float, Float)
- transformToAffine :: (HasCallStack, MonadIO m) => Transform -> m (Float, Float, Float, Float)
- transformToMatrix :: (HasCallStack, MonadIO m) => Maybe Transform -> m Matrix
- transformToString :: (HasCallStack, MonadIO m) => Maybe Transform -> m Text
- transformToTranslate :: (HasCallStack, MonadIO m) => Transform -> m (Float, Float)
- transformTransform :: (HasCallStack, MonadIO m) => Maybe Transform -> Maybe Transform -> m (Maybe Transform)
- transformTransformBounds :: (HasCallStack, MonadIO m) => Transform -> Rect -> m Rect
- transformTransformPoint :: (HasCallStack, MonadIO m) => Transform -> Point -> m Point
- transformTranslate :: (HasCallStack, MonadIO m) => Maybe Transform -> Point -> m (Maybe Transform)
- transformTranslate3d :: (HasCallStack, MonadIO m) => Maybe Transform -> Point3D -> m (Maybe Transform)
- transformUnref :: (HasCallStack, MonadIO m) => Maybe Transform -> m ()
Exported types
Memory-managed wrapper type.
Constructors
Transform (ManagedPtr Transform) |
Instances
Eq Transform Source # | |
GBoxed Transform Source # | |
Defined in GI.Gsk.Structs.Transform | |
ManagedPtrNewtype Transform Source # | |
Defined in GI.Gsk.Structs.Transform Methods | |
TypedObject Transform Source # | |
Defined in GI.Gsk.Structs.Transform | |
HasParentTypes Transform Source # | |
Defined in GI.Gsk.Structs.Transform | |
IsGValue (Maybe Transform) Source # | Convert |
Defined in GI.Gsk.Structs.Transform Methods gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe Transform -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe Transform) # | |
type ParentTypes Transform Source # | |
Defined in GI.Gsk.Structs.Transform type ParentTypes Transform = '[] :: [Type] |
Methods
Click to display all available methods, including inherited ones
Methods
equal, invert, matrix, perspective, print, ref, rotate, rotate3d, scale, scale3d, skew, to2d, to2dComponents, toAffine, toMatrix, toString, toTranslate, transform, transformBounds, transformPoint, translate, translate3d, unref.
Getters
Setters
None.
equal
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Maybe Transform |
|
-> m Bool | Returns: true if the two transforms perform the same operation |
Checks two transforms for equality.
getCategory
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> m TransformCategory | Returns: The category of the transform |
Returns the category this transform belongs to.
invert
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> m (Maybe Transform) | Returns: The inverted transform |
Inverts the given transform.
If self
is not invertible, NULL
is returned.
Note that inverting NULL
also returns NULL
, which is
the correct inverse of NULL
. If you need to differentiate
between those cases, you should check self
is not NULL
before calling this function.
This function consumes self
. Use transformRef
first
if you want to keep it around.
matrix
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Matrix |
|
-> m Transform | Returns: The new transform |
Multiplies next
with the given matrix
.
This function consumes next
. Use transformRef
first
if you want to keep it around.
new
Arguments
:: (HasCallStack, MonadIO m) | |
=> m Transform | Returns: A new identity transform |
Creates a new identity transform.
This function is meant to be used by language
bindings. For C code, this is equivalent to using NULL
.
parse
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m (Bool, Transform) | Returns: true if |
Parses a given into a transform.
Strings printed via transformToString
can be read in again successfully using this function.
If string
does not describe a valid transform, false
is returned and NULL
is put in outTransform
.
perspective
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Float |
|
-> m Transform | Returns: The new transform |
Applies a perspective projection transform.
This transform scales points in X and Y based on their Z value, scaling points with positive Z values away from the origin, and those with negative Z values towards the origin. Points on the z=0 plane are unchanged.
This function consumes next
. Use transformRef
first
if you want to keep it around.
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> String |
|
-> m () |
Converts the transform into a human-readable representation.
The result of this function can later be parsed with
transformParse
.
ref
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> m (Maybe Transform) | Returns: the transform with an additional reference |
Acquires a reference on the given transform.
rotate
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Float |
|
-> m (Maybe Transform) | Returns: The new transform |
Rotates next
by an angle around the Z axis.
The rotation happens around the origin point of (0, 0).
This function consumes next
. Use transformRef
first
if you want to keep it around.
rotate3d
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Float |
|
-> Vec3 |
|
-> m (Maybe Transform) | Returns: The new transform |
Rotates next
angle
degrees around axis
.
For a rotation in 2D space, use transformRotate
This function consumes next
. Use transformRef
first
if you want to keep it around.
scale
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Float |
|
-> Float |
|
-> m (Maybe Transform) | Returns: The new transform |
Scales next
in 2-dimensional space by the given factors.
Use transformScale3d
to scale in all 3 dimensions.
This function consumes next
. Use transformRef
first
if you want to keep it around.
scale3d
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> m (Maybe Transform) | Returns: The new transform |
Scales next
by the given factors.
This function consumes next
. Use transformRef
first
if you want to keep it around.
skew
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Float |
|
-> Float |
|
-> m (Maybe Transform) | Returns: The new transform |
Applies a skew transform.
This function consumes next
. Use transformRef
first
if you want to keep it around.
Since: 4.6
to2d
Arguments
:: (HasCallStack, MonadIO m) | |
=> Transform |
|
-> m (Float, Float, Float, Float, Float, Float) |
Converts a transform to a 2D transformation matrix.
self
must be a 2D transformation. If you are not
sure, use
transformGetCategory
>= GSK_TRANSFORM_CATEGORY_2D
to check.
The returned values are a subset of the full 4x4 matrix that
is computed by transformToMatrix
and have the
following layout:
| xx yx | | a b 0 | | xy yy | = | c d 0 | | dx dy | | tx ty 1 |
This function can be used to convert between a GskTransform
and a matrix type from other 2D drawing libraries, in particular
Cairo.
to2dComponents
transformTo2dComponents Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Transform |
|
-> m (Float, Float, Float, Float, Float, Float, Float) |
Converts a transform to 2D transformation factors.
To recreate an equivalent transform from the factors returned by this function, use
gsk_transform_skew ( gsk_transform_scale ( gsk_transform_rotate ( gsk_transform_translate (NULL, &GRAPHENE_POINT_T (dx, dy)), angle), scale_x, scale_y), skew_x, skew_y)
self
must be a 2D transformation. If you are not sure, use
transformGetCategory
>= GSK_TRANSFORM_CATEGORY_2D
to check.
Since: 4.6
toAffine
Arguments
:: (HasCallStack, MonadIO m) | |
=> Transform |
|
-> m (Float, Float, Float, Float) |
Converts a transform to 2D affine transformation factors.
To recreate an equivalent transform from the factors returned by this function, use
gsk_transform_scale ( gsk_transform_translate ( NULL, &GRAPHENE_POINT_T (dx, dy)), sx, sy)
self
must be a 2D affine transformation. If you are not
sure, use
transformGetCategory
>= GSK_TRANSFORM_CATEGORY_2D_AFFINE
to check.
toMatrix
Computes the 4x4 matrix for the transform.
The previous value of outMatrix
will be ignored.
toString
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> m Text | Returns: A new string for |
Converts the transform into a human-readable string.
The resulting string can be parsed with transformParse
.
This is a wrapper around transformPrint
.
toTranslate
Arguments
:: (HasCallStack, MonadIO m) | |
=> Transform |
|
-> m (Float, Float) |
Converts a transform to a translation operation.
self
must be a 2D transformation. If you are not
sure, use
transformGetCategory
>= GSK_TRANSFORM_CATEGORY_2D_TRANSLATE
to check.
transform
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Maybe Transform |
|
-> m (Maybe Transform) | Returns: The new transform |
Applies all the operations from other
to next
.
This function consumes next
. Use transformRef
first
if you want to keep it around.
transformBounds
transformTransformBounds Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Transform |
|
-> Rect |
|
-> m Rect |
Transforms a rectangle using the given transform.
The result is the bounding box containing the coplanar quad.
transformPoint
transformTransformPoint Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Transform |
|
-> Point |
|
-> m Point |
Transforms a point using the given transform.
translate
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Point |
|
-> m (Maybe Transform) | Returns: The new transform |
Translates next
in 2-dimensional space by point
.
This function consumes next
. Use transformRef
first
if you want to keep it around.
translate3d
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> Point3D |
|
-> m (Maybe Transform) | Returns: The new transform |
Translates next
by point
.
This function consumes next
. Use transformRef
first
if you want to keep it around.
unref
Arguments
:: (HasCallStack, MonadIO m) | |
=> Maybe Transform |
|
-> m () |
Releases a reference on the given transform.
If the reference was the last, the resources associated to the self
are
freed.