summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJovansonlee Cesar <ivanceras@gmail.com>2021-06-30 09:36:26 +0800
committerJovansonlee Cesar <ivanceras@gmail.com>2021-06-30 09:36:26 +0800
commit963f51cbcda42c5e7453da3447b1d2aab0893cb6 (patch)
tree6009fe8220ff320d8acbfb017c7807f9bc44ece1
parent6f3b8985afb3d7e9cbbcc655604ddba10ea03c2b (diff)
Add DIAMETER_CIRCLE lookup
-rw-r--r--svgbob/TODO.md1
-rw-r--r--svgbob/src/buffer/cell_buffer/span.rs2
-rw-r--r--svgbob/src/map.rs1
-rw-r--r--svgbob/src/map/circle_map.rs11
-rw-r--r--svgbob/test_data/simple.bob5
5 files changed, 19 insertions, 1 deletions
diff --git a/svgbob/TODO.md b/svgbob/TODO.md
index 1a28791..852008d 100644
--- a/svgbob/TODO.md
+++ b/svgbob/TODO.md
@@ -17,3 +17,4 @@
When there is 2 arrows in the middle of a line `---->>-------` or `----<<----`
- [ ] Clean the project enforce deny warnings.
- [ ] Fix a bug where an escaped text has whitespaces, the whitespaces are gone.
+- [ ] Remove support for circle art
diff --git a/svgbob/src/buffer/cell_buffer/span.rs b/svgbob/src/buffer/cell_buffer/span.rs
index c2a1491..8cbf2ab 100644
--- a/svgbob/src/buffer/cell_buffer/span.rs
+++ b/svgbob/src/buffer/cell_buffer/span.rs
@@ -15,7 +15,7 @@ use std::{
/// A describes where a char came from relative to the source ascii text
/// The primary purpose of span is to group adjacent cell together
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub struct Span(Vec<(Cell, char)>);
impl Deref for Span {
diff --git a/svgbob/src/map.rs b/svgbob/src/map.rs
index 7cbea3d..e3ed914 100644
--- a/svgbob/src/map.rs
+++ b/svgbob/src/map.rs
@@ -1,5 +1,6 @@
pub use ascii_map::ASCII_PROPERTIES;
pub use circle_map::CIRCLES_SPAN;
+pub use circle_map::DIAMETER_CIRCLE;
pub use unicode_map::{
FRAGMENTS_UNICODE, UNICODE_FRAGMENTS, UNICODE_PROPERTIES,
};
diff --git a/svgbob/src/map/circle_map.rs b/svgbob/src/map/circle_map.rs
index 9d89725..855d1fc 100644
--- a/svgbob/src/map/circle_map.rs
+++ b/svgbob/src/map/circle_map.rs
@@ -257,6 +257,17 @@ lazy_static! {
})
);
+ /// map of circle spans and their radius
+ pub static ref DIAMETER_CIRCLE: BTreeMap<i32,Span> =BTreeMap::from_iter(
+ CIRCLE_MAP.iter().map(|(art, _center_cell, center, radius)|{
+ let cb = CellBuffer::from(*art);
+ let mut spans = cb.group_adjacents();
+ assert_eq!(spans.len(), 1);
+ let span = spans.remove(0).localize();
+ ((*radius * 2.0) as i32, span)
+ })
+ );
+
/// There is only 1 span per circle, and localized
pub static ref CIRCLES_SPAN: BTreeMap<Circle, Span> = BTreeMap::from_iter(
CIRCLE_MAP.iter().map(|(art, _center_cell, center, radius)|{
diff --git a/svgbob/test_data/simple.bob b/svgbob/test_data/simple.bob
index 6142ca4..bec0f56 100644
--- a/svgbob/test_data/simple.bob
+++ b/svgbob/test_data/simple.bob
@@ -1,6 +1,11 @@
+ ------>
+
+ <------
+
+
.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
! :
! +------+ .------. .------. .--------------------------. :