Struct nanovg::Transform [−][src]
Represents a transformation in 2D space.
A transformation is a combination of translation (aka. position), skew and scale or
translation and rotation; implemented as a column-major matrix in the following form:
[a c e] - indices [0 2 4]
[b d f] - indices [1 3 5]
[0 0 1] - only theoretical / does not really exist. Logically it is always [0 0 1].
Fields
matrix: [f32; 6]
Methods
impl Transform
[src]
impl Transform
pub fn new() -> Self
[src]
pub fn new() -> Self
Construct a new transform with an identity matrix.
pub fn absolute(self) -> Self
[src]
pub fn absolute(self) -> Self
Set flag on this transform to use it in absolute coordinate space. Only applies to text.
pub fn relative(self) -> Self
[src]
pub fn relative(self) -> Self
Set flag on this transform to use it in local (relative) coordinate space. Only applies to text.
pub fn with_translation(self, x: f32, y: f32) -> Self
[src]
pub fn with_translation(self, x: f32, y: f32) -> Self
Set the translation of the transform.
pub fn with_scale(self, x: f32, y: f32) -> Self
[src]
pub fn with_scale(self, x: f32, y: f32) -> Self
Set the scale of the transform.
pub fn with_skew(self, x: f32, y: f32) -> Self
[src]
pub fn with_skew(self, x: f32, y: f32) -> Self
Set the skew of the transform.
pub fn with_rotation(self, theta: f32) -> Self
[src]
pub fn with_rotation(self, theta: f32) -> Self
Set the rotation of the transform.
pub fn translate(self, x: f32, y: f32) -> Self
[src]
pub fn translate(self, x: f32, y: f32) -> Self
Translate transform by x and y.
pub fn rotate(self, angle: f32) -> Self
[src]
pub fn rotate(self, angle: f32) -> Self
Rotate transform with spcified angle.
pub fn skew_x(self, angle: f32) -> Self
[src]
pub fn skew_x(self, angle: f32) -> Self
Skew transform along x axis with specified angle.
pub fn skew_y(self, angle: f32) -> Self
[src]
pub fn skew_y(self, angle: f32) -> Self
Skew transform along y axis with specified angle.
pub fn scale(self, x: f32, y: f32) -> Self
[src]
pub fn scale(self, x: f32, y: f32) -> Self
Scale transform along x and y.
pub fn transform_point(&self, (x, y): (f32, f32)) -> (f32, f32)
[src]
pub fn transform_point(&self, (x, y): (f32, f32)) -> (f32, f32)
Transforms a point with this transform. Returns transformed point (x, y).
pub fn try_inverse(&self) -> Option<Transform>
[src]
pub fn try_inverse(&self) -> Option<Transform>
Inverses this transform. Returns inversed copy or None if inversion fails.
Trait Implementations
impl Clone for Transform
[src]
impl Clone for Transform
fn clone(&self) -> Transform
[src]
fn clone(&self) -> Transform
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for Transform
[src]
impl Copy for Transform
impl Debug for Transform
[src]
impl Debug for Transform
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Mul for Transform
[src]
impl Mul for Transform
Implementation of multiplication Trait for Transform. The order in which you multiplicate matters (you are multiplicating matrices)