Skip to content

Commit

Permalink
epaint: Added Shape::{scale,translate} wrappers (#4090)
Browse files Browse the repository at this point in the history
The `Shape::translate` method has been replaced with `Shape::transform`,
which introduces breaking changes that could negatively impact existing
users.

This patch adds a `Shape::translate` wrapper to prevent these breaking
changes.
  • Loading branch information
varphone authored Mar 8, 2024
1 parent 385daeb commit 4d776fd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/epaint/src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,22 @@ impl Shape {
}
}

/// Scale the shape by `factor`, in-place.
///
/// A wrapper around [`Self::transform`].
#[inline(always)]
pub fn scale(&mut self, factor: f32) {
self.transform(TSTransform::from_scaling(factor));
}

/// Move the shape by `delta`, in-place.
///
/// A wrapper around [`Self::transform`].
#[inline(always)]
pub fn translate(&mut self, delta: Vec2) {
self.transform(TSTransform::from_translation(delta));
}

/// Move the shape by this many points, in-place.
///
/// If using a [`PaintCallback`], note that only the rect is scaled as opposed
Expand Down

0 comments on commit 4d776fd

Please sign in to comment.