comparison src/th06/anm0.rs @ 643:01849ffd0180

Add an anmrenderer binary.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 02 Aug 2019 20:24:45 +0200
parents a8e0219162b6
children 7bde50132735
comparison
equal deleted inserted replaced
642:9e40bd5cc26d 643:01849ffd0180
73 pub fn from_slice(data: &[u8]) -> Result<Anm0, ()> { 73 pub fn from_slice(data: &[u8]) -> Result<Anm0, ()> {
74 // XXX: report the exact nom error instead! 74 // XXX: report the exact nom error instead!
75 let (_, anm0) = parse_anm0(data).or_else(|_| Err(()))?; 75 let (_, anm0) = parse_anm0(data).or_else(|_| Err(()))?;
76 assert_eq!(anm0.len(), 1); 76 assert_eq!(anm0.len(), 1);
77 Ok(anm0[0].clone()) 77 Ok(anm0[0].clone())
78 }
79
80 /// TODO
81 pub fn inv_size(&self) -> (f32, f32) {
82 let (x, y) = self.size;
83 (1. / x as f32, 1. / y as f32)
78 } 84 }
79 } 85 }
80 86
81 fn parse_name(i: &[u8], is_present: bool) -> IResult<&[u8], String> { 87 fn parse_name(i: &[u8], is_present: bool) -> IResult<&[u8], String> {
82 if !is_present { 88 if !is_present {