svg_path_editor.path_round_corners#
Functions#
|
Round the corners between straight-line segments in closed subpaths. |
Module Contents#
- svg_path_editor.path_round_corners.round_corners(path, radius, *, selector=lambda a, b, c: ...)[source]#
Round the corners between straight-line segments in closed subpaths.
The input must be a sequence of closed subpaths
M … Z. Every corner between two straight line segments (L/H/V/Z) is replaced by:a shortened segment from \(A\) to \(P\) (on \(AB\)),
a circular arc (
Acommand) from \(P\) to \(Q\) of radiusradius,a shortened segment from \(Q\) to \(C\) (on \(BC\)),
where the corner is at point \(B\) between segments \(AB\) and \(BC\).
Only corners with both adjacent segments line-like are processed. The original path is not modified.
- Parameters:
path (SvgPath) –
SvgPathcontaining one or more closed subpathsM … Z.radius (Number) – Corner rounding radius. Must be positive.
selector (Callable[[Point, Point, Point], bool]) – Optional callback
selector(a, b, c) -> boolthat decides whether to round the corner atbbetween the segmentsabandbc. If it returnsFalsethe corner is left unchanged.
- Returns:
A new
SvgPathwhere the selected corners between line-like segments are rounded with circular arcs.- Raises:
ValueError – If
radiusis not positive.- Return type: