@pixi-essentials/area-allocator
This package implements an area allocator that can be used to issue texture space. It provides the following
implementations:
- GuilloteneAllocator: This maintains a tree of rectangular area nodes that are divided either horizontally or
vertically in a flip-flop fashion. The allocated area is picked from the tightest fit, after which the original
area is sliced. Sibling areas are merged when both are freed. This implementation was inspired the guillotiere crate.
Installation :package:
npm install @pixi-essentials/area-allocator
Usage :page_facing_up:
import { GuilloteneAllocator } from '@pixi-essentials/area-allocator';
import type { AreaAllocator } from '@pixi-essentials/area-allocator';
const spatialAllocator: AreaAllocator = new GuilloteneAllocator(1024, 1024);
const space = spatialAllocator.allocate(128, 256);
spatialAllocator.free(space);