Expand description
Packos is a small library for packing rectangles. It was built for Tarmac, a tool that manages assets for Roblox projects, including packing images into spritesheets.
Packos currently exposes a single packing implementation,
SimplePacker
. More algorithms can be added in the future
using the same basic types that Packos uses.
§Example
use packos::{InputItem, SimplePacker};
// First, transform the rectangles you want to pack into the Packos
// InputItem type.
let my_items = &[
InputItem::new((128, 64)),
InputItem::new((64, 64)),
InputItem::new((1, 300)),
];
// Construct a packer and configure it with your constraints
let packer = SimplePacker::new().max_size((512, 512));
// Compute a solution.
// SimplePacker::pack accepts anything that can turn into an iterator of
// InputItem or &InputItem.
let output = packer.pack(my_items);
Structs§
- Bucket
- Contains a set of
OutputItem
values that were packed together into the same fixed-size containers. - Id
- Represents an item tracked by Packos.
- Input
Item - An input to the rectangle packing routines.
- Output
Item - An item that was placed by a packing function.
- Pack
Output - The results from running a packing function.
- Simple
Packer - A configurable rectangle packer using a simple packing algorithm.