[]Struct druid::Affine

pub struct Affine(_);

A 2D affine transform.

Implementations

impl 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 FLIP_X: Affine

A transform that is flipped on the x-axis.

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(s: f64) -> Affine

An affine transform representing uniform scaling.

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

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 translate<V>(p: V) -> Affine where
    V: Into<Vec2>, 

An affine transform representing translation.

pub fn as_coeffs(self) -> [f64; 6]

Get the coefficients of the transform.

pub fn determinant(self) -> f64

Compute the determinant of this transform.

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

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 Clone for Affine

impl Copy for Affine

impl Data for Affine[src]

impl Debug for Affine

impl Default for Affine

impl From<TranslateScale> for Affine

impl<'a> Mul<&'a BezPath> for Affine

type Output = BezPath

The resulting type after applying the * operator.

impl Mul<Affine> for Affine

type Output = Affine

The resulting type after applying the * operator.

impl Mul<BezPath> for Affine

type Output = BezPath

The resulting type after applying the * operator.

impl Mul<Circle> for Affine

type Output = Ellipse

The resulting type after applying the * operator.

impl Mul<CubicBez> for Affine

type Output = CubicBez

The resulting type after applying the * operator.

impl Mul<Ellipse> for Affine

type Output = Ellipse

The resulting type after applying the * operator.

impl Mul<Line> for Affine

type Output = Line

The resulting type after applying the * operator.

impl Mul<PathEl> for Affine

type Output = PathEl

The resulting type after applying the * operator.

impl Mul<Point> for Affine

type Output = Point

The resulting type after applying the * operator.

impl Mul<QuadBez> for Affine

type Output = QuadBez

The resulting type after applying the * operator.

impl MulAssign<Affine> for Affine

impl PartialEq<Affine> for Affine

impl StructuralPartialEq for Affine

Auto Trait Implementations

impl RefUnwindSafe for Affine

impl Send for Affine

impl Sync for Affine

impl Unpin for Affine

impl UnwindSafe for Affine

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AnyEq for T where
    T: PartialEq<T> + Any
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.