`pub struct Transform { /* private fields */ }`

## Expand description

`Transform`

is an object to describe transform matrices.

Unlike `graphene::Matrix`

, `Transform`

retains the steps in how
a transform was constructed, and allows inspecting them. It is modeled
after the way CSS describes transforms.

`Transform`

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.

GLib type: Shared boxed type with reference counted clone semantics.

## Implementations§

source§### impl Transform

### impl Transform

source#### pub fn as_ptr(&self) -> *mut GskTransform

#### pub fn as_ptr(&self) -> *mut GskTransform

Return the inner pointer to the underlying C value.

source#### pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GskTransform) -> &Self

#### pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GskTransform) -> &Self

Borrows the underlying C value.

source§### impl Transform

### impl Transform

source#### pub fn category(&self) -> TransformCategory

#### pub fn category(&self) -> TransformCategory

source#### pub fn perspective(self, depth: f32) -> Transform

#### pub fn perspective(self, depth: f32) -> 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 @self. Use `Gsk::Transform::ref()`

first
if you want to keep it around.

###### §`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

source#### pub fn to_2d(&self) -> (f32, f32, f32, f32, f32, f32)

#### pub fn to_2d(&self) -> (f32, f32, f32, f32, f32, f32)

Converts a `Transform`

to a 2D transformation matrix.

@self must be a 2D transformation. If you are not
sure, use gsk_transform_get_category() >=
`TransformCategory::_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 `Transform`

and a matrix type from other 2D drawing libraries, in particular
Cairo.

##### §Returns

###### §`out_xx`

return location for the xx member

###### §`out_yx`

return location for the yx member

###### §`out_xy`

return location for the xy member

###### §`out_yy`

return location for the yy member

###### §`out_dx`

return location for the x0 member

###### §`out_dy`

return location for the y0 member

source#### pub fn to_2d_components(&self) -> (f32, f32, f32, f32, f32, f32, f32)

Available on **crate feature **`v4_6`

only.

#### pub fn to_2d_components(&self) -> (f32, f32, f32, f32, f32, f32, f32)

**crate feature**only.

`v4_6`

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

`gsk_transform_get_category() >= [`TransformCategory::_2d`][crate::TransformCategory::_2d]`

to check.

##### §Returns

###### §`out_skew_x`

return location for the skew factor in the x direction

###### §`out_skew_y`

return location for the skew factor in the y direction

###### §`out_scale_x`

return location for the scale factor in the x direction

###### §`out_scale_y`

return location for the scale factor in the y direction

###### §`out_angle`

return location for the rotation angle

###### §`out_dx`

return location for the translation in the x direction

###### §`out_dy`

return location for the translation in the y direction

source#### pub fn to_affine(&self) -> (f32, f32, f32, f32)

#### pub fn to_affine(&self) -> (f32, f32, f32, f32)

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

`gsk_transform_get_category() >= [`TransformCategory::_2dAffine`][crate::TransformCategory::_2dAffine]`

to check.

##### §Returns

###### §`out_scale_x`

return location for the scale factor in the x direction

###### §`out_scale_y`

return location for the scale factor in the y direction

###### §`out_dx`

return location for the translation in the x direction

###### §`out_dy`

return location for the translation in the y direction

source#### pub fn to_translate(&self) -> (f32, f32)

#### pub fn to_translate(&self) -> (f32, f32)

Converts a `Transform`

to a translation operation.

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

`gsk_transform_get_category() >= [`TransformCategory::_2dTranslate`][crate::TransformCategory::_2dTranslate]`

to check.

##### §Returns

###### §`out_dx`

return location for the translation in the x direction

###### §`out_dy`

return location for the translation in the y direction

source#### pub fn transform_bounds(&self, rect: &Rect) -> Rect

#### pub fn transform_bounds(&self, rect: &Rect) -> Rect

Transforms a `graphene::Rect`

using the given transform @self.

The result is the bounding box containing the coplanar quad.

###### §`rect`

##### §Returns

###### §`out_rect`

return location for the bounds of the transformed rectangle

source#### pub fn transform_point(&self, point: &Point) -> Point

#### pub fn transform_point(&self, point: &Point) -> Point

Transforms a `graphene::Point`

using the given transform @self.

###### §`point`

##### §Returns

###### §`out_point`

return location for the transformed point

source§### impl Transform

### impl Transform

source#### pub fn parse(string: impl IntoGStr) -> Result<Self, BoolError>

#### pub fn parse(string: impl IntoGStr) -> Result<Self, BoolError>

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

Strings printed via `to_str()`

can be read in again successfully using this function.

If @string does not describe a valid transform, `false`

is
returned and `None`

is put in @out_transform.

###### §`string`

the string to parse

##### §Returns

`true`

if @string described a valid transform.

###### §`out_transform`

The location to put the transform in

source#### pub fn invert(self) -> Result<Self, BoolError>

#### pub fn invert(self) -> Result<Self, BoolError>

Inverts the given transform.

If @self is not invertible, `None`

is returned.
Note that inverting `None`

also returns `None`

, which is
the correct inverse of `None`

. If you need to differentiate
between those cases, you should check @self is not `None`

before calling this function.

This function consumes @self. Use `Gsk::Transform::ref()`

first
if you want to keep it around.

##### §Returns

The inverted transform

source#### pub fn scale(self, factor_x: f32, factor_y: f32) -> Self

#### pub fn scale(self, factor_x: f32, factor_y: f32) -> Self

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

Use `scale_3d()`

to scale in all 3 dimensions.

This function consumes @self. Use `Gsk::Transform::ref()`

first
if you want to keep it around.

###### §`factor_x`

scaling factor on the X axis

###### §`factor_y`

scaling factor on the Y axis

##### §Returns

The new transform

source#### pub fn translate_3d(self, point: &Point3D) -> Self

#### pub fn translate_3d(self, point: &Point3D) -> Self

## Trait Implementations§

source§### impl HasParamSpec for Transform

### impl HasParamSpec for Transform

source§### impl Ord for Transform

### impl Ord for Transform

source§### impl PartialEq for Transform

### impl PartialEq for Transform

source§### impl PartialOrd for Transform

### impl PartialOrd for Transform

1.0.0 · source§#### fn le(&self, other: &Rhs) -> bool

#### fn le(&self, other: &Rhs) -> bool

`self`

and `other`

) and is used by the `<=`

operator. Read moresource§### impl StaticType for Transform

### impl StaticType for Transform

source§#### fn static_type() -> Type

#### fn static_type() -> Type

`Self`

.### impl Eq for Transform

## Auto Trait Implementations§

### impl Freeze for Transform

### impl RefUnwindSafe for Transform

### impl !Send for Transform

### impl !Sync for Transform

### impl Unpin for Transform

### impl UnwindSafe for Transform

## Blanket Implementations§

source§### impl<T> BorrowMut<T> for Twhere
T: ?Sized,

### impl<T> BorrowMut<T> for Twhere
T: ?Sized,

source§#### fn borrow_mut(&mut self) -> &mut T

#### fn borrow_mut(&mut self) -> &mut T

source§### impl<T> CloneToUninit for Twhere
T: Clone,

### impl<T> CloneToUninit for Twhere
T: Clone,

source§#### default unsafe fn clone_to_uninit(&self, dst: *mut T)

#### default unsafe fn clone_to_uninit(&self, dst: *mut T)

`clone_to_uninit`

)