svg_path_editor.sub_path_bounds#

Functions#

find_previous_move_to(svg, index)

Find the index of the nearest preceding M command.

find_next_move_to(svg, index)

Find the index of the next M command after the given item.

get_sub_path_bounds(svg[, index])

Compute the half-open slice bounds of the subpath containing a given item.

Module Contents#

svg_path_editor.sub_path_bounds.find_previous_move_to(svg, index)[source]#

Find the index of the nearest preceding M command.

Parameters:
  • svg (SvgPath) – Path whose items are inspected.

  • index (int) – Starting index (inclusive) from which to search backwards.

Returns:

Index of the previous M item, or 0 if none is found.

Return type:

int

svg_path_editor.sub_path_bounds.find_next_move_to(svg, index)[source]#

Find the index of the next M command after the given item.

Parameters:
  • svg (SvgPath) – Path whose items are inspected.

  • index (int) – Starting index (exclusive) from which to search forwards.

Returns:

Index of the next M item, or len(svg.path) if none is found.

Return type:

int

svg_path_editor.sub_path_bounds.get_sub_path_bounds(svg, index=None)[source]#

Compute the half-open slice bounds of the subpath containing a given item.

Parameters:
  • svg (SvgPath) – Path whose subpath bounds are computed.

  • index (int | None) – Item index inside the target subpath, or None to get bounds of the entire path.

Returns:

(start, end) indices suitable for slicing svg.path[start:end].

Return type:

tuple[int, int]