Struct flo_canvas::Transform2D
source · pub struct Transform2D(pub [[f32; 3]; 3]);
Expand description
Represents a 2D affine transformation matrix
Tuple Fields§
§0: [[f32; 3]; 3]
Implementations§
source§impl Transform2D
impl Transform2D
sourcepub fn transform_point(&self, x: f32, y: f32) -> (f32, f32)
pub fn transform_point(&self, x: f32, y: f32) -> (f32, f32)
Applies this transformation to a point, returning the transformed point
sourcepub fn identity() -> Transform2D
pub fn identity() -> Transform2D
Creates the identity transform
sourcepub fn translate(x: f32, y: f32) -> Transform2D
pub fn translate(x: f32, y: f32) -> Transform2D
Creates a translation transformation
sourcepub fn scale(scale_x: f32, scale_y: f32) -> Transform2D
pub fn scale(scale_x: f32, scale_y: f32) -> Transform2D
Creates a scaling transformation
sourcepub fn rotate_degrees(degrees: f32) -> Transform2D
pub fn rotate_degrees(degrees: f32) -> Transform2D
Creates a transformation that’s a rotation in degrees
sourcepub fn rotate(radians: f32) -> Transform2D
pub fn rotate(radians: f32) -> Transform2D
Creates a rotation transformation
sourcepub fn invert(&self) -> Option<Transform2D>
pub fn invert(&self) -> Option<Transform2D>
Returns an inverted Transform2D
Trait Implementations§
source§impl CanvasEncoding<String> for Transform2D
impl CanvasEncoding<String> for Transform2D
source§fn encode_canvas(&self, append_to: &mut String)
fn encode_canvas(&self, append_to: &mut String)
Encodes this item by appending it to the specified string
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<'de> Deserialize<'de> for Transform2D
impl<'de> Deserialize<'de> for Transform2D
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<SpriteTransform> for Transform2D
impl From<SpriteTransform> for Transform2D
source§fn from(sprite_transform: SpriteTransform) -> Transform2D
fn from(sprite_transform: SpriteTransform) -> Transform2D
Converts to this type from the input type.
source§impl Mul<&Transform2D> for &Transform2D
impl Mul<&Transform2D> for &Transform2D
§type Output = Transform2D
type Output = Transform2D
The resulting type after applying the
*
operator.source§fn mul(self, other: &Transform2D) -> Transform2D
fn mul(self, other: &Transform2D) -> Transform2D
Performs the
*
operation. Read moresource§impl Mul<Transform2D> for Transform2D
impl Mul<Transform2D> for Transform2D
§type Output = Transform2D
type Output = Transform2D
The resulting type after applying the
*
operator.source§fn mul(self, other: Transform2D) -> Transform2D
fn mul(self, other: Transform2D) -> Transform2D
Performs the
*
operation. Read moresource§impl PartialEq<Transform2D> for Transform2D
impl PartialEq<Transform2D> 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 ==
.