best-fit-strip-pack - v1.1.0
    Preparing search index...

    Class BestFitStripPackRotatable

    Implementation of the Best-Fit Strip Packing algorithm with rotation support.

    This class provides a concrete implementation of the best-fit heuristic that automatically considers both orientations of each rectangle (original and rotated) to find the optimal placement that minimizes the overall strip height.

    Hierarchy

    • AbstractBestFitStripPackRotatable
      • BestFitStripPackRotatable
    Index

    Constructors

    Accessors

    • get packedHeight(): number

      Gets the current total height of the packed strip.

      This represents the vertical space used by all placed rectangles and is updated after each rectangle insertion.

      Returns number

    • get packedWidth(): number

      Gets the current total width of the packed strip.

      This represents the horizontal space used by all placed rectangles and is updated after each rectangle insertion.

      Returns number

    • get stripWidth(): number

      Gets the fixed width of the strip.

      This is the maximum allowable width for any rectangle to be inserted.

      Returns number

    Methods

    • Inserts a rectangle into the strip, considering both orientations.

      The algorithm evaluates both the original orientation (width × height) and the rotated orientation (height × width) to determine which provides better packing efficiency. The orientation and placement that results in the smallest overall height increase is selected.

      Parameters

      • width: number

        Rectangle width

      • height: number

        Rectangle height

      Returns IPlacementPointRotatable

      Placement coordinates and rotation flag.

      TypeError if width or height is not a number.

      RangeError if width or height value is not positive.

      RangeError if both width and height exceed the strip width.