[−][src]Struct paddle::Transform
A 2D transformation represented by a matrix
Transforms can be composed together through matrix multiplication, and are applied to Vectors through multiplication, meaning the notation used is the '*' operator. A property of matrix multiplication is that for some matrices A, B, C and vector V is
Transform = A * B * C
Transform * V = A * (B * (C * V))
This property allows encoding multiple transformations in a single matrix. A transformation that involves rotating a shape 30 degrees and then moving it six units up could be written as
use paddle::quicksilver_compat::{Transform, Vector}; let transform = Transform::rotate(30) * Transform::translate(Vector::new(0, -6));
and then applied to a Vector
transform * Vector::new(5, 5)
Implementations
impl Transform
[src]
pub const IDENTITY: Transform
[src]
The identity transformation
pub const fn from_array(array: [[f32; 3]; 3]) -> Transform
[src]
Create a Transform from an arbitrary matrix in a column-major matrix
pub fn rotate<T: Scalar>(angle: T) -> Transform
[src]
Create a rotation transformation
pub fn translate(vec: impl Into<Vector>) -> Transform
[src]
Create a translation transformation
pub fn scale(vec: impl Into<Vector>) -> Transform
[src]
Create a scale transformation
pub fn as_slice(&self) -> &[f32]
[src]
pub fn row_major(&self) -> Vec<f32>
[src]
#[must_use]pub fn inverse(&self) -> Transform
[src]
Find the inverse of a Transform
A transform's inverse will cancel it out when multplied with it, as seen below:
let transform = Transform::translate(Vector::new(4, 5)); let inverse = transform.inverse(); let vector = Vector::new(10, 10); assert_eq!(vector, transform * inverse * vector); assert_eq!(vector, inverse * transform * vector);
Trait Implementations
impl Clone for Transform
[src]
impl Copy for Transform
[src]
impl Debug for Transform
[src]
impl Default for Transform
[src]
impl<'de> Deserialize<'de> for Transform
[src]
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for Transform
[src]
impl Eq for Transform
[src]
impl Mul<Rectangle> for Transform
[src]
type Output = Rectangle
The resulting type after applying the *
operator.
pub fn mul(self, r: Rectangle) -> Rectangle
[src]
impl<T: Scalar> Mul<T> for Transform
[src]
Scale all of the internal values of the Transform matrix
Note this will NOT scale vectors multiplied by this transform, and generally you shouldn't need to use this.
type Output = Transform
The resulting type after applying the *
operator.
pub fn mul(self, other: T) -> Transform
[src]
impl Mul<Transform> for Transform
[src]
Concat two transforms A and B such that A * B * v = A * (B * v)
type Output = Transform
The resulting type after applying the *
operator.
pub fn mul(self, other: Transform) -> Transform
[src]
impl Mul<Transform> for Vector
[src]
type Output = Vector
The resulting type after applying the *
operator.
pub fn mul(self, t: Transform) -> Vector
[src]
impl Mul<Transform> for Rectangle
[src]
Apply Transform to all points of a Rectangle
type Output = Rectangle
The resulting type after applying the *
operator.
pub fn mul(self, t: Transform) -> Rectangle
[src]
impl Mul<Vector> for Transform
[src]
Transform a vector
type Output = Vector
The resulting type after applying the *
operator.
pub fn mul(self, other: Vector) -> Vector
[src]
impl PartialEq<Transform> for Transform
[src]
pub fn eq(&self, other: &Transform) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for Transform
[src]
Auto Trait Implementations
impl RefUnwindSafe for Transform
[src]
impl Send for Transform
[src]
impl Sync for Transform
[src]
impl Unpin for Transform
[src]
impl UnwindSafe for Transform
[src]
Blanket Implementations
impl<T> Activity for T where
T: Any,
[src]
T: Any,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,