#[repr(C)]pub struct Affine([f64; 6]);
Expand description
A 2D affine transform. Derived from kurbo.
Tuple Fields§
§0: [f64; 6]
Implementations§
§impl Affine
impl Affine
pub const FLIP_Y: Affine = _
pub const FLIP_Y: Affine = _
A transform that is flipped on the y-axis. Useful for converting between y-up and y-down spaces.
pub const fn new(c: [f64; 6]) -> Affine
pub const fn new(c: [f64; 6]) -> Affine
Construct an affine transform from coefficients.
If the coefficients are (a, b, c, d, e, f)
, then the resulting
transformation represents this augmented matrix:
| a c e |
| b d f |
| 0 0 1 |
Note that this convention is transposed from PostScript and
Direct2D, but is consistent with the
Wikipedia
formulation of affine transformation as augmented matrix. The
idea is that (A * B) * v == A * (B * v)
, where *
is the
Mul
trait.
pub const fn scale_non_uniform(s_x: f64, s_y: f64) -> Affine
pub const fn scale_non_uniform(s_x: f64, s_y: f64) -> Affine
An affine transform representing non-uniform scaling with different scale values for x and y
pub fn rotate(th: f64) -> Affine
pub fn rotate(th: f64) -> Affine
An affine transform representing rotation.
The convention for rotation is that a positive angle rotates a positive X direction into positive Y. Thus, in a Y-down coordinate system (as is common for graphics), it is a clockwise rotation, and in Y-up (traditional for math), it is anti-clockwise.
The angle, th
, is expressed in radians.
pub fn map_unit_square(rect: Rect) -> Affine
pub fn map_unit_square(rect: Rect) -> Affine
Creates an affine transformation that takes the unit square to the given rectangle.
Useful when you want to draw into the unit square but have your output fill any rectangle.
In this case push the Affine
onto the transform stack.
pub fn determinant(self) -> f64
pub fn determinant(self) -> f64
Compute the determinant of this transform.
pub fn inverse(self) -> Affine
pub fn inverse(self) -> Affine
Compute the inverse transform.
Produces NaN values when the determinant is zero.
pub fn transform_rect_bbox(self, rect: Rect) -> Rect
pub fn transform_rect_bbox(self, rect: Rect) -> Rect
Compute the bounding box of a transformed rectangle.
Returns the minimal Rect
that encloses the given Rect
after affine transformation.
If the transform is axis-aligned, then this bounding box is “tight”, in other words the
returned Rect
is the transformed rectangle.
The returned rectangle always has non-negative width and height.
Trait Implementations§
§impl<'de> Deserialize<'de> for Affine
impl<'de> Deserialize<'de> for Affine
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Affine, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Affine, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl MulAssign for Affine
impl MulAssign for Affine
§fn mul_assign(&mut self, other: Affine)
fn mul_assign(&mut self, other: Affine)
*=
operation. Read more§impl Serialize for Affine
impl Serialize for Affine
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Affine
impl StructuralPartialEq for Affine
Auto Trait Implementations§
impl Freeze for Affine
impl RefUnwindSafe for Affine
impl Send for Affine
impl Sync for Affine
impl Unpin for Affine
impl UnwindSafe for Affine
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request