pub struct Matrix { /* private fields */ }
Expand description
A Matrix
specifies a transformation between user-space
and device coordinates.
The transformation is given by
x_device = x_user * matrix->xx + y_user * matrix->xy + matrix->x0;
y_device = x_user * matrix->yx + y_user * matrix->yy + matrix->y0;
GLib type: Inline allocated boxed type with stack copy semantics.
Implementations§
Source§impl Matrix
impl Matrix
pub fn as_ptr(&self) -> *mut PangoMatrix
Sourcepub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const PangoMatrix) -> &'a Self
pub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const PangoMatrix) -> &'a Self
Borrows the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow_mut<'a>(
ptr: *mut PangoMatrix,
) -> &'a mut Self
pub unsafe fn from_glib_ptr_borrow_mut<'a>( ptr: *mut PangoMatrix, ) -> &'a mut Self
Borrows the underlying C value mutably.
Source§impl Matrix
impl Matrix
Sourcepub fn font_scale_factor(&self) -> f64
pub fn font_scale_factor(&self) -> f64
Returns the scale factor of a matrix on the height of the font.
That is, the scale factor in the direction perpendicular to the
vector that the X coordinate is mapped to. If the scale in the X
coordinate is needed as well, use font_scale_factors()
.
§Returns
the scale factor of @self on the height of the font,
or 1.0 if @self is None
.
Sourcepub fn font_scale_factors(&self) -> (f64, f64)
pub fn font_scale_factors(&self) -> (f64, f64)
Calculates the scale factor of a matrix on the width and height of the font.
That is, @xscale is the scale factor in the direction of the X coordinate, and @yscale is the scale factor in the direction perpendicular to the vector that the X coordinate is mapped to.
Note that output numbers will always be non-negative.
§Returns
§xscale
output scale factor in the x direction
§yscale
output scale factor perpendicular to the x direction
Sourcepub fn slant_ratio(&self) -> f64
Available on crate feature v1_50
only.
pub fn slant_ratio(&self) -> f64
v1_50
only.Gets the slant ratio of a matrix.
For a simple shear matrix in the form:
1 λ
0 1
this is simply λ.
§Returns
the slant ratio of @self
Sourcepub fn rotate(&mut self, degrees: f64)
pub fn rotate(&mut self, degrees: f64)
Changes the transformation represented by @self to be the transformation given by first rotating by @degrees degrees counter-clockwise then applying the original transformation.
§degrees
degrees to rotate counter-clockwise
Sourcepub fn transform_distance(&self, dx: &mut f64, dy: &mut f64)
pub fn transform_distance(&self, dx: &mut f64, dy: &mut f64)
Transforms the distance vector (@dx,@dy) by @self.
This is similar to transform_point()
,
except that the translation components of the transformation
are ignored. The calculation of the returned vector is as follows:
dx2 = dx1 * xx + dy1 * xy;
dy2 = dx1 * yx + dy1 * yy;
Affine transformations are position invariant, so the same vector always transforms to the same vector. If (@x1,@y1) transforms to (@x2,@y2) then (@x1+@dx1,@y1+@dy1) will transform to (@x1+@dx2,@y1+@dy2) for all values of @x1 and @x2.
§dx
in/out X component of a distance vector
§dy
in/out Y component of a distance vector
Sourcepub fn transform_point(&self, x: &mut f64, y: &mut f64)
pub fn transform_point(&self, x: &mut f64, y: &mut f64)
Source§impl Matrix
impl Matrix
pub fn new(xx: f64, xy: f64, yx: f64, yy: f64, x0: f64, y0: f64) -> Self
Sourcepub fn transform_pixel_rectangle(&self, rect: &mut Rectangle)
pub fn transform_pixel_rectangle(&self, rect: &mut Rectangle)
First transforms the @rect using @self, then calculates the bounding box of the transformed rectangle.
This function is useful for example when you want to draw a rotated @PangoLayout to an image buffer, and want to know how large the image should be and how much you should shift the layout when rendering.
For better accuracy, you should use transform_rectangle()
on original rectangle in Pango units and convert to pixels afterward
using extents_to_pixels()
’s first argument.
§rect
in/out bounding box in device units
Sourcepub fn transform_rectangle(&self, rect: &mut Rectangle)
pub fn transform_rectangle(&self, rect: &mut Rectangle)
First transforms @rect using @self, then calculates the bounding box of the transformed rectangle.
This function is useful for example when you want to draw a rotated @PangoLayout to an image buffer, and want to know how large the image should be and how much you should shift the layout when rendering.
If you have a rectangle in device units (pixels), use
transform_pixel_rectangle()
.
If you have the rectangle in Pango units and want to convert to transformed pixel bounding box, it is more accurate to transform it first (using this function) and pass the result to pango_extents_to_pixels(), first argument, for an inclusive rounded rectangle. However, there are valid reasons that you may want to convert to pixels first and then transform, for example when the transformed coordinates may overflow in Pango units (large matrix translation for example).
§rect
in/out bounding box in Pango units
pub fn xx(&self) -> f64
pub fn xy(&self) -> f64
pub fn yx(&self) -> f64
pub fn yy(&self) -> f64
pub fn x0(&self) -> f64
pub fn y0(&self) -> f64
Trait Implementations§
Source§impl HasParamSpec for Matrix
impl HasParamSpec for Matrix
Source§impl StaticType for Matrix
impl StaticType for Matrix
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Copy for Matrix
Auto Trait Implementations§
impl Freeze for Matrix
impl RefUnwindSafe for Matrix
impl Send for Matrix
impl Sync for Matrix
impl Unpin for Matrix
impl UnwindSafe for Matrix
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§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> IntoClosureReturnValue for T
impl<T> IntoClosureReturnValue for T
fn into_closure_return_value(self) -> Option<Value>
Source§impl<T> PropertyGet for Twhere
T: HasParamSpec,
impl<T> PropertyGet for Twhere
T: HasParamSpec,
Source§impl<T> StaticTypeExt for Twhere
T: StaticType,
impl<T> StaticTypeExt for Twhere
T: StaticType,
Source§fn ensure_type()
fn ensure_type()
Source§impl<T> ToSendValue for T
impl<T> ToSendValue for T
Source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue
clone of self
.