Add a `transformed()` method to `Outline` and `Contour`.

This commit is contained in:
Sebastian K 2020-05-29 22:42:00 +03:00 committed by Patrick Walton
parent 981677976e
commit 4dea6aa258
1 changed files with 11 additions and 0 deletions

View File

@ -178,6 +178,11 @@ impl Outline {
self.bounds = new_bounds.unwrap_or_else(|| RectF::default());
}
pub fn transformed(mut self, transform: &Transform2F) -> Outline {
self.transform(transform);
self
}
pub fn apply_perspective(&mut self, perspective: &Perspective) {
let mut new_bounds = None;
for contour in &mut self.contours {
@ -614,6 +619,12 @@ impl Contour {
}
}
#[inline]
pub fn transformed(mut self, transform: &Transform2F) -> Contour {
self.transform(transform);
self
}
pub fn apply_perspective(&mut self, perspective: &Perspective) {
for (point_index, point) in self.points.iter_mut().enumerate() {
*point = *perspective * *point;