diff options
author | Jovansonlee Cesar <ivanceras@gmail.com> | 2018-08-03 00:16:58 +0800 |
---|---|---|
committer | Jovansonlee Cesar <ivanceras@gmail.com> | 2018-08-03 00:16:58 +0800 |
commit | dec13de59478424fef0f0f07ae389914c8d4bf10 (patch) | |
tree | 93a4ef8290f092e46959d533451d8d5bf525ca19 | |
parent | 3c8d2f9caffb504e28bfc000191cedef3fe1ae8a (diff) |
Fix circle with normal dash breaking
-rw-r--r-- | TODO.md | 4 | ||||
-rw-r--r-- | svgbob/src/enhance_circle.rs | 18 | ||||
-rw-r--r-- | svgbob/src/focus_char.rs | 10 |
3 files changed, 20 insertions, 12 deletions
@@ -8,5 +8,5 @@ it will be easier to process by the fragment emitter - [ ] Group traced elements together, then reduce as needed - [x] Add `#` as square start marker for lines -- [ ] Support for geometric shapes https://en.wikipedia.org/wiki/Geometric_Shapes -- [ ] Add enhance circle, detect circles then enhance it. +- [x] Support for geometric shapes https://en.wikipedia.org/wiki/Geometric_Shapes +- [x] Add enhance circle, detect circles then enhance it. diff --git a/svgbob/src/enhance_circle.rs b/svgbob/src/enhance_circle.rs index 0acfe99..3e4bfe2 100644 --- a/svgbob/src/enhance_circle.rs +++ b/svgbob/src/enhance_circle.rs @@ -100,8 +100,8 @@ impl<'g> EnhanceCircle for FocusChar<'g> { // '-' if self.in_left(2).is('(') && self.in_right(2).is(')') - && self.top().is_satisfied(&IsStrongAll(vec![K,O])) - && self.bottom().is_satisfied(&IsStrongAll(vec![K,O])) + && self.top().can_be_strong_all_blocks(vec![K,O]) + && self.bottom().can_be_strong_all_blocks(vec![K,O]) && self.bottom_left().any("`'") && self.bottom_right().is('\'') && self.top_left().any(".,") @@ -117,14 +117,14 @@ impl<'g> EnhanceCircle for FocusChar<'g> { if self.in_left(2).is('(') && self.in_right(3).is(')') && self.top_left().any(".,") - && self.top().is_satisfied(&IsStrongAll(vec![K,O])) - && self.top_right().is('-') - && self.top_right().right().is_satisfied(&IsStrongAll(vec![K,O])) + && self.top().can_be_strong_all_blocks(vec![K,O]) + && self.top_right().can_be_strong_all_blocks(vec![K,O]) + && self.top().in_right(2).is('.') && self.bottom_left().any("`'") - && self.bottom().is_satisfied(&IsStrongAll(vec![K,O])) - && self.bottom_right().is_satisfied(&IsStrongAll(vec![K,O])) - && self.bottom_right().right().is('\''){ - elm.push(open_circle(&this().o(),10)); + && self.bottom().can_be_strong_all_blocks(vec![K,O]) + && self.bottom_right().can_be_strong_all_blocks(vec![K,O]) + && self.bottom().in_right(2).is('\''){ + elm.push(open_circle(o,10)); consumed.extend(vec![left2(), right3(), top_left(), top(), top_right(), top_right2(), bottom_left(), bottom(), bottom_right(), bottom_right2(), ]); diff --git a/svgbob/src/focus_char.rs b/svgbob/src/focus_char.rs index d894547..cb9fde6 100644 --- a/svgbob/src/focus_char.rs +++ b/svgbob/src/focus_char.rs @@ -245,7 +245,7 @@ impl<'g> FocusChar<'g> { (elements) } - pub fn is_satisfied(&self, can: &Can) -> bool { + fn is_satisfied(&self, can: &Can) -> bool { match *can { ConnectTo(ref cond_block, ref signal) => { self.can_block_pass_connect(&cond_block, signal) @@ -269,6 +269,8 @@ impl<'g> FocusChar<'g> { } } + /// check if this block can be a strong block + /// when applying the intesifier fn can_be_strong_block(&self, block: &Block) -> bool { if self.is_strong_block(block) { true @@ -279,6 +281,12 @@ impl<'g> FocusChar<'g> { } } + /// check if each blocks in the vectors can be strong when + /// applying the intesifiers + pub fn can_be_strong_all_blocks(&self, blocks: Vec<Block>) -> bool{ + blocks.iter().all(|b| self.can_be_strong_block(b)) + } + fn is_strong_block(&self, block: &Block) -> bool { let character: Option<Characteristic> = self.ch.get_characteristic(); if let Some(character) = character { |