package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.gsk/Ocgtk_gsk/Gsk/Wrappers/Transform/index.html

Module Wrappers.Transform

type t = [ `transform ] Gobject.obj

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

val new_ : unit -> t

Create a new Transform

val translate_3d : t -> Ocgtk_graphene.Graphene.Wrappers.Point3_d.t -> t option

Translates @next by @point.

val translate : t -> Ocgtk_graphene.Graphene.Wrappers.Point.t -> t option

Translates @next in 2-dimensional space by @point.

Transforms a `graphene_point_t` using the given transform @self.

Transforms a `graphene_rect_t` using the given transform @self.

The result is the bounding box containing the coplanar quad.

val transform : t -> t option -> t option

Applies all the operations from @other to @next.

val to_translate : t -> float * float

Converts a `GskTransform` to a translation operation.

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

gsk_transform_get_category() >= %GSK_TRANSFORM_CATEGORY_2D_TRANSLATE

to check.

val to_string : t -> string

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

The resulting string can be parsed with func@Gsk.Transform.parse.

This is a wrapper around method@Gsk.Transform.print.

Computes the actual value of @self and stores it in @out_matrix.

The previous value of @out_matrix will be ignored.

val to_affine : t -> 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

gsk_transform_get_category() >= %GSK_TRANSFORM_CATEGORY_2D_AFFINE

to check.

val to_2d_components : t -> 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

gsk_transform_get_category() >= %GSK_TRANSFORM_CATEGORY_2D

to check.

val to_2d : t -> 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 gsk_transform_get_category() >= %GSK_TRANSFORM_CATEGORY_2D 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.

val skew : t -> float -> float -> t option

Applies a skew transform.

val scale_3d : t -> float -> float -> float -> t option

Scales @next by the given factors.

val scale : t -> float -> float -> t option

Scales @next in 2-dimensional space by the given factors.

Use method@Gsk.Transform.scale_3d to scale in all 3 dimensions.

val rotate_3d : t -> float -> Ocgtk_graphene.Graphene.Wrappers.Vec3.t -> t option

Rotates @next @angle degrees around @axis.

For a rotation in 2D space, use method@Gsk.Transform.rotate

val rotate : t -> float -> t option

Rotates @next @angle degrees in 2D - or in 3D-speak, around the Z axis. The rotation happens around the origin point of (0, 0).

val ref : t -> t option

Acquires a reference on the given `GskTransform`.

val perspective : t -> float -> t

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.

Multiplies @next with the given @matrix.

val invert : t -> t option

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.

val get_category : t -> Gsk_enums.transformcategory

Returns the category this transform belongs to.

val equal : t -> t option -> bool

Checks two transforms for equality.

val get_type : unit -> Gobject.Type.t