mod batch;
mod builder;
mod loader;
pub use batch::Batch;
pub use builder::Builder;
pub use loader::{Indices, Key, Loader};
use std::fmt;
use std::path::PathBuf;
use crate::graphics::gpu::Texture;
#[derive(Debug, Clone)]
pub struct TextureArray {
texture: Texture,
x_unit: f32,
y_unit: f32,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Index {
layer: u16,
offset: Offset,
}
#[derive(Debug, Clone, Copy, PartialEq)]
struct Offset {
x: f32,
y: f32,
}
#[derive(Debug, Clone)]
pub enum Error {
KeyNotFound(usize),
ImageIsTooBig(PathBuf),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::KeyNotFound(key) => write!(f, "Key not found: {}", key),
Error::ImageIsTooBig(path) => {
write!(f, "Image is too big: {}", path.display())
}
}
}
}