Natural Performance Manager
    Wondering what’s next for npm?Check out our public roadmap! »

    @pixi-essentials/area-allocator
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.2 • Public • Published

    @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 📦

    npm install @pixi-essentials/area-allocator

    Usage 📄

    import { GuilloteneAllocator } from '@pixi-essentials/area-allocator';
    
    import type { AreaAllocator } from '@pixi-essentials/area-allocator';
    
    // A guillotene allocator that can manage 2D space
    const spatialAllocator: AreaAllocator = new GuilloteneAllocator(1024, 1024);
    
    // Rectange-area allocated by the allocator. The returned object has a __mem_area property that
    // points to a area node that is required to free this area.
    const space = spatialAllocator.allocate(128, 256);
    
    // Free the 2D space after using. NOTE: This must be the same rectangle passed by "allocate", or you
    // must also copy the __mem_area property.
    spatialAllocator.free(space);

    Install

    npm i @pixi-essentials/area-allocator

    DownloadsWeekly Downloads

    106

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    222 kB

    Total Files

    11

    Last publish

    Collaborators

    • avatar