diff options
Diffstat (limited to 'evc/src/block.rs')
-rw-r--r-- | evc/src/block.rs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/evc/src/block.rs b/evc/src/block.rs index 3a37820..0a7ace3 100644 --- a/evc/src/block.rs +++ b/evc/src/block.rs @@ -1,16 +1,23 @@ use anyhow::bail; use crate::{ - format::ser::{Ser, Sink, Source, Small}, - helpers::pixel::Pixel, + format::ser::{Ser, Sink, Small, Source}, helpers::vector::Vec2, + helpers::{matrix::Mat2, pixel::Pixel}, }; #[derive(Clone, Debug)] pub enum Block { Literal(Vec<Pixel>), Split(Box<[Block; 2]>), - Reference { translation: Vec2<isize> }, + Reference { + translation: Vec2<isize>, + }, + AdvancedReference { + translation: Vec2<i8>, + transform: Mat2<i8>, + value_scale: i8, + }, } impl Block { @@ -29,6 +36,14 @@ impl Block { sink.put(2u8)?; sink.put(Small(*translation))?; } + Block::AdvancedReference { + translation, + transform, + value_scale, + } => { + sink.put(3u8)?; + sink.put((*translation, *transform, *value_scale))?; + } } Ok(()) } @@ -56,6 +71,11 @@ impl Block { 2 => Block::Reference { translation: source.get::<Small<Vec2<isize>>>()?.0, }, + 3 => Block::AdvancedReference { + translation: source.get()?, + transform: source.get()?, + value_scale: source.get()?, + }, x => bail!("corrupt block type ({})", x), }) } |