tex-packer-core 0.2.0

Core algorithms and API for packing images into texture atlases (Skyline / MaxRects / Guillotine). Returns pages (RGBA) and metadata (JSON/Plist/templates).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::model::{Frame, Rect};

pub mod guillotine;
pub mod maxrects;
pub mod skyline;

/// A packer places rectangles into a page.
///
/// Implementations must ensure no overlaps and respect the configured border/padding.
/// `pack` may return `None` if the rectangle cannot be placed on the current page.
pub trait Packer<K> {
    fn can_pack(&self, rect: &Rect) -> bool;
    fn pack(&mut self, key: K, rect: &Rect) -> Option<Frame<K>>;
}