svg_path_editor.path_round_corners#

Functions#

round_corners(path, radius, *[, selector])

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 (A command) from \(P\) to \(Q\) of radius radius,

  • 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) – SvgPath containing one or more closed subpaths M Z.

  • radius (Number) – Corner rounding radius. Must be positive.

  • selector (Callable[[Point, Point, Point], bool]) – Optional callback selector(a, b, c) -> bool that decides whether to round the corner at b between the segments ab and bc. If it returns False the corner is left unchanged.

Returns:

A new SvgPath where the selected corners between line-like segments are rounded with circular arcs.

Raises:

ValueError – If radius is not positive.

Return type:

SvgPath