diff options
author | Jovansonlee Cesar <ivanceras@gmail.com> | 2021-07-11 19:39:13 +0800 |
---|---|---|
committer | Jovansonlee Cesar <ivanceras@gmail.com> | 2021-07-11 19:39:13 +0800 |
commit | b0f61560b1438d023ca1e0ef9ada686858dce5d5 (patch) | |
tree | 69416009817a4672815d823925fd44ebdd25ba0b | |
parent | 9c5d1e2b3771ff3cee17d5df850d6c20ce72ebec (diff) |
make the logic of endorse_rect_and_arcs uniform with arcs
-rw-r--r-- | svgbob/TODO.md | 1 | ||||
-rw-r--r-- | svgbob/src/buffer/cell_buffer/span.rs | 6 | ||||
-rw-r--r-- | svgbob/src/map/circle_map.rs | 9 | ||||
-rw-r--r-- | svgbob/test_data/circles.bob | 4 |
4 files changed, 14 insertions, 6 deletions
diff --git a/svgbob/TODO.md b/svgbob/TODO.md index 9a7a7ca..ca5a92e 100644 --- a/svgbob/TODO.md +++ b/svgbob/TODO.md @@ -21,3 +21,4 @@ - [X] Revise calculation of Circle and Arc center by basing on the number of chars/width - [ ] Add more circle art - [ ] Enhance quarter arc to be able to merge 2 or 3 quarters to form bigger arcs +- [ ] Support for pills, elongated ovals diff --git a/svgbob/src/buffer/cell_buffer/span.rs b/svgbob/src/buffer/cell_buffer/span.rs index dc8bb60..def4e31 100644 --- a/svgbob/src/buffer/cell_buffer/span.rs +++ b/svgbob/src/buffer/cell_buffer/span.rs @@ -186,8 +186,12 @@ impl Span { for um in unmatched { un_endorsed_circles.push(groups[um].clone()); } - } else if let Some(arc) = circle_map::endorse_arc(&groups) { + } else if let Some((arc, unmatched)) = circle_map::endorse_arc(&groups) + { fragments.push(arc.clone().into()); + for um in unmatched { + un_endorsed_circles.push(groups[um].clone()); + } } else { un_endorsed_circles.extend(groups) } diff --git a/svgbob/src/map/circle_map.rs b/svgbob/src/map/circle_map.rs index 41c81e1..7dd9cda 100644 --- a/svgbob/src/map/circle_map.rs +++ b/svgbob/src/map/circle_map.rs @@ -603,10 +603,13 @@ fn is_subset_of( /// proportional, due to 1 of the arc not matching on the same arc level since the /// arc parameters is determine only by the contacts, and have no clue about it's radius. /// Multiple arc contacts can be the same while not having the same arc radius. -pub fn endorse_arc(search: &Vec<Contacts>) -> Option<&fragment::Arc> { +pub fn endorse_arc( + search: &Vec<Contacts>, +) -> Option<(&fragment::Arc, Vec<usize>)> { FRAGMENTS_ARC.iter().rev().find_map(|(contacts, arc)| { - if contacts == search { - Some(arc) + let (matched, unmatched) = is_subset_of(contacts, search); + if matched { + Some((arc, unmatched)) } else { None } diff --git a/svgbob/test_data/circles.bob b/svgbob/test_data/circles.bob index 2a3f27f..68914ef 100644 --- a/svgbob/test_data/circles.bob +++ b/svgbob/test_data/circles.bob @@ -384,11 +384,11 @@ ''''-._ - `. + | `. _.-'''' | \ ,' | . / | | | - . | +-------- | + . | +---------| | | | +--------- | | |