aboutsummaryrefslogtreecommitdiff
path: root/lvc/src/debug.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lvc/src/debug.rs')
-rw-r--r--lvc/src/debug.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/lvc/src/debug.rs b/lvc/src/debug.rs
new file mode 100644
index 0000000..9959e9a
--- /dev/null
+++ b/lvc/src/debug.rs
@@ -0,0 +1,30 @@
+use crate::{split::split, Block, Frame, Pixel, View, P2};
+
+pub fn draw_debug(frame: &mut Frame, view: View, block: &Block) {
+ match block {
+ Block::Lit(_) => rect(frame, view, Pixel::GREEN),
+ Block::Split([a, b]) => {
+ let [av, bv] = split(view);
+ draw_debug(frame, av, &a);
+ draw_debug(frame, bv, &b);
+ }
+ Block::Ref(_r) => {}
+ }
+}
+
+fn rect(frame: &mut Frame, view: View, color: Pixel) {
+ for x in view.a.x..view.b.x {
+ frame[P2 { x, y: view.a.y }] = color;
+ frame[P2 { x, y: view.b.y - 1 }] = color;
+ }
+ for y in view.a.y..view.b.y {
+ frame[P2 { y, x: view.a.x }] = color;
+ frame[P2 { y, x: view.b.x - 1 }] = color;
+ }
+}
+
+impl Pixel {
+ pub const RED: Pixel = Pixel { r: 255, g: 0, b: 0 };
+ pub const GREEN: Pixel = Pixel { r: 0, g: 255, b: 0 };
+ pub const BLUE: Pixel = Pixel { r: 0, g: 0, b: 255 };
+}