diff options
Diffstat (limited to 'evc/src/block.rs')
-rw-r--r-- | evc/src/block.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/evc/src/block.rs b/evc/src/block.rs index 8daba5c..d0dd4d5 100644 --- a/evc/src/block.rs +++ b/evc/src/block.rs @@ -3,13 +3,14 @@ use anyhow::bail; use crate::{ pixel::Pixel, ser::{Ser, Sink, Source}, + vec2::Vec2, }; #[derive(Clone, Debug)] pub enum Block { Literal(Vec<Pixel>), Split(Box<[Block; 2]>), - Reference { translation: (usize, usize) }, + Reference { translation: Vec2 }, } impl Block { @@ -32,20 +33,20 @@ impl Block { Ok(()) } - pub fn read(source: &mut impl std::io::Read, size: (usize, usize)) -> anyhow::Result<Self> { + pub fn read(source: &mut impl std::io::Read, size: Vec2) -> anyhow::Result<Self> { Ok(match source.get::<u8>()? { 0 => Block::Literal(source.get()?), 1 => Block::Split(Box::new({ - let vert = size.0 > size.1; + let vert = size.x > size.y; let asize = if vert { - (size.0 / 2, size.1) + (size.x / 2, size.y).into() } else { - (size.0, size.1 / 2) + (size.x, size.y / 2).into() }; let bsize = if vert { - (size.0 - size.0 / 2, size.1) + (size.x - size.x / 2, size.y).into() } else { - (size.0, size.1 - size.1 / 2) + (size.x, size.y - size.y / 2).into() }; let a = Block::read(source, asize)?; @@ -53,7 +54,7 @@ impl Block { [a, b] })), 2 => Block::Reference { - translation: (0, 0), //source.get()?, + translation: Vec2::ZERO, //source.get()?, }, x => bail!("corrupt block type ({})", x), }) |