svg_path_editor.path_offset#
Attributes#
Extra decimal digits used when |
Classes#
Precomputed data for offsetting a simple closed path. |
|
Small bevel triangle between original and offset geometry. |
|
Planar bevel face bounded by straight segments. |
|
Planar bevel face containing an elliptical-arc boundary. |
Functions#
|
Return |
|
Validate |
|
Outgoing point of a line offset segment (after |
|
Outgoing point of an arc offset segment (after |
|
Compute the outward unit normal of an edge. |
|
Yield |
|
Handle the incoming side of an offset arc. |
|
Handle the outgoing side of an offset arc. |
|
Handle the incoming side of a straight segment. |
|
Offset a simple closed SVG path. |
|
Construct bevel faces for an offset of a simple closed path. |
Module Contents#
- type svg_path_editor.path_offset.Shape = Line | ParametricEllipticalArc#
- svg_path_editor.path_offset.additional_digits: int = 8#
Extra decimal digits used when
prec="auto".
- svg_path_editor.path_offset._all_non_none[T](elems)[source]#
Return
Trueiffelemscontains noNonevalues.- Parameters:
elems (list[T | None])
- Return type:
TypeGuard[list[T]]
- class svg_path_editor.path_offset._OffsetData[source]#
Bases:
NamedTuplePrecomputed data for offsetting a simple closed path.
- is_ccw: bool#
- inters: list[Intersection]#
- svg_path_editor.path_offset._prepare_offset_data(path, *, d, prec)[source]#
Validate
pathand compute offset segments and their intersections.- Parameters:
- Return type:
- svg_path_editor.path_offset._line_outgoing_point(inter1)[source]#
Outgoing point of a line offset segment (after
inter1).- Parameters:
inter1 (Intersection)
- Return type:
- svg_path_editor.path_offset._arc_outgoing_point(inter1)[source]#
Outgoing point of an arc offset segment (after
inter1).- Parameters:
inter1 (Intersection)
- Return type:
- svg_path_editor.path_offset.outward_normal(p0, p1, is_ccw)[source]#
Compute the outward unit normal of an edge.
- class svg_path_editor.path_offset.Tri[source]#
Bases:
NamedTupleSmall bevel triangle between original and offset geometry.
- Variables:
orig0 – Vertex on the original path.
off0 – First vertex on the offset path.
off1 – Second vertex on the offset path.
- svg_path_editor.path_offset._iter_segment_contexts(offsets, inters, items)[source]#
Yield
(orig_item, offset_geom, incoming_inter, outgoing_inter)per segment.- Parameters:
offsets (list[Shape])
inters (list[Intersection])
items (list[SvgItem])
- Return type:
collections.abc.Iterable[tuple[SvgItem, Shape, Intersection, Intersection]]
- svg_path_editor.path_offset._arc_ante(orig, inter0)[source]#
Handle the incoming side of an offset arc.
Returns the ante point on the offset arc plus bevel triangles to emit before the arc segment.
- Parameters:
orig (EllipticalArcTo)
inter0 (Intersection)
- Return type:
- svg_path_editor.path_offset._arc_post(orig, inter1)[source]#
Handle the outgoing side of an offset arc.
Yields bevel triangles to emit after the arc segment.
- Parameters:
orig (EllipticalArcTo)
inter1 (Intersection)
- Return type:
collections.abc.Iterable[Tri]
- svg_path_editor.path_offset._line_ante(orig, inter0)[source]#
Handle the incoming side of a straight segment.
Returns the ante point on the offset line plus bevel triangles to emit before the line segment.
- Parameters:
orig (SvgItem)
inter0 (Intersection)
- Return type:
- svg_path_editor.path_offset.offset_path(path, *, d, prec=None)[source]#
Offset a simple closed SVG path.
The input must be a single closed subpath
M … Zof straight lines and elliptical arcs. Every segment is offset by distanced(inwards ford > 0), and consecutive offset segments are intersected to form the output path.- Parameters:
path (SvgPath) – Closed
SvgPathwith exactly one subpathM … Z, using only line and elliptical-arc segments.d (Number) – Offset distance. Positive values move edges towards the interior.
prec (Precision | Literal['auto', 'auto-intersections'] | None) –
Intersection and offsetting precision:
"auto": decimal precision +additional_digitsfor both offset geometry and intersections."auto-intersections": same automatic precision for intersections only; offsets remain symbolic.Precision: use this precision everywhere.None: purely symbolic where supported.
- Returns:
The offset closed path.
- Raises:
AssertionError – If
pathis not a single closed subpath of the expected form, or if an offset intersection cannot be computed.- Return type:
- class svg_path_editor.path_offset.BevelPolygon[source]#
Bases:
NamedTuplePlanar bevel face bounded by straight segments.
- Variables:
path – Closed
SvgPathdescribing the bevel polygon.outward_normal – Unit normal pointing out of the filled region.
- ante_ext: bool = False#
- post_ext: bool = False#
- class svg_path_editor.path_offset.BevelArced[source]#
Bases:
NamedTuplePlanar bevel face containing an elliptical-arc boundary.
The path consists of two corresponding arc segments (original and offset) joined by straight segments.
- Variables:
path – Closed
SvgPathdescribing the bevel face.c – Center of the supporting ellipse.
r – Radii vector of the supporting ellipse.
phi – Rotation of the ellipse in degrees.
locally_convex –
Trueiff the bevel is convex w.r.t. the interior.
- phi: decimal.Decimal#
- locally_convex: bool#
- ante_ext: bool = False#
- post_ext: bool = False#
- svg_path_editor.path_offset.bevel_path(path, *, d, prec=None)[source]#
Construct bevel faces for an offset of a simple closed path.
Unlike
offset_path(), this yields only the auxiliary faces that fill the bevel region between the original path and its offset.- Parameters:
path (SvgPath) – Closed
SvgPathwith exactly one subpathM … Z, using only line and elliptical-arc segments.d (Number) – Offset distance. Positive values move edges towards the interior.
prec (Precision | Literal['auto', 'auto-intersections'] | None) – Same semantics as in
offset_path().
- Returns:
Closed paths covering the bevel surface between original and offset.
- Raises:
AssertionError – If
pathis not a single closed subpath of the expected form, or if an offset intersection cannot be computed.- Return type:
collections.abc.Iterable[BevelPolygon | BevelArced]