pub struct TranslateScale { /* private fields */ }
Expand description
A transformation including scaling and translation.
If the translation is (x, y)
and the scale is s
, then this
transformation represents this augmented matrix:
| s 0 x |
| 0 s y |
| 0 0 1 |
See Affine
for more details about the
equivalence with augmented matrices.
Various multiplication ops are defined, and these are all defined
to be consistent with matrix multiplication. Therefore,
TranslateScale * Point
is defined but not the other way around.
Also note that multiplication is not commutative. Thus,
TranslateScale::scale(2.0) * TranslateScale::translate(Vec2::new(1.0, 0.0))
has a translation of (2, 0), while
TranslateScale::translate(Vec2::new(1.0, 0.0)) * TranslateScale::scale(2.0)
has a translation of (1, 0). (Both have a scale of 2; also note that
the first case can be written
2.0 * TranslateScale::translate(Vec2::new(1.0, 0.0))
as this case
has an implicit conversion).
This transformation is less powerful than Affine
, but can be applied
to more primitives, especially including Rect
.
Implementations§
§impl TranslateScale
impl TranslateScale
pub const fn new(translation: Vec2, scale: f64) -> TranslateScale
pub const fn new(translation: Vec2, scale: f64) -> TranslateScale
Create a new transformation from translation and scale.
pub const fn scale(s: f64) -> TranslateScale
pub const fn scale(s: f64) -> TranslateScale
Create a new transformation with scale only.
pub const fn translate(t: Vec2) -> TranslateScale
pub const fn translate(t: Vec2) -> TranslateScale
Create a new transformation with translation only.
pub fn inverse(self) -> TranslateScale
pub fn inverse(self) -> TranslateScale
Compute the inverse transform.
Multiplying a transform with its inverse (either on the left or right) results in the identity transform (modulo floating point rounding errors).
Produces NaN values when scale is zero.
Trait Implementations§
§impl Add<TranslateScale> for Vec2
impl Add<TranslateScale> for Vec2
§type Output = TranslateScale
type Output = TranslateScale
+
operator.§fn add(self, other: TranslateScale) -> TranslateScale
fn add(self, other: TranslateScale) -> TranslateScale
+
operation. Read more§impl Add<Vec2> for TranslateScale
impl Add<Vec2> for TranslateScale
§type Output = TranslateScale
type Output = TranslateScale
+
operator.§fn add(self, other: Vec2) -> TranslateScale
fn add(self, other: Vec2) -> TranslateScale
+
operation. Read more§impl AddAssign<Vec2> for TranslateScale
impl AddAssign<Vec2> for TranslateScale
§fn add_assign(&mut self, other: Vec2)
fn add_assign(&mut self, other: Vec2)
+=
operation. Read more§impl Clone for TranslateScale
impl Clone for TranslateScale
§fn clone(&self) -> TranslateScale
fn clone(&self) -> TranslateScale
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for TranslateScale
impl Debug for TranslateScale
§impl Default for TranslateScale
impl Default for TranslateScale
§fn default() -> TranslateScale
fn default() -> TranslateScale
§impl From<TranslateScale> for Affine
impl From<TranslateScale> for Affine
§fn from(ts: TranslateScale) -> Affine
fn from(ts: TranslateScale) -> Affine
§impl<'a> Mul<&'a BezPath> for TranslateScale
impl<'a> Mul<&'a BezPath> for TranslateScale
§impl Mul<BezPath> for TranslateScale
impl Mul<BezPath> for TranslateScale
§impl Mul<Circle> for TranslateScale
impl Mul<Circle> for TranslateScale
§impl Mul<CubicBez> for TranslateScale
impl Mul<CubicBez> for TranslateScale
§impl Mul<Line> for TranslateScale
impl Mul<Line> for TranslateScale
§impl Mul<PathEl> for TranslateScale
impl Mul<PathEl> for TranslateScale
§impl Mul<PathSeg> for TranslateScale
impl Mul<PathSeg> for TranslateScale
§impl Mul<Point> for TranslateScale
impl Mul<Point> for TranslateScale
§impl Mul<QuadBez> for TranslateScale
impl Mul<QuadBez> for TranslateScale
§impl Mul<Rect> for TranslateScale
impl Mul<Rect> for TranslateScale
§impl Mul<RoundedRect> for TranslateScale
impl Mul<RoundedRect> for TranslateScale
§type Output = RoundedRect
type Output = RoundedRect
*
operator.§fn mul(self, other: RoundedRect) -> RoundedRect
fn mul(self, other: RoundedRect) -> RoundedRect
*
operation. Read more§impl Mul<RoundedRectRadii> for TranslateScale
impl Mul<RoundedRectRadii> for TranslateScale
§type Output = RoundedRectRadii
type Output = RoundedRectRadii
*
operator.§fn mul(self, other: RoundedRectRadii) -> RoundedRectRadii
fn mul(self, other: RoundedRectRadii) -> RoundedRectRadii
*
operation. Read more§impl Mul<TranslateScale> for TranslateScale
impl Mul<TranslateScale> for TranslateScale
§type Output = TranslateScale
type Output = TranslateScale
*
operator.§fn mul(self, other: TranslateScale) -> TranslateScale
fn mul(self, other: TranslateScale) -> TranslateScale
*
operation. Read more§impl Mul<TranslateScale> for f64
impl Mul<TranslateScale> for f64
§type Output = TranslateScale
type Output = TranslateScale
*
operator.§fn mul(self, other: TranslateScale) -> TranslateScale
fn mul(self, other: TranslateScale) -> TranslateScale
*
operation. Read more§impl MulAssign<TranslateScale> for TranslateScale
impl MulAssign<TranslateScale> for TranslateScale
§fn mul_assign(&mut self, other: TranslateScale)
fn mul_assign(&mut self, other: TranslateScale)
*=
operation. Read more§impl Sub<Vec2> for TranslateScale
impl Sub<Vec2> for TranslateScale
§type Output = TranslateScale
type Output = TranslateScale
-
operator.§fn sub(self, other: Vec2) -> TranslateScale
fn sub(self, other: Vec2) -> TranslateScale
-
operation. Read more§impl SubAssign<Vec2> for TranslateScale
impl SubAssign<Vec2> for TranslateScale
§fn sub_assign(&mut self, other: Vec2)
fn sub_assign(&mut self, other: Vec2)
-=
operation. Read more