pub struct PdfMatrix { /* private fields */ }Expand description
Six floating-point values, labelled a, b, c, d, e, and f, that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Applying the matrix to any transformable object containing a set_matrix() function - such as
a page, clip path, individual page object, or page object group - will result in a
transformation of that object. Depending on the values specified in the matrix, the object
can be moved, scaled, rotated, or skewed.
It is rare that a matrix needs to be used directly. All transformable objects provide convenient and expressive access to the most commonly used transformation operations without requiring a matrix.
However, a matrix can be convenient when the same transformation values need to be applied to a large set of transformable objects.
An overview of PDF transformation matrices can be found in the PDF Reference Manual version 1.7 on page 204; a detailed description can be founded in section 4.2.3 on page 207.
Implementations§
Source§impl PdfMatrix
impl PdfMatrix
Sourcepub const IDENTITY: PdfMatrix
pub const IDENTITY: PdfMatrix
A PdfMatrix object with matrix values a and d set to 1.0 and all other values set to 0.0.
Sourcepub const fn new(
a: PdfMatrixValue,
b: PdfMatrixValue,
c: PdfMatrixValue,
d: PdfMatrixValue,
e: PdfMatrixValue,
f: PdfMatrixValue,
) -> Self
pub const fn new( a: PdfMatrixValue, b: PdfMatrixValue, c: PdfMatrixValue, d: PdfMatrixValue, e: PdfMatrixValue, f: PdfMatrixValue, ) -> Self
Creates a new PdfMatrix with the given matrix values.
Sourcepub const fn zero() -> Self
pub const fn zero() -> Self
Creates a new PdfMatrix object with all matrix values set to 0.0.
The return value of this function is identical to the constant PdfMatrix::ZERO.
Sourcepub const fn identity() -> Self
pub const fn identity() -> Self
Creates a new PdfMatrix object with matrix values a and d set to 1.0 and all other values set to 0.0.
The return value of this function is identical to the constant PdfMatrix::IDENTITY.
Sourcepub fn a(&self) -> PdfMatrixValue
pub fn a(&self) -> PdfMatrixValue
Returns the value of a, the first of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn set_a(&mut self, a: PdfMatrixValue)
pub fn set_a(&mut self, a: PdfMatrixValue)
Sets the value of a, the first of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn b(&self) -> PdfMatrixValue
pub fn b(&self) -> PdfMatrixValue
Returns the value of b, the second of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn set_b(&mut self, b: PdfMatrixValue)
pub fn set_b(&mut self, b: PdfMatrixValue)
Sets the value of b, the second of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn c(&self) -> PdfMatrixValue
pub fn c(&self) -> PdfMatrixValue
Returns the value of c, the third of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn set_c(&mut self, c: PdfMatrixValue)
pub fn set_c(&mut self, c: PdfMatrixValue)
Sets the value of c, the third of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn d(&self) -> PdfMatrixValue
pub fn d(&self) -> PdfMatrixValue
Returns the value of d, the fourth of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn set_d(&mut self, d: PdfMatrixValue)
pub fn set_d(&mut self, d: PdfMatrixValue)
Sets the value of d, the fourth of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn e(&self) -> PdfMatrixValue
pub fn e(&self) -> PdfMatrixValue
Returns the value of e, the fifth of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn set_e(&mut self, e: PdfMatrixValue)
pub fn set_e(&mut self, e: PdfMatrixValue)
Sets the value of e, the fifth of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn f(&self) -> PdfMatrixValue
pub fn f(&self) -> PdfMatrixValue
Returns the value of f, the sixth of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn set_f(&mut self, f: PdfMatrixValue)
pub fn set_f(&mut self, f: PdfMatrixValue)
Sets the value of f, the sixth of six floating-point values that represent
the six configurable elements of a nine-element 3x3 PDF transformation matrix.
Sourcepub fn determinant(&self) -> PdfMatrixValue
pub fn determinant(&self) -> PdfMatrixValue
Returns the determinant of this PdfMatrix.
Sourcepub fn transform(
self,
a: PdfMatrixValue,
b: PdfMatrixValue,
c: PdfMatrixValue,
d: PdfMatrixValue,
e: PdfMatrixValue,
f: PdfMatrixValue,
) -> Result<Self, PdfiumError>
pub fn transform( self, a: PdfMatrixValue, b: PdfMatrixValue, c: PdfMatrixValue, d: PdfMatrixValue, e: PdfMatrixValue, f: PdfMatrixValue, ) -> Result<Self, PdfiumError>
Applies the given transformation, expressed as six values representing the six configurable elements of a nine-element 3x3 PDF transformation matrix, to this PdfMatrix.
To move, scale, rotate, or skew this PdfMatrix, consider using one or more of the following functions. Internally they all use Self::transform(), but are probably easier to use (and certainly clearer in their intent) in most situations.
- Self::translate(): changes the position of this PdfMatrix.
- Self::scale(): changes the size of this PdfMatrix.
- this PdfMatrix horizontally around its origin.
- this PdfMatrix vertically around its origin.
- Self::rotate_clockwise_degrees(), Self::rotate_counter_clockwise_degrees(), Self::rotate_clockwise_radians(), Self::rotate_counter_clockwise_radians(): rotates this PdfMatrix around its origin.
- Self::skew_degrees(), Self::skew_radians(): skews this PdfMatrix relative to its axes.
The order in which transformations are applied is significant. For example, the result of rotating then translating an object may be vastly different from translating then rotating the same object.
An overview of PDF transformation matrices can be found in the PDF Reference Manual version 1.7 on page 204; a detailed description can be found in section 4.2.3 on page 207.
Sourcepub fn apply_matrix(self, matrix: PdfMatrix) -> Result<Self, PdfiumError>
pub fn apply_matrix(self, matrix: PdfMatrix) -> Result<Self, PdfiumError>
Sourcepub fn reset_matrix(self, matrix: PdfMatrix) -> Result<Self, PdfiumError>
pub fn reset_matrix(self, matrix: PdfMatrix) -> Result<Self, PdfiumError>
Sourcepub fn reset_matrix_to_identity(self) -> Result<Self, PdfiumError>
pub fn reset_matrix_to_identity(self) -> Result<Self, PdfiumError>
Resets the transformation matrix for this PdfMatrix to the identity matrix, undoing any previously applied transformations.
Sourcepub fn translate(
self,
delta_x: PdfPoints,
delta_y: PdfPoints,
) -> Result<Self, PdfiumError>
pub fn translate( self, delta_x: PdfPoints, delta_y: PdfPoints, ) -> Result<Self, PdfiumError>
Moves the origin of this PdfMatrix by the given horizontal and vertical delta distances.
Sourcepub fn scale(
self,
horizontal_scale_factor: PdfMatrixValue,
vertical_scale_factor: PdfMatrixValue,
) -> Result<Self, PdfiumError>
pub fn scale( self, horizontal_scale_factor: PdfMatrixValue, vertical_scale_factor: PdfMatrixValue, ) -> Result<Self, PdfiumError>
Changes the size of this PdfMatrix, scaling it by the given horizontal and vertical scale factors.
Sourcepub fn flip_horizontally(self) -> Result<Self, PdfiumError>
pub fn flip_horizontally(self) -> Result<Self, PdfiumError>
Flips this PdfMatrix horizontally around its origin by applying a horizontal scale factor of -1.
Sourcepub fn flip_vertically(self) -> Result<Self, PdfiumError>
pub fn flip_vertically(self) -> Result<Self, PdfiumError>
Flips this PdfMatrix vertically around its origin by applying a vertical scale factor of -1.
Sourcepub fn reflect(self) -> Result<Self, PdfiumError>
pub fn reflect(self) -> Result<Self, PdfiumError>
Reflects this PdfMatrix by flipping it both horizontally and vertically around its origin.
Sourcepub fn rotate_counter_clockwise_degrees(
self,
degrees: PdfMatrixValue,
) -> Result<Self, PdfiumError>
pub fn rotate_counter_clockwise_degrees( self, degrees: PdfMatrixValue, ) -> Result<Self, PdfiumError>
Rotates this PdfMatrix counter-clockwise by the given number of degrees.
Sourcepub fn rotate_clockwise_degrees(
self,
degrees: PdfMatrixValue,
) -> Result<Self, PdfiumError>
pub fn rotate_clockwise_degrees( self, degrees: PdfMatrixValue, ) -> Result<Self, PdfiumError>
Rotates this PdfMatrix clockwise by the given number of degrees.
Sourcepub fn rotate_counter_clockwise_radians(
self,
radians: PdfMatrixValue,
) -> Result<Self, PdfiumError>
pub fn rotate_counter_clockwise_radians( self, radians: PdfMatrixValue, ) -> Result<Self, PdfiumError>
Rotates this PdfMatrix counter-clockwise by the given number of radians.
Sourcepub fn rotate_clockwise_radians(
self,
radians: PdfMatrixValue,
) -> Result<Self, PdfiumError>
pub fn rotate_clockwise_radians( self, radians: PdfMatrixValue, ) -> Result<Self, PdfiumError>
Rotates this PdfMatrix clockwise by the given number of radians.
Sourcepub fn skew_degrees(
self,
x_axis_skew: PdfMatrixValue,
y_axis_skew: PdfMatrixValue,
) -> Result<Self, PdfiumError>
pub fn skew_degrees( self, x_axis_skew: PdfMatrixValue, y_axis_skew: PdfMatrixValue, ) -> Result<Self, PdfiumError>
Skews the axes of this PdfMatrix by the given angles in degrees.
Sourcepub fn skew_radians(
self,
x_axis_skew: PdfMatrixValue,
y_axis_skew: PdfMatrixValue,
) -> Result<Self, PdfiumError>
pub fn skew_radians( self, x_axis_skew: PdfMatrixValue, y_axis_skew: PdfMatrixValue, ) -> Result<Self, PdfiumError>
Skews the axes of this PdfMatrix by the given angles in radians.
Sourcepub fn matrix(&self) -> Result<PdfMatrix, PdfiumError>
pub fn matrix(&self) -> Result<PdfMatrix, PdfiumError>
Returns the transformation matrix currently applied to this PdfMatrix.
Sourcepub fn get_translation(&self) -> (PdfPoints, PdfPoints)
pub fn get_translation(&self) -> (PdfPoints, PdfPoints)
Returns the current horizontal and vertical translation of the origin of this PdfMatrix.
Sourcepub fn get_horizontal_translation(&self) -> PdfPoints
pub fn get_horizontal_translation(&self) -> PdfPoints
Returns the current horizontal translation of the origin of this PdfMatrix.
Sourcepub fn get_vertical_translation(&self) -> PdfPoints
pub fn get_vertical_translation(&self) -> PdfPoints
Returns the current vertical translation of the origin of this PdfMatrix.
Sourcepub fn get_scale(&self) -> (PdfMatrixValue, PdfMatrixValue)
pub fn get_scale(&self) -> (PdfMatrixValue, PdfMatrixValue)
Returns the current horizontal and vertical scale factors applied to this PdfMatrix.
Sourcepub fn get_horizontal_scale(&self) -> PdfMatrixValue
pub fn get_horizontal_scale(&self) -> PdfMatrixValue
Returns the current horizontal scale factor applied to this PdfMatrix.
Sourcepub fn get_vertical_scale(&self) -> PdfMatrixValue
pub fn get_vertical_scale(&self) -> PdfMatrixValue
Returns the current vertical scale factor applied to this PdfMatrix.
Sourcepub fn get_rotation_counter_clockwise_degrees(&self) -> PdfMatrixValue
pub fn get_rotation_counter_clockwise_degrees(&self) -> PdfMatrixValue
Returns the counter-clockwise rotation applied to this PdfMatrix, in degrees.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Sourcepub fn get_rotation_clockwise_degrees(&self) -> PdfMatrixValue
pub fn get_rotation_clockwise_degrees(&self) -> PdfMatrixValue
Returns the clockwise rotation applied to this PdfMatrix, in degrees.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Sourcepub fn get_rotation_counter_clockwise_radians(&self) -> PdfMatrixValue
pub fn get_rotation_counter_clockwise_radians(&self) -> PdfMatrixValue
Returns the counter-clockwise rotation applied to this PdfMatrix, in radians.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Sourcepub fn get_rotation_clockwise_radians(&self) -> PdfMatrixValue
pub fn get_rotation_clockwise_radians(&self) -> PdfMatrixValue
Returns the clockwise rotation applied to this PdfMatrix, in radians.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Sourcepub fn get_skew_degrees(&self) -> (PdfMatrixValue, PdfMatrixValue)
pub fn get_skew_degrees(&self) -> (PdfMatrixValue, PdfMatrixValue)
Returns the current x axis and y axis skew angles applied to this PdfMatrix, in degrees.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Sourcepub fn get_x_axis_skew_degrees(&self) -> PdfMatrixValue
pub fn get_x_axis_skew_degrees(&self) -> PdfMatrixValue
Returns the current x axis skew angle applied to this PdfMatrix, in degrees.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Sourcepub fn get_y_axis_skew_degrees(&self) -> PdfMatrixValue
pub fn get_y_axis_skew_degrees(&self) -> PdfMatrixValue
Returns the current y axis skew applied to this PdfMatrix, in degrees.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Sourcepub fn get_skew_radians(&self) -> (PdfMatrixValue, PdfMatrixValue)
pub fn get_skew_radians(&self) -> (PdfMatrixValue, PdfMatrixValue)
Returns the current x axis and y axis skew angles applied to this PdfMatrix, in radians.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Sourcepub fn get_x_axis_skew_radians(&self) -> PdfMatrixValue
pub fn get_x_axis_skew_radians(&self) -> PdfMatrixValue
Returns the current x axis skew applied to this PdfMatrix, in radians.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Sourcepub fn get_y_axis_skew_radians(&self) -> PdfMatrixValue
pub fn get_y_axis_skew_radians(&self) -> PdfMatrixValue
Returns the current y axis skew applied to this PdfMatrix, in radians.
If the object is both rotated and skewed, the return value of this function will reflect the combined operation.
Trait Implementations§
impl Copy for PdfMatrix
impl Eq for PdfMatrix
Auto Trait Implementations§
impl Freeze for PdfMatrix
impl RefUnwindSafe for PdfMatrix
impl Send for PdfMatrix
impl Sync for PdfMatrix
impl Unpin for PdfMatrix
impl UnwindSafe for PdfMatrix
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more