diff options
author | Jovansonlee Cesar <ivanceras@gmail.com> | 2023-08-10 23:44:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 23:44:50 +0800 |
commit | 228e3511d535150404dd215b3f3d48b80b2db857 (patch) | |
tree | cfe3e07e9007b66ec0e076be62ec3640e8c6421b /packages | |
parent | 85c384aaab02c20caa7dab5f7d484c3c3b2cf6bc (diff) | |
parent | 608db0bbc4589952fce86cea1bf5844d9943102f (diff) |
Merge branch 'master' into bump-workflow-actions
Diffstat (limited to 'packages')
-rw-r--r-- | packages/svgbob/Cargo.toml | 14 | ||||
-rw-r--r-- | packages/svgbob/src/buffer/cell_buffer.rs | 135 | ||||
-rw-r--r-- | packages/svgbob/src/buffer/cell_buffer/cell.rs | 8 | ||||
-rw-r--r-- | packages/svgbob/src/buffer/fragment_buffer/fragment.rs | 10 | ||||
-rw-r--r-- | packages/svgbob/src/buffer/fragment_buffer/fragment/line.rs | 2 | ||||
-rw-r--r-- | packages/svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs | 2 | ||||
-rw-r--r-- | packages/svgbob/src/buffer/fragment_buffer/fragment/rect.rs | 2 | ||||
-rw-r--r-- | packages/svgbob/src/map/ascii_map.rs | 2778 | ||||
-rw-r--r-- | packages/svgbob/src/map/circle_map.rs | 941 | ||||
-rw-r--r-- | packages/svgbob/src/map/unicode_map.rs | 359 | ||||
-rw-r--r-- | packages/svgbob/src/util.rs | 10 | ||||
-rw-r--r-- | packages/svgbob/tests/simple_shapes.rs | 10 | ||||
-rw-r--r-- | packages/svgbob/tests/styling.rs | 2 | ||||
-rw-r--r-- | packages/svgbob_cli/Cargo.toml | 4 | ||||
-rw-r--r-- | packages/svgbob_cli/src/main.rs | 10 | ||||
-rw-r--r-- | packages/svgbob_server/Cargo.toml | 6 |
16 files changed, 2609 insertions, 1684 deletions
diff --git a/packages/svgbob/Cargo.toml b/packages/svgbob/Cargo.toml index b86c81d..390a116 100644 --- a/packages/svgbob/Cargo.toml +++ b/packages/svgbob/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "svgbob" -version = "0.6.7" +version = "0.7.1" authors = ["Jovansonlee Cesar <ivanceras@gmail.com>"] description = "Transform your ascii diagrams into happy little SVG" repository = "https://github.com/ivanceras/svgbob" @@ -10,16 +10,16 @@ license = "Apache-2.0" edition = "2021" [dependencies] -nalgebra = "0.30.1" -parry2d = "0.8.0" -lazy_static = "1.3.0" -sauron = { version = "0.51", default-features = false} +nalgebra = "0.32.1" +parry2d = "0.13.5" +once_cell = "1.18.0" +sauron = { version = "0.59.0", default-features = false} #sauron = { path = "../../../sauron", default-features = false} unicode-width = "0.1.9" -itertools = "0.10.3" +itertools = "0.11.0" pom = { version = "3.2.0" } log = "0.4.14" -indexmap = "1.9.1" +indexmap = "2.0" diff --git a/packages/svgbob/src/buffer/cell_buffer.rs b/packages/svgbob/src/buffer/cell_buffer.rs index d632132..c949c51 100644 --- a/packages/svgbob/src/buffer/cell_buffer.rs +++ b/packages/svgbob/src/buffer/cell_buffer.rs @@ -13,7 +13,8 @@ pub use endorse::Endorse; use itertools::Itertools; use sauron::{ html, - html::{attributes::*, *}, + html::attributes::{class, id}, + html::*, svg::{attributes::*, *}, Node, }; @@ -109,7 +110,7 @@ impl CellBuffer { let svg_node = Self::fragments_to_node(fragments, legend_css, settings, w, h) - .add_children(group_nodes); + .with_children(group_nodes); (svg_node, w, h) } @@ -125,7 +126,7 @@ impl CellBuffer { let svg_node = Self::fragments_to_node(fragments, legend_css, settings, w, h) - .add_children(group_nodes); + .with_children(group_nodes); svg_node } @@ -261,7 +262,9 @@ impl CellBuffer { let classes: Vec<String> = self .css_styles .iter() - .map(|(class, styles)| format!(".{}{{ {} }}", class, styles)) + .map(|(class, styles)| { + format!(".svgbob .{}{{ {} }}", class, styles) + }) .collect(); classes.join("\n") } @@ -276,8 +279,11 @@ impl CellBuffer { let font_family = settings.font_family.to_owned(); let font_size = settings.font_size.to_owned(); - let element_styles = sauron::jss! { - "line, path, circle, rect, polygon": { + // we put a .svgbob class in order to avoid clashing with other svg in the document + // since the style element in this svg also affects the other svg element in the whole + // document + let element_styles = sauron::jss_pretty! { + ".svgbob line, .svgbob path, .svgbob circle, .svgbob rect, .svgbob polygon": { stroke: stroke_color.clone(), stroke_width: stroke_width, stroke_opacity: 1, @@ -286,76 +292,74 @@ impl CellBuffer { stroke_linejoin: "miter", }, - "text": { + ".svgbob text": { /* This fix the spacing bug in svg text*/ white_space: "pre", fill: stroke_color, + font_family: font_family, + font_size: px(font_size), }, - "rect.backdrop":{ + ".svgbob rect.backdrop":{ stroke: "none", fill: background.clone(), }, - ".broken":{ + ".svgbob .broken":{ stroke_dasharray: 8, }, - ".filled":{ + ".svgbob .filled":{ fill: fill_color, }, - ".bg_filled":{ + ".svgbob .bg_filled":{ fill: background.clone(), + stroke_width: 1, }, - ".nofill":{ + ".svgbob .nofill":{ fill: background, }, - "text": { - font_family: font_family, - font_size: px(font_size), - }, - - ".end_marked_arrow":{ + ".svgbob .end_marked_arrow":{ marker_end: "url(#arrow)", - }, + }, - ".start_marked_arrow":{ + ".svgbob .start_marked_arrow":{ marker_start: "url(#arrow)", - }, + }, - ".end_marked_diamond":{ + ".svgbob .end_marked_diamond":{ marker_end: "url(#diamond)", - }, - ".start_marked_diamond":{ + }, + ".svgbob .start_marked_diamond":{ marker_start: "url(#diamond)", - }, + }, - ".end_marked_circle":{ + ".svgbob .end_marked_circle":{ marker_end: "url(#circle)", - }, + }, - ".start_marked_circle":{ + ".svgbob .start_marked_circle":{ marker_start: "url(#circle)", - }, + }, - ".end_marked_open_circle":{ + ".svgbob .end_marked_open_circle":{ marker_end: "url(#open_circle)", - }, + }, - ".start_marked_open_circle":{ + ".svgbob .start_marked_open_circle":{ marker_start: "url(#open_circle)", - }, + }, - ".end_marked_big_open_circle":{ + ".svgbob .end_marked_big_open_circle":{ marker_end: "url(#big_open_circle)", - }, + }, - ".start_marked_big_open_circle": { + ".svgbob .start_marked_big_open_circle": { marker_start: "url(#big_open_circle)", - } + } }; html::tags::style([], [text(element_styles), text(legend_css)]) } @@ -397,7 +401,12 @@ impl CellBuffer { children.extend(fragment_nodes); svg( - [xmlns("http://www.w3.org/2000/svg"), width(w), height(h)], + [ + xmlns("http://www.w3.org/2000/svg"), + width(w), + height(h), + class("svgbob"), + ], children, ) } @@ -419,11 +428,11 @@ impl CellBuffer { marker( [ id("arrow"), - viewBox("-2 -2 8 8"), - refX(4), - refY(2), - markerWidth(7), - markerHeight(7), + view_box("-2 -2 8 8"), + ref_x(4), + ref_y(2), + marker_width(7), + marker_height(7), orient("auto-start-reverse"), ], [polygon([points("0,0 0,4 4,2 0,0")], [])], @@ -434,11 +443,11 @@ impl CellBuffer { marker( [ id("diamond"), - viewBox("-2 -2 8 8"), - refX(4), - refY(2), - markerWidth(7), - markerHeight(7), + view_box("-2 -2 8 8"), + ref_x(4), + ref_y(2), + marker_width(7), + marker_height(7), orient("auto-start-reverse"), ], [polygon([points("0,2 2,0 4,2 2,4 0,2")], [])], @@ -449,11 +458,11 @@ impl CellBuffer { marker( [ id("open_circle"), - viewBox("0 0 8 8"), - refX(4), - refY(4), - markerWidth(7), - markerHeight(7), + view_box("0 0 8 8"), + ref_x(4), + ref_y(4), + marker_width(7), + marker_height(7), orient("auto-start-reverse"), ], [circle( @@ -467,11 +476,11 @@ impl CellBuffer { marker( [ id("circle"), - viewBox("0 0 8 8"), - refX(4), - refY(4), - markerWidth(7), - markerHeight(7), + view_box("0 0 8 8"), + ref_x(4), + ref_y(4), + marker_width(7), + marker_height(7), orient("auto-start-reverse"), ], [circle( @@ -485,11 +494,11 @@ impl CellBuffer { marker( [ id("big_open_circle"), - viewBox("0 0 8 8"), - refX(4), - refY(4), - markerWidth(7), - markerHeight(7), + view_box("0 0 8 8"), + ref_x(4), + ref_y(4), + marker_width(7), + marker_height(7), orient("auto-start-reverse"), ], [circle( diff --git a/packages/svgbob/src/buffer/cell_buffer/cell.rs b/packages/svgbob/src/buffer/cell_buffer/cell.rs index 27b82bc..286b6cb 100644 --- a/packages/svgbob/src/buffer/cell_buffer/cell.rs +++ b/packages/svgbob/src/buffer/cell_buffer/cell.rs @@ -1,6 +1,6 @@ use crate::{util, Point}; use parry2d::{ - bounding_volume::AABB, + bounding_volume::Aabb, math::Isometry, query::{intersection_test, PointQuery}, shape::{Polyline, Segment}, @@ -129,7 +129,7 @@ impl Cell { /// the bounding box of this cell #[inline] - fn bounding_box(&self) -> AABB { + fn bounding_box(&self) -> Aabb { let start = Point::new( self.x as f32 * Self::width(), self.y as f32 * Self::height(), @@ -138,7 +138,7 @@ impl Cell { (self.x + 1) as f32 * Self::width(), (self.y + 1) as f32 * Self::height(), ); - AABB::new(*start, *end) + Aabb::new(*start, *end) } /// Convert the bounding box aabb to polyline segment @@ -433,7 +433,7 @@ mod tests { #[test] fn test_aabb() { assert_eq!( - AABB::new(*Point::new(0.0, 0.0), *Point::new(1.0, 2.0)), + Aabb::new(*Point::new(0.0, 0.0), *Point::new(1.0, 2.0)), Cell::new(0, 0).bounding_box() ); } diff --git a/packages/svgbob/src/buffer/fragment_buffer/fragment.rs b/packages/svgbob/src/buffer/fragment_buffer/fragment.rs index aa041ab..1cef8f1 100644 --- a/packages/svgbob/src/buffer/fragment_buffer/fragment.rs +++ b/packages/svgbob/src/buffer/fragment_buffer/fragment.rs @@ -5,7 +5,7 @@ pub use circle::Circle; pub use line::Line; pub use marker_line::{Marker, MarkerLine}; use parry2d::{ - bounding_volume::{BoundingVolume, AABB}, + bounding_volume::{Aabb, BoundingVolume}, math::Isometry, query::{intersection_test, PointQuery}, shape::{ConvexPolygon, Polyline, Segment, Shape}, @@ -167,13 +167,13 @@ impl Fragment { } pub fn hit(&self, start: Point, end: Point) -> bool { - self.is_intersecting(&AABB::new(*start, *end)) + self.is_intersecting(&Aabb::new(*start, *end)) } /// check if this fragment is intersecting with this bounding box /// Note: if intersection logic requires testing the solid shape inside the polygon /// use the ConvexPolygon of each shape instead of Polyline - pub fn is_intersecting(&self, bbox: &AABB) -> bool { + pub fn is_intersecting(&self, bbox: &Aabb) -> bool { let points = vec![ *Point::new(bbox.mins.x, bbox.mins.y), *Point::new(bbox.maxs.x, bbox.mins.y), @@ -206,9 +206,9 @@ impl Fragment { } /// check if this fragment can be contain in the specified bounding box `bbox` - pub fn is_inside(&self, bbox: &AABB) -> bool { + pub fn is_inside(&self, bbox: &Aabb) -> bool { let (start, end) = self.bounds(); - let frag_bound = AABB::new(*start, *end); + let frag_bound = Aabb::new(*start, *end); bbox.contains(&frag_bound) } diff --git a/packages/svgbob/src/buffer/fragment_buffer/fragment/line.rs b/packages/svgbob/src/buffer/fragment_buffer/fragment/line.rs index bcf7fdb..1b656f0 100644 --- a/packages/svgbob/src/buffer/fragment_buffer/fragment/line.rs +++ b/packages/svgbob/src/buffer/fragment_buffer/fragment/line.rs @@ -4,7 +4,7 @@ use crate::{ util, Direction, Point, }; use parry2d::{ - bounding_volume::AABB, + bounding_volume::Aabb, math::Isometry, query::PointQuery, shape::{Polyline, Segment, Shape}, diff --git a/packages/svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs b/packages/svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs index 183cad0..2cf90bb 100644 --- a/packages/svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs +++ b/packages/svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs @@ -174,6 +174,6 @@ impl<MSG> From<MarkerLine> for Node<MSG> { if let Some(end_marker) = ml.end_marker { classes.push(class(format!("end_marked_{}", end_marker))); } - node.add_attributes(classes) + node.with_attributes(classes) } } diff --git a/packages/svgbob/src/buffer/fragment_buffer/fragment/rect.rs b/packages/svgbob/src/buffer/fragment_buffer/fragment/rect.rs index 7bbc18d..e45f4f0 100644 --- a/packages/svgbob/src/buffer/fragment_buffer/fragment/rect.rs +++ b/packages/svgbob/src/buffer/fragment_buffer/fragment/rect.rs @@ -1,7 +1,7 @@ use crate::{fragment::Bounds, util, Cell, Point}; use parry2d::shape::{ConvexPolygon, Polyline, Segment, Shape}; use sauron::{ - html::attributes::*, + html::attributes::{class, classes_flag}, svg::{attributes::*, *}, Node, }; diff --git a/packages/svgbob/src/map/ascii_map.rs b/packages/svgbob/src/map/ascii_map.rs index 6ed3033..fb8706d 100644 --- a/packages/svgbob/src/map/ascii_map.rs +++ b/packages/svgbob/src/map/ascii_map.rs @@ -11,1088 +11,1774 @@ use crate::{ Fragment, Property, Signal::{self, Medium, Strong, Weak}, }; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::{collections::BTreeMap, sync::Arc}; -lazy_static! { +/// The figure below is a Cell that can contain 1 character, divided into 32 equal small rectangles called CellGrid. +/// ```ignore +/// 0 1 2 3 4 B C D +/// 0┌─┬─┬─┬─┐ A┌─┬─┬─┬─┐E +/// 1├─┼─┼─┼─┤ │ │ │ │ │ +/// 2├─┼─┼─┼─┤ F├─G─H─I─┤J +/// 3├─┼─┼─┼─┤ │ │ │ │ │ +/// 4├─┼─┼─┼─┤ K├─L─M─N─┤O +/// 5├─┼─┼─┼─┤ │ │ │ │ │ +/// 6├─┼─┼─┼─┤ P├─Q─R─S─┤T +/// 7├─┼─┼─┼─┤ │ │ │ │ │ +/// 8└─┴─┴─┴─┘ U└─┴─┴─┴─┘Y +/// ``` V W X - /// The figure below is a Cell that can contain 1 character, divided into 32 equal small rectangles called CellGrid. - /// ```ignore - /// 0 1 2 3 4 B C D - /// 0┌─┬─┬─┬─┐ A┌─┬─┬─┬─┐E - /// 1├─┼─┼─┼─┤ │ │ │ │ │ - /// 2├─┼─┼─┼─┤ F├─G─H─I─┤J - /// 3├─┼─┼─┼─┤ │ │ │ │ │ - /// 4├─┼─┼─┼─┤ K├─L─M─N─┤O - /// 5├─┼─┼─┼─┤ │ │ │ │ │ - /// 6├─┼─┼─┼─┤ P├─Q─R─S─┤T - /// 7├─┼─┼─┼─┤ │ │ │ │ │ - /// 8└─┴─┴─┴─┘ U└─┴─┴─┴─┘Y - /// ``` V W X +pub static ASCII_PROPERTIES: Lazy<BTreeMap<char, Property>> = Lazy::new(|| { + let cell = Cell::new(0, 0); - pub static ref ASCII_PROPERTIES: BTreeMap<char, Property> = { - #![allow(unused)] + let a = CellGrid::a(); + let b = CellGrid::b(); + let c = CellGrid::c(); + let d = CellGrid::d(); + let e = CellGrid::e(); + let f = CellGrid::f(); + let g = CellGrid::g(); + let h = CellGrid::h(); + let i = CellGrid::i(); + let j = CellGrid::j(); + let k = CellGrid::k(); + let l = CellGrid::l(); + let m = CellGrid::m(); + let n = CellGrid::n(); + let o = CellGrid::o(); + let p = CellGrid::p(); + let q = CellGrid::q(); + let r = CellGrid::r(); + let s = CellGrid::s(); + let t = CellGrid::t(); + let u = CellGrid::u(); + let v = CellGrid::v(); + let w = CellGrid::w(); + let x = CellGrid::x(); + let y = CellGrid::y(); - let cell = Cell::new(0,0); + /// cellgrids that have no names + /// just name them with coordinate locations + let _01 = CellGrid::point(0, 1); + let _11 = CellGrid::point(1, 1); + let _21 = CellGrid::point(2, 1); + let _31 = CellGrid::point(3, 1); + let _41 = CellGrid::point(4, 1); + let _03 = CellGrid::point(0, 3); + let _13 = CellGrid::point(1, 3); + let _23 = CellGrid::point(2, 3); + let _33 = CellGrid::point(3, 3); + let _43 = CellGrid::point(4, 3); + let _05 = CellGrid::point(0, 5); + let _15 = CellGrid::point(1, 5); + let _25 = CellGrid::point(2, 5); + let _35 = CellGrid::point(3, 5); + let _45 = CellGrid::point(4, 5); + let _07 = CellGrid::point(0, 7); + let _17 = CellGrid::point(1, 7); + let _27 = CellGrid::point(2, 7); + let _37 = CellGrid::point(3, 7); + let _47 = CellGrid::point(4, 7); - let a = CellGrid::a(); - let b = CellGrid::b(); - let c = CellGrid::c(); - let d = CellGrid::d(); - let e = CellGrid::e(); - let f = CellGrid::f(); - let g = CellGrid::g(); - let h = CellGrid::h(); - let i = CellGrid::i(); - let j = CellGrid::j(); - let k = CellGrid::k(); - let l = CellGrid::l(); - let m = CellGrid::m(); - let n = CellGrid::n(); - let o = CellGrid::o(); - let p = CellGrid::p(); - let q = CellGrid::q(); - let r = CellGrid::r(); - let s = CellGrid::s(); - let t = CellGrid::t(); - let u = CellGrid::u(); - let v = CellGrid::v(); - let w = CellGrid::w(); - let x = CellGrid::x(); - let y = CellGrid::y(); + let unit1 = Cell::unit(1); // 0.25 + let unit1_5 = Cell::unit(1) * 1.5; // 0.375 + let unit2 = Cell::unit(2); // 0.5 + let unit3 = Cell::unit(3); // 0.75 + let unit4 = Cell::unit(4); // 1.0 + let unit5 = Cell::unit(5); // 1.25 + let unit6 = Cell::unit(6); // 1.5 + let unit7 = Cell::unit(7); // 1.75 + let unit8 = Cell::unit(8); // 2.0 - /// cellgrids that have no names - /// just name them with coordinate locations - let _01 = CellGrid::point(0, 1); - let _11 = CellGrid::point(1, 1); - let _21 = CellGrid::point(2, 1); - let _31 = CellGrid::point(3, 1); - let _41 = CellGrid::point(4, 1); - let _03 = CellGrid::point(0, 3); - let _13 = CellGrid::point(1, 3); - let _23 = CellGrid::point(2, 3); - let _33 = CellGrid::point(3, 3); - let _43 = CellGrid::point(4, 3); - let _05 = CellGrid::point(0, 5); - let _15 = CellGrid::point(1, 5); - let _25 = CellGrid::point(2, 5); - let _35 = CellGrid::point(3, 5); - let _45 = CellGrid::point(4, 5); - let _07 = CellGrid::point(0, 7); - let _17 = CellGrid::point(1, 7); - let _27 = CellGrid::point(2, 7); - let _37 = CellGrid::point(3, 7); - let _47 = CellGrid::point(4, 7); + // in between 1 and 2 + let between1_2 = (unit1 + unit2) / 2.0; // 0.375 - let unit1 = Cell::unit(1); // 0.25 - let unit1_5 = Cell::unit(1) * 1.5; // 0.375 - let unit2 = Cell::unit(2); // 0.5 - let unit3 = Cell::unit(3); // 0.75 - let unit4 = Cell::unit(4); // 1.0 - let unit5 = Cell::unit(5); // 1.25 - let unit6 = Cell::unit(6); // 1.5 - let unit7 = Cell::unit(7); // 1.75 - let unit8 = Cell::unit(8); // 2.0 - - // in between 1 and 2 - let between1_2 = (unit1 + unit2) / 2.0; // 0.375 - - /// char, default static fragments, conditional fragments - let map: Vec<( - char, - Vec<(Signal, Vec<Fragment>)>, - Arc<dyn Fn(&Property, &Property, &Property, &Property, &Property, &Property, &Property, &Property) -> Vec<(bool, Vec<Fragment>)> + Sync + Send >, - )> = vec![ - /////////////// - // dash - - /////////////// - ( - '-', - vec![ - (Strong, vec![line(k, o)]), - ], - Arc::new( - move| top_left, top, top_right, left, right, bottom_left, bottom, bottom_right| { - vec![ - (true, vec![line(k,o)]), - ] - } - ) + /// char, default static fragments, conditional fragments + let map: Vec<( + char, + Vec<(Signal, Vec<Fragment>)>, + Arc< + dyn Fn( + &Property, + &Property, + &Property, + &Property, + &Property, + &Property, + &Property, + &Property, + ) -> Vec<(bool, Vec<Fragment>)> + + Sync + + Send, + >, + )> = vec![ + /////////////// + // dash - + /////////////// + ( + '-', + vec![(Strong, vec![line(k, o)])], + Arc::new( + move |top_left, + top, + top_right, + left, + right, + bottom_left, + bottom, + bottom_right| { + vec![(true, vec![line(k, o)])] + }, ), - /////////////// - // tilde ~ - /////////////// - ( - '~', - vec![ - (Strong, vec![broken_line(k, o)]), - ], - Arc::new( - move|top_left, top, top_right, left, right, bottom_left, bottom, bottom_right| { - vec![ - (true, vec![broken_line(k, o)]), - ] - } - ) + ), + /////////////// + // tilde ~ + /////////////// + ( + '~', + vec![(Strong, vec![broken_line(k, o)])], + Arc::new( + move |top_left, + top, + top_right, + left, + right, + bottom_left, + bottom, + bottom_right| { + vec![(true, vec![broken_line(k, o)])] + }, ), - //////////////////// - // vertical line | - //////////////////// - ( - '|', - vec![ - (Strong, vec![line(c,w)]), - ], - Arc::new( - move|top_left, top, top_right, left, right, bottom_left, bottom, bottom_right| { - vec![ - (!bottom_left.is('/') && !bottom_right.is('\\') && !top_left.is('\\') && !top_right.is('/'), vec![line(c,w)]), - // _ - // | - (top_right.line_overlap(u, v), vec![line(c,e)]), - // _ - // | - (top_left.line_overlap(x, y), vec![line(a,c)]), - // |_ - (right.line_overlap(u,v), vec![line(w,y)]), - // _| - (left.line_overlap(x,y), vec![line(u,w)]), - // |- - (right.line_strongly_overlap(k,l), vec![line(m,o)]), - // -| - (left.line_strongly_overlap(n,o), vec![line(k,m)]), - // TODO: restrict lef, right, bottom, top_right, is not connecting to - // here - // | - // / - (bottom_left.line_overlap(e,u), vec![line(c,m),line(m,u)]), - // TODO: restrict left, right, bottom, top_left, top_right - // | - // \ - (bottom_right.line_overlap(a,y), vec![line(c,m), line(m,y)]), - // TODO: restrict left, right, top, bottom_left, bottom_right - // \ / - // | - (top_left.line_overlap(a,y) && top_right.line_overlap(e,u), vec![line(a,m),line(m,w),line(m,e)]), - ] - } - ) + ), + //////////////////// + // vertical line | + //////////////////// + ( + '|', + vec![(Strong, vec![line(c, w)])], + Arc::new( + move |top_left, + top, + top_right, + left, + right, + bottom_left, + bottom, + bottom_right| { + vec![ + ( + !bottom_left.is('/') + && !bottom_right.is('\\') + && !top_left.is('\\') + && !top_right.is('/'), + vec![line(c, w)], + ), + // _ + // | + (top_right.line_overlap(u, v), vec![line(c, e)]), + // _ + // | + (top_left.line_overlap(x, y), vec![line(a, c)]), + // |_ + (right.line_overlap(u, v), vec![line(w, y)]), + // _| + (left.line_overlap(x, y), vec![line(u, w)]), + // |- + (right.line_strongly_overlap(k, l), vec![line(m, o)]), + // -| + (left.line_strongly_overlap(n, o), vec![line(k, m)]), + // TODO: restrict lef, right, bottom, top_right, is not connecting to + // here + // | + // / + ( + bottom_left.line_overlap(e, u), + vec![line(c, m), line(m, u)], + ), + // TODO: restrict left, right, bottom, top_left, top_right + // | + // \ + ( + bottom_right.line_overlap(a, y), + vec![line(c, m), line(m, y)], + ), + // TODO: restrict left, right, top, bottom_left, bottom_right + // \ / + // | + ( + top_left.line_overlap(a, y) + && top_right.line_overlap(e, u), + vec![line(a, m), line(m, w), line(m, e)], + ), + ] + }, ), - //////////////////// - // exclamation bang ! - //////////////////// - ( - '!', - vec![ - (Strong, vec![broken_line(c,w)]), - ], - Arc::new( - move| top_left, top, top_right, left, right, bottom_left, bottom, bottom_right| { - vec![ - (top.line_strongly_overlap(r,w) || bottom.line_strongly_overlap(c,h), vec![broken_line(c,w)]), - ] - } - ) + ), + //////////////////// + // exclamation bang ! + //////////////////// + ( + '!', + vec![(Strong, vec![broken_line(c, w)])], + Arc::new( + move |top_left, + top, + top_right, + left, + right, + bottom_left, + bottom, + bottom_right| { + vec![( + top.line_strongly_overlap(r, w) + || bottom.line_strongly_overlap(c, h), + vec![broken_line(c, w)], + )] + }, ), - //////////////////// - // colon : - //////////////////// - ( - ':', - vec![ - (Strong, vec![broken_line(c,w)]), - ], - Arc::new( - move| top_left, top, top_right, left, right, bottom_left, bottom, bottom_right| { - vec![ - (top.line_strongly_overlap(r,w) || bottom.line_strongly_overlap(c,h), vec![broken_line(c,w)]), - ] - } - ) + ), + //////////////////// + // colon : + //////////////////// + ( + ':', + vec![(Strong, vec![broken_line(c, w)])], + Arc::new( + move |top_left, + top, + top_right, + left, + right, + bottom_left, + bottom, + bottom_right| { + vec![( + top.line_strongly_overlap(r, w) + || bottom.line_strongly_overlap(c, h), + vec![broken_line(c, w)], + )] + }, ), - ///////////////////////// - // plus cross + - ///////////////////////// - ( |