diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2024-06-12 01:35:49 +0200 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2024-06-12 01:35:49 +0200 |
commit | 85dd790817e4766f120fab2335da2006b07b8134 (patch) | |
tree | 65d24f2e56c9d601630143f892c17f63443741bd | |
parent | d62459369992b2ad7824a55b1736a22de4188b1a (diff) | |
download | textgraph-85dd790817e4766f120fab2335da2006b07b8134.tar.gz textgraph-85dd790817e4766f120fab2335da2006b07b8134.zip |
Improve braille mode slightly
-rw-r--r-- | src/graph.rs | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/src/graph.rs b/src/graph.rs index 1958056..69a271d 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -393,7 +393,6 @@ impl GraphBuilder { /// Draw a graph using * for the pixels of the graph fn draw_braille(&mut self) { let mut i = 0; - let mut x = 0; while i < self.y_values.len() - 1 { let y1 = (self.draw_height * 3) - (self.y_values[i] as usize) - 1; let y1_abs = y1 / 3; @@ -402,45 +401,35 @@ impl GraphBuilder { if y1_abs == y2_abs { let px = match (y1 % 3, y2 % 3) { - (0, 0) => ' ', - (0, 1) => '⠠', - (0, 2) => '⠐', - (0, 3) => '⠈', - (1, 0) => '⠄', - (1, 1) => '⠤', - (1, 2) => '⠔', - (1, 3) => '⠌', - (2, 0) => '⠂', - (2, 1) => '⠢', - (2, 2) => '⠒', - (2, 3) => '⠊', - (3, 0) => '⠁', - (3, 1) => '⠡', - (3, 2) => '⠑', - (3, 3) => '⠉', + (0, 0) => '⠤', + (0, 1) => '⠔', + (0, 2) => '⠌', + (1, 0) => '⠢', + (1, 1) => '⠒', + (1, 2) => '⠊', + (2, 0) => '⠡', + (2, 1) => '⠑', + (2, 2) => '⠉', _ => '?', }; - self.draw(x, y1_abs, GraphPixel::Normal(px)); + self.draw(i / 2, y1_abs, GraphPixel::Normal(px)); } else { let px = match y1 % 3 { - 0 => ' ', - 1 => '⠄', - 2 => '⠂', - 3 => '⠁', + 0 => '⠄', + 1 => '⠂', + 2 => '⠁', _ => '?', }; - self.draw(x, y1_abs, GraphPixel::Normal(px)); + self.draw(i / 2, y1_abs, GraphPixel::Normal(px)); let px = match y2 % 3 { - 0 => ' ', - 1 => '⠠', - 2 => '⠐', - 3 => '⠈', + 0 => '⠠', + 1 => '⠐', + 2 => '⠈', _ => '?', }; - self.draw(x, y2_abs, GraphPixel::Normal(px)); + self.draw(i / 2, y2_abs, GraphPixel::Normal(px)); } i += 2; - x += 1; } } } |