summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJovansonlee Cesar <ivanceras@gmail.com>2022-09-29 09:39:48 +0800
committerJovansonlee Cesar <ivanceras@gmail.com>2022-09-29 09:39:48 +0800
commit25fcd6eee53dc82e2c60b7a2ed21b0c0a0d1f864 (patch)
treef90506c94ea28caddc5045aa91ccd39a148b1160
parent573a76e66131888175b0e4499ae69daec4e2f828 (diff)
feat: remove multiple Polygon tag for arrow characters
-rw-r--r--packages/svgbob/src/map/ascii_map.rs5
-rw-r--r--packages/svgbob/tests/simple_shapes.rs32
2 files changed, 35 insertions, 2 deletions
diff --git a/packages/svgbob/src/map/ascii_map.rs b/packages/svgbob/src/map/ascii_map.rs
index d2c4901..6ed3033 100644
--- a/packages/svgbob/src/map/ascii_map.rs
+++ b/packages/svgbob/src/map/ascii_map.rs
@@ -16,6 +16,7 @@ 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
@@ -96,7 +97,7 @@ lazy_static! {
// in between 1 and 2
let between1_2 = (unit1 + unit2) / 2.0; // 0.375
- /// char, default fragments, conditional fragments
+ /// char, default static fragments, conditional fragments
let map: Vec<(
char,
Vec<(Signal, Vec<Fragment>)>,
@@ -931,7 +932,7 @@ lazy_static! {
////////////////////////
('V',
vec![
- (Medium, vec![polygon(vec![f,j,w], true, vec![ArrowBottom, ArrowBottomLeft, ArrowBottomRight])]),
+ (Medium, vec![polygon(vec![f,j,w], true, vec![ArrowBottom])]),
(Weak, vec![line(m,w)]),
],
Arc::new(
diff --git a/packages/svgbob/tests/simple_shapes.rs b/packages/svgbob/tests/simple_shapes.rs
index 8549c89..3313c50 100644
--- a/packages/svgbob/tests/simple_shapes.rs
+++ b/packages/svgbob/tests/simple_shapes.rs
@@ -52,3 +52,35 @@ fn rounded_rect() {
println!("{}", svg);
assert_eq!(expected, svg);
}
+
+#[test]
+fn just_v() {
+ let bob = r#"
+ V
+ "#;
+
+ let expected = r#"<svg xmlns="http://www.w3.org/2000/svg" width="80" height="48">
+ <text x="66" y="28" >V</text>
+</svg>"#;
+
+ let svg = svgbob::to_svg_with_settings(bob, &Settings::for_debug());
+ println!("{}", svg);
+ assert_eq!(expected, svg);
+}
+
+#[test]
+fn arrow_down() {
+ let bob = r#"
+ |
+ V
+ "#;
+
+ let expected = r#"<svg xmlns="http://www.w3.org/2000/svg" width="80" height="64">
+ <line x1="68" y1="16" x2="68" y2="36" class="solid"></line>
+ <polygon points="64,36 72,36 68,48" class="filled"></polygon>
+</svg>"#;
+
+ let svg = svgbob::to_svg_with_settings(bob, &Settings::for_debug());
+ println!("{}", svg);
+ assert_eq!(expected, svg);
+}