rust/lib-hedgewars-engine/src/render/atlas.rs
changeset 15190 e2adb40c7988
parent 15186 9cf0c2f44f0e
child 15286 16bd389fc735
equal deleted inserted replaced
15189:ff397798e812 15190:e2adb40c7988
    63 impl std::fmt::Debug for UsedSpace {
    63 impl std::fmt::Debug for UsedSpace {
    64     fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
    64     fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
    65         write!(
    65         write!(
    66             f,
    66             f,
    67             "{:.2}%",
    67             "{:.2}%",
    68             self.used() as f32 / self.total() as f32 / 100.0
    68             self.used() as f32 / self.total() as f32 * 100.0
    69         )?;
    69         )?;
    70         Ok(())
    70         Ok(())
    71     }
    71     }
    72 }
    72 }
    73 
    73 
   247                 self.rects.push(((self.atlases.len() - 1) as u32, rect))
   247                 self.rects.push(((self.atlases.len() - 1) as u32, rect))
   248             }
   248             }
   249             self.consume_index()
   249             self.consume_index()
   250         }
   250         }
   251     }
   251     }
       
   252 
       
   253     pub fn used_space(&self) -> String {
       
   254         self.atlases
       
   255             .iter()
       
   256             .enumerate()
       
   257             .map(|(i, a)| format!("{}: {:?}", i, a.used_space()))
       
   258             .join("\n")
       
   259     }
   252 }
   260 }
   253 
   261 
   254 impl Index<SpriteIndex> for AtlasCollection {
   262 impl Index<SpriteIndex> for AtlasCollection {
   255     type Output = SpriteLocation;
   263     type Output = SpriteLocation;
   256 
   264