Auto merge of #366 - pcwalton:outline-merge, r=pcwalton

Add a function to merge two outlines
This commit is contained in:
bors-servo 2020-06-24 20:12:23 -04:00 committed by GitHub
commit 981677976e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {