svg_path_editor.path_round_corners#

Functions#

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

Round corners between straight segments in closed subpaths.

Module Contents#

svg_path_editor.path_round_corners.round_corners(path, radius, *, selector=lambda a, b, c: ...)[source]#

Round corners between straight segments in closed subpaths.

The input must be one or more closed subpaths M Z. Each corner between two straight segments (L/H/V/Z) at point \(B\) between \(AB\) and \(BC\) is replaced by:

  • a shortened segment from \(A\) to \(P\) on \(AB\),

  • a circular arc from \(P\) to \(Q\) with radius radius,

  • a shortened segment from \(Q\) to \(C\) on \(BC\).

Only corners with straight incoming and outgoing segments are modified. The input path is not modified.

Parameters:
  • path (SvgPath) – SvgPath with one or more closed subpaths M Z.

  • radius (Number) – Corner radius; must be positive.

  • selector (Callable[[Point, Point, Point], bool]) – Optional selector(a, b, c) -> bool; if it returns False for corner \(B\) between \(AB\) and \(BC\), that corner is left unchanged.

Returns:

New SvgPath with chosen line-line corners rounded by arcs.

Raises:

ValueError – If radius is not positive.

Return type:

SvgPath