Trait lux::modifiers::Transform
[−]
[src]
pub trait Transform {
fn current_matrix(&self) -> &[[Float; 4]; 4];
fn current_matrix_mut(&mut self) -> &mut [[Float; 4]; 4];
fn apply_matrix(&mut self, other: [[Float; 4]; 4]) -> &mut Self { ... }
fn translate(&mut self, dx: Float, dy: Float) -> &mut Self { ... }
fn scale(&mut self, sx: Float, sy: Float) -> &mut Self { ... }
fn shear(&mut self, sx: Float, sy: Float) -> &mut Self { ... }
fn rotate(&mut self, theta: Float) -> &mut Self { ... }
fn rotate_around(&mut self, point: (Float, Float), theta: Float) -> &mut Self { ... }
fn with_matrix<F, R>(&mut self, f: F) -> R where F: FnOnce(&mut Self) -> R { ... }
fn with_rotation<F, R>(&mut self, rotation: Float, f: F) -> R where F: FnOnce(&mut Self) -> R { ... }
fn with_translate<F, R>(&mut self, dx: Float, dy: Float, f: F) -> R where F: FnOnce(&mut Self) -> R { ... }
fn with_scale<F, R>(&mut self, scale_x: Float, scale_y: Float, f: F) -> R where F: FnOnce(&mut Self) -> R { ... }
fn with_shear<F, R>(&mut self, sx: Float, sy: Float, f: F) -> R where F: FnOnce(&mut Self) -> R { ... }
fn with_rotate_around<F, R>(&mut self, point: (Float, Float), theta: Float, f: F) -> R where F: FnOnce(&mut Self) -> R { ... }
}A trait for objects that can be "transformed". Transformations include scaling, translation, shearing, rotating, and general purpose matrix application.
Required Methods
fn current_matrix(&self) -> &[[Float; 4]; 4]
Return a reference to the current matrix.
fn current_matrix_mut(&mut self) -> &mut [[Float; 4]; 4]
Return a mutible reference to the current matrix.
Provided Methods
fn apply_matrix(&mut self, other: [[Float; 4]; 4]) -> &mut Self
Multiplies the current matrix against another.
self = self * other.
fn translate(&mut self, dx: Float, dy: Float) -> &mut Self
Applies a translation transformation to the matrix.
fn scale(&mut self, sx: Float, sy: Float) -> &mut Self
Applies a scaling transformation to the matrix.
fn shear(&mut self, sx: Float, sy: Float) -> &mut Self
Applies a shearing transformation to the matrix.
fn rotate(&mut self, theta: Float) -> &mut Self
Applies a rotation transformation to the matrix.
fn rotate_around(&mut self, point: (Float, Float), theta: Float) -> &mut Self
Combines rotation with translation to effectively rotate around a given point.
fn with_matrix<F, R>(&mut self, f: F) -> R where F: FnOnce(&mut Self) -> R
Used when you want to make several successive calls to transformations on a single stacked matrix.
Example: lux.with_matrix(|lux| { lux.translate(5.0, 10.0); lux.rotate(3.14 / 2.0); lux.scale(2.0, 1.0); // do other stuff });
fn with_rotation<F, R>(&mut self, rotation: Float, f: F) -> R where F: FnOnce(&mut Self) -> R
Similar to with_matrix but with a rotation applied
for the duration of the closure.
fn with_translate<F, R>(&mut self, dx: Float, dy: Float, f: F) -> R where F: FnOnce(&mut Self) -> R
Similar to with_matrix but with a translation applied
for the duration of the closure.
fn with_scale<F, R>(&mut self, scale_x: Float, scale_y: Float, f: F) -> R where F: FnOnce(&mut Self) -> R
Similar to with_matrix but with a scale applied
for the duration of the closure.
fn with_shear<F, R>(&mut self, sx: Float, sy: Float, f: F) -> R where F: FnOnce(&mut Self) -> R
Similar to with_matrix but with a shear applied
for the duration of the closure.
fn with_rotate_around<F, R>(&mut self, point: (Float, Float), theta: Float, f: F) -> R where F: FnOnce(&mut Self) -> R
Similar to with_matrix but with rotate_around applied
for the duration of the closure.
Implementors
impl<'a, C> Transform for Rectangle<'a, C>impl<'a, C> Transform for Ellipse<'a, C>impl Transform for [[Float; 4]; 4]impl Transform for Frameimpl<'a, D> Transform for DrawableTexture<'a, D> where D: HasDisplay + HasProgramsimpl<'a, A, B: AsRef<str>> Transform for ContainedText<'a, A, B> where A: HasDisplay + HasFontCache + Canvas