type Pos = [f32; 2];
#[derive(Clone, Copy, Debug)]
pub struct AtlasRegion {
pub xy: Pos,
pub x2y: Pos,
pub x2y2: Pos,
pub xy2: Pos
}
impl AtlasRegion {
pub fn map_uvs(&self, u: f32, v: f32) -> [f32; 2] {
let w = self.x2y[0] - self.xy[0];
let h = self.xy2[1] - self.xy[1];
[
self.xy[0] + w * u,
self.xy[1] + h * v
]
}
}
pub trait Atlas {
fn get(&self, name: &str) -> Option<&AtlasRegion>;
}