gi-gsk-4.0.9: Gsk bindings

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

Contents

- Exported types
- Methods
  - equal
  - getCategory
  - invert
  - matrix
  - matrix2d
  - new
  - parse
  - perspective
  - print
  - ref
  - rotate
  - rotate3d
  - scale
  - scale3d
  - skew
  - to2d
  - to2dComponents
  - toAffine
  - toMatrix
  - toString
  - toTranslate
  - transform
  - transformBounds
  - transformPoint
  - translate
  - translate3d
  - unref

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
- transformMatrix2d :: (HasCallStack, MonadIO m) => Maybe Transform -> Float -> Float -> Float -> Float -> Float -> Float -> m (Maybe 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

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 Methods (==) :: Transform -> Transform -> Bool Source # (/=) :: Transform -> Transform -> Bool Source #
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 Source #
TypedObject Transform Source # |
Instance details Defined in GI.Gsk.Structs.Transform Methods glibType :: IO GType Source #
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 Source # gvalueSet_ :: Ptr GValue -> Maybe Transform -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Transform) Source #
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, matrix2d, 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) |
=> Maybe 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) |
=> Maybe Transform | `self`: a transform
-> m TransformCategory | Returns: The category of the transform

Returns the category this transform belongs to.

## invert

transformInvert Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Transform | `self`: transform to invert
-> 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

transformMatrix Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe 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`.

This function consumes `next`. Use `transformRef` first if you want to keep it around.

## matrix2d

transformMatrix2d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Transform | `next`: the next transform
-> Float | `xx`: the xx member
-> Float | `yx`: the yx member
-> Float | `xy`: the xy member
-> Float | `yy`: the yy member
-> Float | `dx`: the x0 member
-> Float | `dy`: the y0 member
-> m (Maybe Transform) | Returns: The new transform

Multiplies `next` with the matrix [ xx yx x0; xy yy y0; 0 0 1 ].

The result of calling `transformTo2d` on the returned `Transform` should match the input passed to this function.

This function consumes `next`. Use `transformRef` first if you want to keep it around.

Since: 4.20

## new

transformNew Source #

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

transformParse Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `string`: the string to parse
-> m (Bool, Transform) | Returns: true if `string` described a valid transform

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

transformPerspective Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe 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.

This function consumes `next`. Use `transformRef` first if you want to keep it around.

## print

transformPrint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Transform | `self`: a transform
-> String | `string`: The string to print into
-> m () |

Converts the transform into a human-readable representation.

The result of this function can later be parsed with `transformParse`.

## ref

transformRef Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Transform | `self`: a transform
-> m (Maybe Transform) | Returns: the transform with an additional reference

Acquires a reference on the given transform.

## rotate

transformRotate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Transform | `next`: the next transform
-> Float | `angle`: the rotation angle, in degrees (clockwise)
-> 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

transformRotate3d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe 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`

This function consumes `next`. Use `transformRef` first if you want to keep it around.

## scale

transformScale Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe 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.

This function consumes `next`. Use `transformRef` first if you want to keep it around.

## scale3d

transformScale3d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe 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.

This function consumes `next`. Use `transformRef` first if you want to keep it around.

## skew

transformSkew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe 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.

This function consumes `next`. Use `transformRef` first if you want to keep it around.

Since: 4.6

## to2d

transformTo2d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Transform | `self`: a 2D 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 | `self`: a 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_INIT (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

transformToAffine Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Transform | `self`: a 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

transformToMatrix Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Transform | `self`: a transform
-> m Matrix |

Computes the 4x4 matrix for the transform.

The previous value of `outMatrix` will be ignored.

## toString

transformToString Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Transform | `self`: a transform
-> m Text | Returns: A new string for `self`

Converts the transform into a human-readable string.

The resulting string can be parsed with `transformParse`.

This is a wrapper around `transformPrint`.

## toTranslate

transformToTranslate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Transform | `self`: a 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

transformTransform Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe 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`.

This function consumes `next`. Use `transformRef` first if you want to keep it around.

## transformBounds

transformTransformBounds Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Transform | `self`: a transform
-> Rect | `rect`: the rectangle to transform
-> m Rect |

Transforms a rectangle using the given transform.

The result is the bounding box containing the coplanar quad.

The input and output rect may point to the same rectangle.

## transformPoint

transformTransformPoint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Transform | `self`: a transform
-> Point | `point`: the point to transform
-> m Point |

Transforms a point using the given transform.

## translate

transformTranslate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe 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`.

This function consumes `next`. Use `transformRef` first if you want to keep it around.

## translate3d

transformTranslate3d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe 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`.

This function consumes `next`. Use `transformRef` first if you want to keep it around.

## unref

transformUnref Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Transform | `self`: a transform
-> m () |

Releases a reference on the given transform.

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