From 4d776fd84e647632aa81600ab06644402db12270 Mon Sep 17 00:00:00 2001 From: Varphone Wong Date: Fri, 8 Mar 2024 17:07:31 +0800 Subject: [PATCH] `epaint`: Added `Shape::{scale,translate}` wrappers (#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. --- crates/epaint/src/shape.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/epaint/src/shape.rs b/crates/epaint/src/shape.rs index 033d4dfc..89048ac4 100644 --- a/crates/epaint/src/shape.rs +++ b/crates/epaint/src/shape.rs @@ -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