diff options
| author | Micha White <botahamec@outlook.com> | 2022-10-12 13:29:42 -0400 |
|---|---|---|
| committer | Micha White <botahamec@outlook.com> | 2022-10-12 13:29:42 -0400 |
| commit | 630a917c245844a0b56bbefad9902cdcd87103ad (patch) | |
| tree | 3cd3528a5475d84b839642a6a23e6b0686890bd1 /src/texture.rs | |
| parent | b15126ef266cc9e364e9fe155fd6941779249579 (diff) | |
Fixed texture bug
Diffstat (limited to 'src/texture.rs')
| -rw-r--r-- | src/texture.rs | 14 |
1 files changed, 7 insertions, 7 deletions
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<f32> { 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, |
