Guillotiere
A dynamic texture atlas allocator with fast deallocation and rectangle coalescing.
Install / Use
/learn @nical/GuillotiereREADME
Guillotière
<p align="center"> <a href="https://crates.io/crates/guillotiere"> <img src="https://img.shields.io/crates/v/guillotiere.svg" alt="crates.io"> </a> <a href="https://github.com/nical/guillotiere/actions"> <img src="https://github.com/nical/guillotiere/actions/workflows/main.yml/badge.svg" alt="Build Status"> </a> <a href="https://docs.rs/guillotiere"> <img src="https://docs.rs/guillotiere/badge.svg" alt="documentation"> </a> </p>A dynamic texture atlas allocator with fast deallocation and rectangle coalescing.
Motivation
The ability to dynamically batch textures together is important for some graphics rendering scenarios (for example WebRender). A challenging aspect of dynamic atlas allocation is the need to coalesce free rectangles after deallocation to defragment the available space. Some atlas allocators perform this task by examining all possible pairs of free rectangles and test if they can be merged, which is prohibitively expensive for real-time applications.
Guillotière solves this problem by internally maintaining a data structure that allows constant time access to neighbor rectangles and greatly speeds up the coalesing operation.
The details of how this works are explained in the AtlasAllocator documentation.
Example
use guillotiere::*;
let mut atlas = AtlasAllocator::new(size2(1000, 1000));
let a = atlas.allocate(size2(100, 1000)).unwrap();
let b = atlas.allocate(size2(900, 200)).unwrap();
atlas.deallocate(a.id);
let c = atlas.allocate(size2(300, 200)).unwrap();
assert_eq!(c.rectangle, atlas[c.id]);
atlas.deallocate(c.id);
atlas.deallocate(b.id);
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/license/mit)
at your option.
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
