From 541ad28f64abab3552478b9c92453a3f0f194a01 Mon Sep 17 00:00:00 2001 From: Sebastian K Date: Tue, 19 May 2020 18:26:17 +0300 Subject: [PATCH] add Outline::merge to combine two outlines --- content/src/outline.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/content/src/outline.rs b/content/src/outline.rs index 8cb4f229..4ad31cde 100644 --- a/content/src/outline.rs +++ b/content/src/outline.rs @@ -218,6 +218,20 @@ impl Outline { pub fn close_all_contours(&mut self) { self.contours.iter_mut().for_each(|contour| contour.close()); } + + pub fn merge(&mut self, other: Outline) { + if other.len() == 0 { + return; + } + + if self.len() == 0 { + self.bounds = other.bounds; + } else { + self.bounds = self.bounds.union_rect(other.bounds); + } + + self.contours.extend(other.contours); + } } impl Debug for Outline {