aboutsummaryrefslogtreecommitdiff
path: root/lvc/src/decode.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lvc/src/decode.rs')
-rw-r--r--lvc/src/decode.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/lvc/src/decode.rs b/lvc/src/decode.rs
new file mode 100644
index 0000000..b4f2391
--- /dev/null
+++ b/lvc/src/decode.rs
@@ -0,0 +1,20 @@
+use crate::{split::split, Block, Frame, View, P2};
+
+pub fn decode(last_frame: &Frame, frame: &mut Frame, view: View, block: &Block) {
+ match block {
+ Block::Lit(pxs) => frame.import(view, &pxs),
+ Block::Split([a, b]) => {
+ let [av, bv] = split(view);
+ decode(last_frame, frame, av, &a);
+ decode(last_frame, frame, bv, &b);
+ }
+ Block::Ref(r) => {
+ for y in view.a.y..view.b.y {
+ for x in view.a.x..view.b.x {
+ let p = P2 { x, y };
+ frame[p] = last_frame[p + r.pos_off] + r.color_off
+ }
+ }
+ }
+ }
+}