Skip to content

Commit

Permalink
Add transform() method to ContourPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens authored and cmyr committed May 21, 2021
1 parent 292514d commit 71557e2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/glyph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 71557e2

Please # to comment.