knots.path.as_mask#
- knots.path.as_mask(knot: Knot, width: float, *, dpi: float = 200, fig_width: float = 5) ndarray[tuple[int, ...], dtype[uint8]][source]#
Generate a mask of points “in the ribbon”.
This works by rendering the path via Matplotlib and extracting a gray-scale image.
Due to anti-aliasing this is a grayscale mask as uint8. To get a binary mask, threshold at your level of choice.
- Parameters:
- knotKnot
The knot to generate mask of
- widthfloat
The width of the ribbon in points.
- dpifloat, default: 200
The dpi to render at internally
- fig_widthfloat, default: 5
The width of the transient figure used in in.
- Returns:
- maskNDArray[np.uint8]
gray-scale mask of the knot