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

    Class BestFitStripPack

    Implementation of the Best-Fit Strip Packing algorithm without rotation.

    This class provides a concrete implementation of the best-fit heuristic that places rectangles in their original orientation, finding the optimal placement that minimizes the overall strip height.

    Hierarchy

    • AbstractBestFitStripPack
      • BestFitStripPack
    Index

    Constructors

    • Creates a new best-fit strip packing instance.

      Parameters

      • stripWidth: number

        The fixed width of the packing strip.

      Returns BestFitStripPack

      TypeError if stripWidth is not a number.

      RangeError if stripWidth is not a positive number.

    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 at optimal position.

      Finds an optimal position for the rectangle by evaluating potential placements and selecting the one that minimizes the increase to the overall packed height of the strip.

      Parameters

      • width: number

        Rectangle width

      • height: number

        Rectangle height

      Returns IPlacementPoint

      Placement coordinates.

      TypeError if width or height is not a number.

      RangeError if width or height value is not positive.

      RangeError if width is larger than strip width.