From 414990bb53f5c9e2028d42db46fa641fa606cd86 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 7 Mar 2023 17:15:49 +0100 Subject: works --- lvc/src/debug.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lvc/src/debug.rs (limited to 'lvc/src/debug.rs') 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 }; +} -- cgit v1.2.3-70-g09d2