diff options
author | metamuffin <metamuffin@disroot.org> | 2022-12-07 21:23:42 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-12-07 21:23:42 +0100 |
commit | 2ac18802b58d671c10538e78d50a620baad9a188 (patch) | |
tree | 17f924039fd8f3dae2801902d4bdeaac8ea74624 /evc/src/debug.rs | |
parent | 9d7986bbfd44b69a623fa29528b5d13000b91c77 (diff) | |
download | video-codec-experiments-2ac18802b58d671c10538e78d50a620baad9a188.tar video-codec-experiments-2ac18802b58d671c10538e78d50a620baad9a188.tar.bz2 video-codec-experiments-2ac18802b58d671c10538e78d50a620baad9a188.tar.zst |
advanced transform
Diffstat (limited to 'evc/src/debug.rs')
-rw-r--r-- | evc/src/debug.rs | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/evc/src/debug.rs b/evc/src/debug.rs index 06dd507..99723b8 100644 --- a/evc/src/debug.rs +++ b/evc/src/debug.rs @@ -1,4 +1,11 @@ -use crate::{frame::Frame, helpers::pixel::Pixel, helpers::vector::Vec2, view::View}; +use crate::{ + block::Block, + format::ser::map_scalar8, + frame::Frame, + helpers::vector::Vec2, + helpers::{matrix::Mat2, pixel::Pixel}, + view::View, +}; impl View<&mut Frame> { pub fn draw_box(&mut self, color: Pixel) { @@ -54,3 +61,47 @@ impl Pixel { b: 255, }; } + +pub fn draw_debug(block: &Block, mut target: View<&mut Frame>) { + match &block { + Block::Literal(_) => { + target.draw_box(Pixel::GREEN); + } + Block::Split(box [a, b]) => { + let [at, bt] = target.split_mut_unsafe(); + draw_debug(a, at); + draw_debug(b, bt); + } + Block::Reference { translation } => { + target.draw_box(Pixel::BLUE); + target.frame.draw_line( + target.center().into(), + (target.center() + *translation).into(), + Pixel::RED, + ) + } + Block::AdvancedReference(r) => { + let mat = Mat2 { + a: map_scalar8(r.transform.a), + b: map_scalar8(r.transform.b), + c: map_scalar8(r.transform.c), + d: map_scalar8(r.transform.d), + }; + let translation = Vec2 { + x: map_scalar8(r.translation.x), + y: map_scalar8(r.translation.y), + }; + let tl = mat.transform(translation) + target.offset.into(); + let tr = + mat.transform(translation + target.size.x_only().into()) + target.offset.into(); + let bl = + mat.transform(translation + target.size.y_only().into()) + target.offset.into(); + let br = mat.transform(translation + target.size.into()) + target.offset.into(); + target.frame.draw_line(tl, tr, Pixel::MAGENTA); + target.frame.draw_line(tr, br, Pixel::MAGENTA); + target.frame.draw_line(bl, br, Pixel::MAGENTA); + target.frame.draw_line(tl, bl, Pixel::MAGENTA); + target.draw_box(Pixel::CYAN); + } + } +} |