Package ch.bailu.gtk.gsk
Class Transform
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.gsk.Transform
- All Implemented Interfaces:
PointerInterface
`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.
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.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks two transforms for equality.int
Returns the category this transform belongs to.static ClassHandler
static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
invert()
Inverts the given transform.Multiplies @next with the given @matrix.perspective
(float depth) Applies a perspective projection transform.void
Converts @self into a human-readable string representation suitable
for printing.ref()
Acquires a reference on the given `GskTransform`.rotate
(float angle) Rotates @next @angle degrees in 2D - or in 3D-speak, around the z axis.Rotates @next @angle degrees around @axis.scale
(float factor_x, float factor_y) Scales @next in 2-dimensional space by the given factors.scale3d
(float factor_x, float factor_y, float factor_z) Scales @next by the given factors.skew
(float skew_x, float skew_y) Applies a skew transform.void
Converts a `GskTransform` to a 2D transformation matrix.void
to2dComponents
(Flt out_skew_x, Flt out_skew_y, Flt out_scale_x, Flt out_scale_y, Flt out_angle, Flt out_dx, Flt out_dy) Converts a `GskTransform` to 2D transformation factors.void
Converts a `GskTransform` to 2D affine transformation factors.void
Computes the actual value of @self and stores it in @out_matrix.toStr()
Converts a matrix into a string that is suitable for printing.void
toTranslate
(Flt out_dx, Flt out_dy) Converts a `GskTransform` to a translation operation.Applies all the operations from @other to @next.void
transformBounds
(Rect rect, Rect out_rect) Transforms a `graphene_rect_t` using the given transform @self.void
transformPoint
(Point point, Point out_point) Transforms a `graphene_point_t` using the given transform @self.Translates @next in 2-dimensional space by @point.translate3d
(Point3D point) Translates @next by @point.void
unref()
Releases a reference on the given `GskTransform`.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
Transform
-
Transform
public Transform()
-
-
Method Details
-
getClassHandler
-
equal
Checks two transforms for equality.- Parameters:
second
- the second transform- Returns:
- %TRUE if the two transforms perform the same operation
-
getCategory
public int getCategory()Returns the category this transform belongs to.- Returns:
- The category of the transform
-
invert
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.- Returns:
- The inverted transform
-
matrix
Multiplies @next with the given @matrix.- Parameters:
matrix
- the matrix to multiply @next with- Returns:
- The new transform
-
perspective
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.- Parameters:
depth
- distance of the z=0 plane. Lower values give a more flattened pyramid and therefore a more pronounced perspective effect.- Returns:
- The new transform
-
print
Converts @self into a human-readable string representation suitable
for printing.
The result of this function can later be parsed with
[func@Gsk.Transform.parse].- Parameters:
string
- The string to print into
-
ref
Acquires a reference on the given `GskTransform`.- Returns:
- the `GskTransform` with an additional reference
-
rotate
Rotates @next @angle degrees in 2D - or in 3D-speak, around the z axis.- Parameters:
angle
- the rotation angle, in degrees (clockwise)- Returns:
- The new transform
-
rotate3d
Rotates @next @angle degrees around @axis.
For a rotation in 2D space, use [method@Gsk.Transform.rotate]- Parameters:
angle
- the rotation angle, in degrees (clockwise)axis
- The rotation axis- Returns:
- The new transform
-
scale
Scales @next in 2-dimensional space by the given factors.
Use [method@Gsk.Transform.scale_3d] to scale in all 3 dimensions.- Parameters:
factor_x
- scaling factor on the X axisfactor_y
- scaling factor on the Y axis- Returns:
- The new transform
-
scale3d
Scales @next by the given factors.- Parameters:
factor_x
- scaling factor on the X axisfactor_y
- scaling factor on the Y axisfactor_z
- scaling factor on the Z axis- Returns:
- The new transform
-
skew
Applies a skew transform.- Parameters:
skew_x
- skew factor, in degrees, on the X axisskew_y
- skew factor, in degrees, on the Y axis- Returns:
- The new transform
-
to2d
public void to2d(@Nonnull Flt out_xx, @Nonnull Flt out_yx, @Nonnull Flt out_xy, @Nonnull Flt out_yy, @Nonnull Flt out_dx, @Nonnull Flt out_dy) 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.- Parameters:
out_xx
- return location for the xx memberout_yx
- return location for the yx memberout_xy
- return location for the xy memberout_yy
- return location for the yy memberout_dx
- return location for the x0 memberout_dy
- return location for the y0 member
-
to2dComponents
public void to2dComponents(@Nonnull Flt out_skew_x, @Nonnull Flt out_skew_y, @Nonnull Flt out_scale_x, @Nonnull Flt out_scale_y, @Nonnull Flt out_angle, @Nonnull Flt out_dx, @Nonnull Flt out_dy) 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.- Parameters:
out_skew_x
- return location for the skew factor in the x directionout_skew_y
- return location for the skew factor in the y directionout_scale_x
- return location for the scale factor in the x directionout_scale_y
- return location for the scale factor in the y directionout_angle
- return location for the rotation angleout_dx
- return location for the translation in the x directionout_dy
- return location for the translation in the y direction
-
toAffine
public void toAffine(@Nonnull Flt out_scale_x, @Nonnull Flt out_scale_y, @Nonnull Flt out_dx, @Nonnull Flt out_dy) 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.- Parameters:
out_scale_x
- return location for the scale factor in the x directionout_scale_y
- return location for the scale factor in the y directionout_dx
- return location for the translation in the x directionout_dy
- return location for the translation in the y direction
-
toMatrix
Computes the actual value of @self and stores it in @out_matrix.
The previous value of @out_matrix will be ignored.- Parameters:
out_matrix
- The matrix to set
-
toStr
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].- Returns:
- A new string for @self
-
toTranslate
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.- Parameters:
out_dx
- return location for the translation in the x directionout_dy
- return location for the translation in the y direction
-
transform
Applies all the operations from @other to @next.- Parameters:
other
- Transform to apply- Returns:
- The new transform
-
transformBounds
Transforms a `graphene_rect_t` using the given transform @self.
The result is the bounding box containing the coplanar quad.- Parameters:
rect
- a `graphene_rect_t`out_rect
- return location for the bounds of the transformed rectangle
-
transformPoint
Transforms a `graphene_point_t` using the given transform @self.- Parameters:
point
- a `graphene_point_t`out_point
- return location for the transformed point
-
translate
Translates @next in 2-dimensional space by @point.- Parameters:
point
- the point to translate the transform by- Returns:
- The new transform
-
translate3d
Translates @next by @point.- Parameters:
point
- the point to translate the transform by- Returns:
- The new transform
-
unref
public void unref()Releases a reference on the given `GskTransform`.
If the reference was the last, the resources associated to the @self are
freed. -
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-