tex_packer_core/
lib.rs

1//! Core library for packing textures into atlases.
2//!
3//! - Algorithms: Skyline (BL/MW + optional Waste Map), MaxRects (BAF/BSSF/BLSF/BL/CP), Guillotine (choice + split)
4//! - Pipeline: `pack_images` takes in-memory images and returns pages + metadata
5//! - Data model is serde-serializable; exporters are provided in helpers and the CLI crate.
6//!
7//! Quick example:
8//! ```ignore
9//! use image::ImageReader;
10//! use tex_packer_core::{InputImage, PackerConfig, pack_images};
11//! # fn main() -> anyhow::Result<()> {
12//! let img1 = ImageReader::open("a.png")?.decode()?;
13//! let img2 = ImageReader::open("b.png")?.decode()?;
14//! let inputs = vec![
15//!   InputImage { key: "a".into(), image: img1 },
16//!   InputImage { key: "b".into(), image: img2 },
17//! ];
18//! let cfg = PackerConfig { max_width: 1024, max_height: 1024, ..Default::default() };
19//! let out = pack_images(inputs, cfg)?;
20//! println!("pages: {}", out.pages.len());
21//! # Ok(()) }
22//! ```
23
24pub mod compositing;
25pub mod config;
26pub mod error;
27pub mod export;
28pub mod export_plist;
29pub mod model;
30pub mod packer;
31pub mod pipeline;
32pub mod runtime;
33pub mod runtime_atlas;
34
35pub use config::*;
36pub use error::*;
37pub use export::*;
38pub use export_plist::*;
39pub use model::*;
40pub use packer::*;
41pub use pipeline::*;
42
43/// Convenience prelude for common types and functions.
44/// Importing `tex_packer_core::prelude::*` brings the primary APIs into scope.
45pub mod prelude {
46    pub use crate::config::{
47        AlgorithmFamily, AutoMode, GuillotineChoice, GuillotineSplit, MaxRectsHeuristic,
48        PackerConfig, PackerConfigBuilder, SkylineHeuristic, SortOrder,
49    };
50    pub use crate::model::{Atlas, Frame, Meta, PackStats, Page, Rect};
51    pub use crate::pipeline::LayoutItem;
52    pub use crate::runtime::{AtlasSession, RuntimeStats, RuntimeStrategy, ShelfPolicy};
53    pub use crate::runtime_atlas::{RuntimeAtlas, UpdateRegion};
54    pub use crate::{
55        InputImage, OutputPage, PackOutput, pack_images, pack_layout, pack_layout_items,
56    };
57}