Add a function to merge two outlines

This commit is contained in:
Sebastian K 2020-05-19 18:26:17 +03:00 committed by Patrick Walton
parent bf50e74396
commit 3486d55565
1 changed files with 20 additions and 0 deletions

View File

@ -218,6 +218,26 @@ impl Outline {
pub fn close_all_contours(&mut self) { pub fn close_all_contours(&mut self) {
self.contours.iter_mut().for_each(|contour| contour.close()); self.contours.iter_mut().for_each(|contour| contour.close());
} }
#[inline]
pub fn is_empty(&self) -> bool {
self.contours.iter().all(Contour::is_empty)
}
/// Appends the contours in another outline to this one.
pub fn push_outline(&mut self, other: Outline) {
if other.is_empty() {
return;
}
if self.is_empty() {
self.bounds = other.bounds;
} else {
self.bounds = self.bounds.union_rect(other.bounds);
}
self.contours.extend(other.contours);
}
} }
impl Debug for Outline { impl Debug for Outline {