type Pos = [f32; 2];

/// A region from an atlas
#[derive(Clone, Copy, Debug)]
pub struct AtlasRegion {
	pub xy: Pos,
	pub x2y: Pos,
	pub x2y2: Pos,
	pub xy2: Pos
}

impl AtlasRegion {
	/// Map UVs from [0, 1] to [x, x + w]
	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
		]
	}
}

/// A texture atlas that maps strings to regions
pub trait Atlas {
	/// Get a region from this atlas
	fn get(&self, name: &str) -> Option<&AtlasRegion>;
}
