From 630a917c245844a0b56bbefad9902cdcd87103ad Mon Sep 17 00:00:00 2001 From: Micha White Date: Wed, 12 Oct 2022 13:29:42 -0400 Subject: Fixed texture bug --- src/texture.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/texture.rs') diff --git a/src/texture.rs b/src/texture.rs index 060a029..da69c77 100644 --- a/src/texture.rs +++ b/src/texture.rs @@ -82,11 +82,11 @@ pub struct TextureAtlas { } macro_rules! texture_info { - ($name: ident, $prop: ident) => { + ($name: ident, $prop: ident, $divisor: ident) => { pub fn $name(&self, id: TextureId) -> Option { let frame = self.texture_frame(id)?; let property = frame.frame.$prop; - let value = property as f32; + let value = property as f32 / self.$divisor as f32; Some(value) } }; @@ -198,10 +198,10 @@ impl TextureAtlas { self.packer.get_frame(&id) } - texture_info!(texture_width, w); - texture_info!(texture_height, h); - texture_info!(texture_x, x); - texture_info!(texture_y, y); + texture_info!(texture_width, w, width); + texture_info!(texture_height, h, height); + texture_info!(texture_x, x, width); + texture_info!(texture_y, y, height); fn fill_image(&mut self) -> ExportResult<()> { let atlas = { @@ -215,7 +215,7 @@ impl TextureAtlas { Ok(()) } - fn clear(&mut self) { + pub fn clear(&mut self) { self.packer = TexturePacker::new_skyline(TexturePackerConfig { max_width: self.width, max_height: self.height, -- cgit v1.2.3