diff options
author | Jovansonlee Cesar <ivanceras@gmail.com> | 2018-09-01 22:59:27 +0800 |
---|---|---|
committer | Jovansonlee Cesar <ivanceras@gmail.com> | 2018-09-01 22:59:27 +0800 |
commit | 7cf9d0470e5912091071d9e7948de27ba150a2fa (patch) | |
tree | 5d4745c3d17b2cb0666cfd8908e142b21dbc87a9 /svgbob | |
parent | 006570524d4563e6a66e4301b933ea92adc0aae9 (diff) |
Add implementation for beatifying railroad diagram
Diffstat (limited to 'svgbob')
-rw-r--r-- | svgbob/src/box_drawing.rs | 20 | ||||
-rw-r--r-- | svgbob/src/enhance.rs | 61 |
2 files changed, 74 insertions, 7 deletions
diff --git a/svgbob/src/box_drawing.rs b/svgbob/src/box_drawing.rs index f4cd8bd..3e7ce75 100644 --- a/svgbob/src/box_drawing.rs +++ b/svgbob/src/box_drawing.rs @@ -33,6 +33,7 @@ pub fn box_drawing(ch: &char) -> (Vec<Block>, Vec<Fragment>) { let w = &PointBlock::block(W); let x = &PointBlock::block(X); let y = &PointBlock::block(Y); + ////////////////////////////// // // Static are all Strong signal @@ -202,7 +203,24 @@ pub fn box_drawing(ch: &char) -> (Vec<Block>, Vec<Fragment>) { ) } else if ch.is('╨') { (vec![K, O, B, D], vec![line(k, o), line(b, l), line(d, n)]) - } else { + } + // ◜ + else if ch.is('◜'){ + (vec![E,W], vec![arc(e, m, 4), line(m, w)]) + } + // ◝ + else if ch.is('◝'){ + (vec![A,W], vec![arc(m, a, 4), line(m, w)]) + } + // ◟ + else if ch.is('◟'){ + (vec![C,Y], vec![arc(m, y, 4), line(c, m)]) + } + // ◞ + else if ch.is('◞'){ + (vec![C,U], vec![arc(u, m, 4), line(m, c)]) + } + else { (vec![], vec![]) } } diff --git a/svgbob/src/enhance.rs b/svgbob/src/enhance.rs index c90b61f..adfc7e8 100644 --- a/svgbob/src/enhance.rs +++ b/svgbob/src/enhance.rs @@ -2,9 +2,9 @@ use focus_char::FocusChar; use fragments::Fragment; use location::Location; use location::Direction::{Bottom, BottomLeft, BottomRight, Left, Right, Top, TopLeft, TopRight}; -use block::Block::{A, C, E, F, J, K, M, O, P, S, U, W, Y}; +use block::Block::{A, C, E, F, J, K, M, O, P, R, S, T, U, W, Y}; use point_block::PointBlock; -use fragments::{line, arc, arrow_line}; +use fragments::{line, arc, arrow_line, open_circle}; pub trait Enhance { fn enhance(&self) -> (Vec<Fragment>, Vec<Location>); @@ -32,9 +32,9 @@ impl<'g> Enhance for FocusChar<'g> { let o = &PointBlock::block(O); let p = &PointBlock::block(P); //let _q = &PointBlock::block(Q); - //let _r = &PointBlock::block(R); + let r = &PointBlock::block(R); let s = &PointBlock::block(S); - //let _t = &PointBlock::block(T); + let t = &PointBlock::block(T); let u = &PointBlock::block(U); //let _v = &PointBlock::block(V); let w = &PointBlock::block(W); @@ -58,7 +58,6 @@ impl<'g> Enhance for FocusChar<'g> { let bottom_left2 = || bottom().go_left(2); let top2_right = || top2().right(); - // _ underscore if self.is('_') { // _| @@ -261,7 +260,57 @@ impl<'g> Enhance for FocusChar<'g> { elm.extend(vec![arc(w, c, 5), line(k, o)]); consumed.push(this()); } - + // railroad diagram + // _◞_ + if self.is('◞') && self.left().is('_') && self.right().is('_'){ + elm.extend(vec![line(u,y)]); + } + // railroad diagram + // _◟_ + if self.is('◟') && self.left().is('_') && self.right().is('_'){ + elm.extend(vec![line(u,y)]); + } + // railroad diagram + // + // -╯- -╰- -╭- -╮- + // + if self.any("╯╮╰╭") && self.left().is('-') && self.right().is('-'){ + elm.extend(vec![line(k,o)]); + } + // | | + // ╰ ╯ + // | | + if self.any("╰╯") && self.top().is('|') && self.bottom().is('|'){ + elm.extend(vec![line(c,w)]); + } + // railroad start + // O_ + if self.is('O') && self.right().is('_'){ + elm.extend(vec![open_circle(m,3), arc(t,&right().y(),4)]); + consumed.extend(vec![this(), right()]); + } + // railroad end + // _O + if self.is('O') && self.left().is('_'){ + elm.extend(vec![open_circle(m,3), arc(&left().u(), p,4)]); + consumed.extend(vec![this(), left()]); + } + // railroad start + // o_ + if self.is('o') && self.right().is('_'){ + elm.extend(vec![open_circle(m,2), + arc(s,&right().w(),4), + line(&right().w(), &right().y())]); + consumed.extend(vec![this(), right()]); + } + // railroad end + // _o + if self.is('o') && self.left().is('_'){ + elm.extend(vec![open_circle(m,2), + arc(&left().w(), q, 4), + line(&left().w(), &left().u())]); + consumed.extend(vec![this(), left()]); + } (elm, consumed) } } |