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 }; }