Skip to content

Commit c6b48bb

Browse files
varphonehacknus
authored andcommitted
epaint: Added Shape::{scale,translate} wrappers (emilk#4090)
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.
1 parent 7c04f93 commit c6b48bb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/epaint/src/shape.rs

+16
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,22 @@ impl Shape {
355355
}
356356
}
357357

358+
/// Scale the shape by `factor`, in-place.
359+
///
360+
/// A wrapper around [`Self::transform`].
361+
#[inline(always)]
362+
pub fn scale(&mut self, factor: f32) {
363+
self.transform(TSTransform::from_scaling(factor));
364+
}
365+
366+
/// Move the shape by `delta`, in-place.
367+
///
368+
/// A wrapper around [`Self::transform`].
369+
#[inline(always)]
370+
pub fn translate(&mut self, delta: Vec2) {
371+
self.transform(TSTransform::from_translation(delta));
372+
}
373+
358374
/// Move the shape by this many points, in-place.
359375
///
360376
/// If using a [`PaintCallback`], note that only the rect is scaled as opposed

0 commit comments

Comments
 (0)