From 104f22876843e0ac6888281b93423c70a1df0fb4 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Sun, 16 May 2021 21:52:33 +0100 Subject: [PATCH] Add transform() method to ContourPoint --- src/glyph/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/glyph/mod.rs b/src/glyph/mod.rs index 6f4b3358..bd14f1cb 100644 --- a/src/glyph/mod.rs +++ b/src/glyph/mod.rs @@ -535,6 +535,14 @@ impl ContourPoint { pub fn to_kurbo(&self) -> kurbo::Point { kurbo::Point::new(self.x as f64, self.y as f64) } + + /// Applies a transformation matrix to the point's coordinates + pub fn transform(&mut self, transform: AffineTransform) { + let new_x = transform.x_scale * self.x + transform.yx_scale * self.y + transform.x_offset; + let new_y = transform.xy_scale * self.x + transform.y_scale * self.y + transform.y_offset; + self.x = new_x; + self.y = new_y; + } } impl Component {