gi-gsk-4.0.5: Gsk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gsk.Structs.Transform

Description

GskTransform is an object to describe transform matrices.

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

Exported types

newtype Transform Source #

Memory-managed wrapper type.

Constructors

Transform (ManagedPtr Transform) 

Instances

Instances details
Eq Transform Source # 
Instance details

Defined in GI.Gsk.Structs.Transform

GBoxed Transform Source # 
Instance details

Defined in GI.Gsk.Structs.Transform

ManagedPtrNewtype Transform Source # 
Instance details

Defined in GI.Gsk.Structs.Transform

Methods

toManagedPtr :: Transform -> ManagedPtr Transform

TypedObject Transform Source # 
Instance details

Defined in GI.Gsk.Structs.Transform

Methods

glibType :: IO GType

HasParentTypes Transform Source # 
Instance details

Defined in GI.Gsk.Structs.Transform

IsGValue (Maybe Transform) Source #

Convert Transform to and from GValue. See toGValue and fromGValue.

Instance details

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 # 
Instance details

Defined in GI.Gsk.Structs.Transform

type ParentTypes Transform = '[] :: [Type]

Methods

Click to display all available methods, including inherited ones

Expand

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

getCategory.

Setters

None.

equal

transformEqual Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

first: the first transform

-> Maybe Transform

second: the second transform

-> m Bool

Returns: True if the two transforms perform the same operation

Checks two transforms for equality.

getCategory

transformGetCategory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: A GskTransform

-> m TransformCategory

Returns: The category of the transform

Returns the category this transform belongs to.

invert

transformInvert Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: Transform to invert

-> m (Maybe Transform)

Returns: The inverted transform

Inverts the given transform.

If self is not invertible, Nothing is returned. Note that inverting Nothing also returns Nothing, which is the correct inverse of Nothing. If you need to differentiate between those cases, you should check self is not Nothing before calling this function.

matrix

transformMatrix Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: the next transform

-> Matrix

matrix: the matrix to multiply next with

-> m Transform

Returns: The new transform

Multiplies next with the given matrix.

new

transformNew :: (HasCallStack, MonadIO m) => m Transform Source #

No description available in the introspection data.

parse

transformParse Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

string: the string to parse

-> m (Bool, Transform)

Returns: True if string described a valid transform.

Parses the given string into a transform and puts it in outTransform.

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 Nothing is put in outTransform.

perspective

transformPerspective Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: the next transform

-> Float

depth: distance of the z=0 plane. Lower values give a more flattened pyramid and therefore a more pronounced perspective effect.

-> 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.

print

transformPrint Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a GskTransform

-> String

string: The string to print into

-> m () 

Converts self into a human-readable string representation suitable for printing.

The result of this function can later be parsed with [funcgsk.Transform.parse].

ref

transformRef Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a GskTransform

-> m (Maybe Transform)

Returns: the GskTransform with an additional reference

Acquires a reference on the given GskTransform.

rotate

transformRotate Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: the next transform

-> Float

angle: the rotation angle, in degrees (clockwise)

-> m (Maybe Transform)

Returns: The new transform

Rotates next angle degrees in 2D - or in 3D-speak, around the z axis.

rotate3d

transformRotate3d Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: the next transform

-> Float

angle: the rotation angle, in degrees (clockwise)

-> Vec3

axis: The rotation axis

-> m (Maybe Transform)

Returns: The new transform

Rotates next angle degrees around axis.

For a rotation in 2D space, use transformRotate

scale

transformScale Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: the next transform

-> Float

factorX: scaling factor on the X axis

-> Float

factorY: scaling factor on the Y axis

-> 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.

scale3d

transformScale3d Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: the next transform

-> Float

factorX: scaling factor on the X axis

-> Float

factorY: scaling factor on the Y axis

-> Float

factorZ: scaling factor on the Z axis

-> m (Maybe Transform)

Returns: The new transform

Scales next by the given factors.

skew

transformSkew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: the next transform

-> Float

skewX: skew factor, in degrees, on the X axis

-> Float

skewY: skew factor, in degrees, on the Y axis

-> m (Maybe Transform)

Returns: The new transform

Applies a skew transform.

Since: 4.6

to2d

transformTo2d Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a 2D GskTransform

-> m (Float, Float, Float, Float, Float, Float) 

Converts a GskTransform to a 2D transformation matrix.

self must be a 2D transformation. If you are not sure, use transformGetCategory >= TransformCategory2d to check.

The returned values 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

self: a GskTransform

-> m (Float, Float, Float, Float, Float, Float, Float) 

Converts a GskTransform 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 >= TransformCategory2d

to check.

Since: 4.6

toAffine

transformToAffine Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a GskTransform

-> m (Float, Float, Float, Float) 

Converts a GskTransform 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 >= TransformCategory2dAffine

to check.

toMatrix

transformToMatrix Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a GskTransform

-> m Matrix 

Computes the actual value of self and stores it in outMatrix.

The previous value of outMatrix will be ignored.

toString

transformToString Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a GskTransform

-> m Text

Returns: A new string for self

Converts a matrix into a string that is suitable for printing.

The resulting string can be parsed with [funcgsk.Transform.parse].

This is a wrapper around transformPrint.

toTranslate

transformToTranslate Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a GskTransform

-> m (Float, Float) 

Converts a GskTransform to a translation operation.

self must be a 2D transformation. If you are not sure, use

transformGetCategory >= TransformCategory2dTranslate

to check.

transform

transformTransform Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: Transform to apply other to

-> Maybe Transform

other: Transform to apply

-> m (Maybe Transform)

Returns: The new transform

Applies all the operations from other to next.

transformBounds

transformTransformBounds Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a GskTransform

-> Rect

rect: a graphene_rect_t

-> m Rect 

Transforms a graphene_rect_t using the given transform self.

The result is the bounding box containing the coplanar quad.

transformPoint

transformTransformPoint Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a GskTransform

-> Point

point: a graphene_point_t

-> m Point 

Transforms a graphene_point_t using the given transform self.

translate

transformTranslate Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: the next transform

-> Point

point: the point to translate the transform by

-> m (Maybe Transform)

Returns: The new transform

Translates next in 2-dimensional space by point.

translate3d

transformTranslate3d Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

next: the next transform

-> Point3D

point: the point to translate the transform by

-> m (Maybe Transform)

Returns: The new transform

Translates next by point.

unref

transformUnref Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Transform

self: a GskTransform

-> m () 

Releases a reference on the given GskTransform.

If the reference was the last, the resources associated to the self are freed.