Table of Contents

Class GuillotinePacker

Namespace
Stride.Core.Mathematics
Assembly
Stride.Core.Mathematics.dll

Implementation of a "Guillotine" packer. More information at http://clb.demon.fi/files/RectangleBinPack.pdf.

public class GuillotinePacker
Inheritance
GuillotinePacker

Properties

Height

Current height used by the packer.

public int Height { get; }

Property Value

int

Width

Current width used by the packer.

public int Width { get; }

Property Value

int

Methods

Clear()

Clears the whole region.

public virtual void Clear()

Clear(int, int)

Clears the specified region.

public void Clear(int width, int height)

Parameters

width int

The width.

height int

The height.

Free(ref Rectangle)

Frees the specified old rectangle.

public void Free(ref Rectangle oldRectangle)

Parameters

oldRectangle Rectangle

The old rectangle.

Insert(int, int, ref Rectangle)

Tries to fit a single rectangle with the specified width and height.

public bool Insert(int width, int height, ref Rectangle bestRectangle)

Parameters

width int

Width requested.

height int

Height requested

bestRectangle Rectangle

Fill with the rectangle if it was successfully inserted.

Returns

bool

true if it was successfully inserted.

TryInsert(int, int, int, InsertRectangleCallback)

Tries to fit multiple rectangle with (width, height).

public bool TryInsert(int width, int height, int count, GuillotinePacker.InsertRectangleCallback inserted)

Parameters

width int

Width requested.

height int

Height requested

count int

The number of rectangle to fit.

inserted GuillotinePacker.InsertRectangleCallback

A callback called for each rectangle successfully fitted.

Returns

bool

true if all rectangles were successfully fitted.