BinPacker¶
Under Construction
This documentation is auto-generated, and is a work in progress. Please see the source code at https://github.com/phetsims/dot/blob/main/js/BinPacker.ts for the most up-to-date information.
Overview¶
Given a rectangular containing area, takes care of allocating and deallocating smaller rectangular "bins" that fit together inside the area and do not overlap. Optimized more for runtime CPU usage than space currently.
For example:
@author Sharfudeen Ashraf @author Jonathan Olson <jonathan.olson@colorado.edu>
Class BinPacker¶
Constructor¶
new BinPacker( bounds : Bounds2 )¶
Instance Methods¶
allocate( width : number, height : number ) : Bin | null¶
Allocates a bin with the specified width and height if possible (returning a {Bin}), otherwise returns null.
deallocate( bin : Bin )¶
Deallocates a bin, so that its area can be reused by future allocations.
@param bin - The bin that was returned from allocate().
toString() : string¶
Static Properties¶
Bin : typeof Bin¶
Class Bin¶
Constructor¶
new Bin( bounds : Bounds2, parent : Bin | null )¶
Instance Methods¶
toString() : string¶
Instance Properties¶
bounds : Bounds2¶
Our containing bounds
children : Bin[]¶
Source Code¶
See the source for BinPacker.ts in the dot repository.