#[repr(C)]pub struct ScaleOffset2D<T, Src, Dst> {
pub sx: T,
pub sy: T,
pub tx: T,
pub ty: T,
/* private fields */
}Fields§
§sx: T§sy: T§tx: T§ty: TImplementations§
Source§impl<T, Src, Dst> ScaleOffset2D<T, Src, Dst>
impl<T, Src, Dst> ScaleOffset2D<T, Src, Dst>
Sourcepub fn new(sx: T, sy: T, tx: T, ty: T) -> Self
pub fn new(sx: T, sy: T, tx: T, ty: T) -> Self
Create a transform with provided scale and offset terms.
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns true if self is an identity transform, using T’s
default epsilon value.
Source§impl<T: Copy, Src, Dst> ScaleOffset2D<T, Src, Dst>
impl<T: Copy, Src, Dst> ScaleOffset2D<T, Src, Dst>
Sourcepub fn transform_point(&self, p: Point2D<T, Src>) -> Point2D<T, Dst>
pub fn transform_point(&self, p: Point2D<T, Src>) -> Point2D<T, Dst>
Returns the given point transformed by this transform.
Sourcepub fn transform_vector(&self, v: Vector2D<T, Src>) -> Vector2D<T, Dst>where
T: Mul<Output = T>,
pub fn transform_vector(&self, v: Vector2D<T, Src>) -> Vector2D<T, Dst>where
T: Mul<Output = T>,
Returns the given vector transformed by this transform.
Sourcepub fn transform_box(&self, b: &Box2D<T, Src>) -> Box2D<T, Dst>
pub fn transform_box(&self, b: &Box2D<T, Src>) -> Box2D<T, Dst>
Returns the given box transformed by this transform.
Sourcepub fn transform_rect(&self, r: &Rect<T, Src>) -> Rect<T, Dst>
pub fn transform_rect(&self, r: &Rect<T, Src>) -> Rect<T, Dst>
Returns the given rectangle transformed by this transform.
Sourcepub fn then<NewDst>(
&self,
other: &ScaleOffset2D<T, Dst, NewDst>,
) -> ScaleOffset2D<T, Src, NewDst>
pub fn then<NewDst>( &self, other: &ScaleOffset2D<T, Dst, NewDst>, ) -> ScaleOffset2D<T, Src, NewDst>
Produce a ScaleOffset2D that includes both self and other.
The ‘other’ ScaleOffset2D is applied after self.
This is equivalent to Transform2D::then.
Sourcepub fn pre_translate(&self, v: Vector2D<T, Src>) -> Self
pub fn pre_translate(&self, v: Vector2D<T, Src>) -> Self
Applies a translation before self’s transformation and returns the resulting transform.
Sourcepub fn then_translate(&self, v: Vector2D<T, Dst>) -> Self
pub fn then_translate(&self, v: Vector2D<T, Dst>) -> Self
Applies a translation after self’s transformation and returns the resulting transform.
Sourcepub fn pre_scale(&self, sx: T, sy: T) -> Self
pub fn pre_scale(&self, sx: T, sy: T) -> Self
Applies a scale before self’s transformation and returns the resulting transform.
Sourcepub fn then_scale(&self, sx: T, sy: T) -> Self
pub fn then_scale(&self, sx: T, sy: T) -> Self
Applies a scale after self’s transformation and returns the resulting transform.
Sourcepub fn is_invertible(&self) -> bool
pub fn is_invertible(&self) -> bool
Returns whether it is possible to compute the inverse transform.
Sourcepub fn inverse(&self) -> Option<ScaleOffset2D<T, Dst, Src>>
pub fn inverse(&self) -> Option<ScaleOffset2D<T, Dst, Src>>
Returns the inverse transform if possible.
Sourcepub fn to_transform2d(&self) -> Transform2D<T, Src, Dst>where
T: Zero,
pub fn to_transform2d(&self) -> Transform2D<T, Src, Dst>where
T: Zero,
Returns the same transform using Transform2D’s matrix representation.
Sourcepub fn to_transform3d(&self) -> Transform3D<T, Src, Dst>
pub fn to_transform3d(&self) -> Transform3D<T, Src, Dst>
Returns the same transform using Transform3D’s matrix representation.
Sourcepub fn to_array(&self) -> [T; 4]
pub fn to_array(&self) -> [T; 4]
Returns an array containing this transform’s terms.
The terms are laid out in the same order as they are
specified in ScaleOffset2D::new.
Sourcepub fn with_source<NewSrc>(&self) -> ScaleOffset2D<T, NewSrc, Dst>
pub fn with_source<NewSrc>(&self) -> ScaleOffset2D<T, NewSrc, Dst>
Returns the same transform with a different source unit.
Sourcepub fn with_destination<NewDst>(&self) -> ScaleOffset2D<T, Src, NewDst>
pub fn with_destination<NewDst>(&self) -> ScaleOffset2D<T, Src, NewDst>
Returns the same transform with a different destination unit.
Sourcepub fn to_untyped(&self) -> ScaleOffset2D<T, UnknownUnit, UnknownUnit>
pub fn to_untyped(&self) -> ScaleOffset2D<T, UnknownUnit, UnknownUnit>
Drop the units, preserving only the numeric value.
Sourcepub fn from_untyped(val: ScaleOffset2D<T, UnknownUnit, UnknownUnit>) -> Self
pub fn from_untyped(val: ScaleOffset2D<T, UnknownUnit, UnknownUnit>) -> Self
Tag a unitless value with units.
Trait Implementations§
Source§impl<T: ApproxEq<T>, Src, Dst> ApproxEq<T> for ScaleOffset2D<T, Src, Dst>
impl<T: ApproxEq<T>, Src, Dst> ApproxEq<T> for ScaleOffset2D<T, Src, Dst>
Source§fn approx_eq_eps(&self, other: &Self, eps: &T) -> bool
fn approx_eq_eps(&self, other: &Self, eps: &T) -> bool
Returns true if this transform is approximately equal to the other one, using
a provided epsilon value.
Source§fn approx_epsilon() -> T
fn approx_epsilon() -> T
Source§fn approx_eq(&self, other: &Self) -> bool
fn approx_eq(&self, other: &Self) -> bool
true if this object is approximately equal to the other one, using
the approx_epsilon epsilon value.Source§impl<T: Clone, Src, Dst> Clone for ScaleOffset2D<T, Src, Dst>
impl<T: Clone, Src, Dst> Clone for ScaleOffset2D<T, Src, Dst>
Source§impl<T, Src, Dst> Debug for ScaleOffset2D<T, Src, Dst>
impl<T, Src, Dst> Debug for ScaleOffset2D<T, Src, Dst>
Source§impl<T, Src, Dst> Default for ScaleOffset2D<T, Src, Dst>
impl<T, Src, Dst> Default for ScaleOffset2D<T, Src, Dst>
Source§fn default() -> Self
fn default() -> Self
Returns the identity transform.