NodeBox | Clamping paths

Clamping paths

Paths in NodeBox can be forced to fit a bounding box. Then as the size of the box is adjusted the path will stretch accordingly. This reverse logic is useful in some situations where a path needs to exactly fit an area and we don't want to be bothered with creating the shape in exactly the right proportions or at the right position.

path.fit(x=None, y=None, width=None, height=None, stretch=False)

All of the parameters are optional so you can define any combination of them:

  • x: the path will be positioned at the specified x value.
  • y: the path will be positioned at the specified y value.
  • width: the path will be of the specified width.
  • height: the path will be of the specified height.
  • stretch: if both width and height are defined, either stretch the path or keep the aspect ratio.