C# dynamic texture atlas allocator/rectangle packer
$ dotnet add package AtlasAllocatorC# ported versions of the https://github.com/nical/etagere and https://github.com/nical/guillotiere libraries.
A pure C# implementation of dynamic texture atlas allocators for texture atlas creation and rectangle packing.
Available allocator:
using AtlasAllocator;
GuillotineAtlasAllocator allocator = new GuillotineAtlasAllocator(new Size(128, 128));
Allocation? a1 = allocator.Allocate(new Size(32, 32));
Console.WriteLine(a1.Value.Rectangle); // {X=0,Y=0,Width=32,Height=32}
Allocation? a2 = allocator.Allocate(new Size(64, 64));
Console.WriteLine(a2.Value.Rectangle); // {X=0,Y=32,Width=64,Height=64}
Allocation? a3 = allocator.Allocate(new Size(96, 96));
Console.WriteLine(a3.HasValue); // False
allocator.Deallocate(a2.Value.Id);
Allocation? a4 = allocator.Allocate(new Size(96, 96));
Console.WriteLine(a4.Value.Rectangle); // {X=0,Y=32,Width=96,Height=96}
allocator.Grow(new Size(256, 256));
Allocation? a5 = allocator.Allocate(new Size(128, 128));
Console.WriteLine(a5.Value.Rectangle); // {X=128,Y=0,Width=128,Height=128}
MIT