texture-atlasser

Crates.iotexture-atlasser
lib.rstexture-atlasser
version0.1.1
sourcesrc
created_at2021-04-24 20:35:45.266075
updated_at2021-04-25 09:35:41.978175
descriptionEasy texture atlass creation with various options to fit different needs.
homepage
repository
max_upload_size
id389074
size32,475
(Shaddaaa)

documentation

README

Easy texture atlass creation with various options to fit different needs.

Provides a way to create texture atlasses from lists of Paths or DynamicImages.

Examples

Loading different images into atlantes and saving them afterwards:

use std::path::Path;
use texture_atlasser as ta;
fn main() -> Result<(), Box<dyn std::error::Error>>{
    let paths: Vec<&Path> = vec!(
        Path::new("image1.png"), 
        Path::new("image2.png"), 
        Path::new("image3.jpg"),
    );
    let options = ta::AtlasOptions { 
        width: 64,
        height: 64,
        margin: 5,
        max_atlantes: 2,
        try_smaller: None,
        cut_down: true,
    };
    // create the atlas
    let atlas = ta::atlas_paths(&paths, options)?;
    
    // save the atlantes
    for (i, image) in atlas.atlantes.iter().enumerate() {
        image.save(format!("atlas{}.png", i))?;
    }
    // Log the positions of the single textures inside the atlantes into the console
    for rect in atlas.rects.iter() {
        println!("{:?}", rect);
    }
    Ok(())
}

For an example loading an entire directory of images, see the examples folders.

Commit count: 0

cargo fmt