summaryrefslogtreecommitdiff
path: root/src/texture.rs
diff options
context:
space:
mode:
authorMicha White <botahamec@outlook.com>2022-10-12 13:29:42 -0400
committerMicha White <botahamec@outlook.com>2022-10-12 13:29:42 -0400
commit630a917c245844a0b56bbefad9902cdcd87103ad (patch)
tree3cd3528a5475d84b839642a6a23e6b0686890bd1 /src/texture.rs
parentb15126ef266cc9e364e9fe155fd6941779249579 (diff)
Fixed texture bug
Diffstat (limited to 'src/texture.rs')
-rw-r--r--src/texture.rs14
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,