diff --git a/RectpackSharp/RectanglePacker.cs b/RectpackSharp/RectanglePacker.cs index 76f43e6..7191b51 100644 --- a/RectpackSharp/RectanglePacker.cs +++ b/RectpackSharp/RectanglePacker.cs @@ -147,6 +147,29 @@ public static void Pack(PackingRectangle[] rectangles, out PackingRectangle boun ReturnList(emptySpaces); } +#if NET5_0_OR_GREATER + /// + /// Finds a way to pack all the given rectangles into a single bin. Performance can be traded for + /// space efficiency by using the optional parameters. + /// + /// The rectangles to pack. The result is saved onto this array. + /// The bounds of the resulting bin. This will always be at X=Y=0. + /// Specifies hints for optimizing performance. + /// Searching stops once a bin is found with this density (usedArea/boundsArea) or better. + /// The amount by which to increment/decrement size when trying to pack another bin. + /// The maximum allowed width for the resulting bin, or null for no limit. + /// The maximum allowed height for the resulting bin, or null for no limit. + /// + /// The values are never touched. Use this to identify your rectangles. + /// + public static void Pack(PackingRectangle[] rectangles, out PackingRectangle bounds, + PackingHints packingHint = PackingHints.FindBest, double acceptableDensity = 1, uint stepSize = 1, + uint? maxBoundsWidth = null, uint? maxBoundsHeight = null) + { + Pack(rectangles.AsSpan(), out bounds, packingHint, acceptableDensity, stepSize, maxBoundsWidth, maxBoundsHeight); + } +#endif + /// /// Tries to find a solution with the smallest bin size possible, packing /// the rectangles in the order in which the were provided.