Struct femtovg::Transform2D
source · pub struct Transform2D(pub [f32; 6]);
Expand description
2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, or scaling.
Tuple Fields§
§0: [f32; 6]
Implementations§
source§impl Transform2D
impl Transform2D
sourcepub fn identity() -> Self
pub fn identity() -> Self
Creates an identity transformation with no translation, rotation or scaling applied.
sourcepub fn new(&mut self, a: f32, b: f32, c: f32, d: f32, e: f32, f: f32) -> Self
pub fn new(&mut self, a: f32, b: f32, c: f32, d: f32, e: f32, f: f32) -> Self
Creates a new transformation matrix.
The parameters are interpreted as matrix as follows: [a c e] [b d f] [0 0 1]
pub fn new_translation(x: f32, y: f32) -> Self
pub fn translate(&mut self, tx: f32, ty: f32)
pub fn scale(&mut self, sx: f32, sy: f32)
pub fn rotate(&mut self, a: f32)
pub fn skew_x(&mut self, a: f32)
pub fn skew_y(&mut self, a: f32)
pub fn multiply(&mut self, other: &Self)
pub fn premultiply(&mut self, other: &Self)
pub fn inverse(&mut self)
pub fn inversed(&self) -> Self
pub fn transform_point(&self, sx: f32, sy: f32) -> (f32, f32)
pub fn average_scale(&self) -> f32
pub fn to_mat3x4(self) -> [f32; 12]
pub fn cache_key(&self) -> u64
Trait Implementations§
source§impl Clone for Transform2D
impl Clone for Transform2D
source§fn clone(&self) -> Transform2D
fn clone(&self) -> Transform2D
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Transform2D
impl Debug for Transform2D
source§impl Default for Transform2D
impl Default for Transform2D
source§impl Index<usize> for Transform2D
impl Index<usize> for Transform2D
source§impl IndexMut<usize> for Transform2D
impl IndexMut<usize> for Transform2D
source§impl PartialEq for Transform2D
impl PartialEq for Transform2D
source§fn eq(&self, other: &Transform2D) -> bool
fn eq(&self, other: &Transform2D) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for Transform2D
impl PartialOrd for Transform2D
source§fn partial_cmp(&self, other: &Transform2D) -> Option<Ordering>
fn partial_cmp(&self, other: &Transform2D) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Transform2D
impl StructuralPartialEq for Transform2D
Auto Trait Implementations§
impl Freeze for Transform2D
impl RefUnwindSafe for Transform2D
impl Send for Transform2D
impl Sync for Transform2D
impl Unpin for Transform2D
impl UnwindSafe for Transform2D
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
Mutably borrows from an owned value. Read more