#![warn(missing_docs)] //! This crate creates texture atlases from an asset tree. //! The main interface for this crate is ... TODO use std::{collections::HashMap, path::PathBuf}; use serde::{Deserialize, Serialize}; /// The location of a single image in a sprite atlas #[derive(Debug, Serialize, Deserialize, Clone)] pub struct SpriteAtlasImage { /// The index of the atlas this image is in pub atlas: usize, /// x-position of this image /// (between 0 and 1, using wgpu texture coordinates) pub x: f32, /// y-position of this image /// (between 0 and 1, using wgpu texture coordinates) pub y: f32, /// Width of this image /// (between 0 and 1, using wgpu texture coordinates) pub w: f32, /// Height of this image /// (between 0 and 1, using wgpu texture coordinates) pub h: f32, } /// A map between file paths (relative to the root asset dir) /// and [`AtlasTexture`]s. #[derive(Debug, Serialize, Deserialize, Clone)] pub struct SpriteAtlas { /// The images in this atlas pub index: HashMap, } impl SpriteAtlas { /// Make an empty [`SpriteAtlasIndex`] pub fn new() -> Self { Self { index: HashMap::new(), } } }