svg_path_editor.path_offset =========================== .. py:module:: svg_path_editor.path_offset Attributes ---------- .. autoapisummary:: svg_path_editor.path_offset.Shape svg_path_editor.path_offset.additional_digits Classes ------- .. autoapisummary:: svg_path_editor.path_offset._OffsetData svg_path_editor.path_offset.Tri svg_path_editor.path_offset.BevelPolygon svg_path_editor.path_offset.BevelArced Functions --------- .. autoapisummary:: svg_path_editor.path_offset._all_non_none svg_path_editor.path_offset._prepare_offset_data svg_path_editor.path_offset._line_outgoing_point svg_path_editor.path_offset._arc_outgoing_point svg_path_editor.path_offset.outward_normal svg_path_editor.path_offset._iter_segment_contexts svg_path_editor.path_offset._arc_ante svg_path_editor.path_offset._arc_post svg_path_editor.path_offset._line_ante svg_path_editor.path_offset.offset_path svg_path_editor.path_offset.bevel_path Module Contents --------------- .. py:type:: Shape :canonical: Line | ParametricEllipticalArc .. py:data:: additional_digits :type: int :value: 8 Extra decimal digits used when ``prec="auto"``. .. py:function:: _all_non_none[T](elems) Return ``True`` iff ``elems`` contains no ``None`` values. .. py:class:: _OffsetData Bases: :py:obj:`NamedTuple` Precomputed data for offsetting a simple closed path. .. py:attribute:: is_ccw :type: bool .. py:attribute:: items :type: list[svg_path_editor.svg.SvgItem] .. py:attribute:: offsets :type: list[Shape] .. py:attribute:: inters :type: list[svg_path_editor.intersect.Intersection] .. py:function:: _prepare_offset_data(path, *, d, prec) Validate ``path`` and compute offset segments and their intersections. .. py:function:: _line_outgoing_point(inter1) Outgoing point of a line offset segment (after ``inter1``). .. py:function:: _arc_outgoing_point(inter1) Outgoing point of an arc offset segment (after ``inter1``). .. py:function:: outward_normal(p0, p1, is_ccw) Compute the outward unit normal of an edge. :param p0: Start point of the edge. :param p1: End point of the edge. :param is_ccw: ``True`` iff the polygon is oriented counter-clockwise. :return: Unit normal pointing outside the filled region. .. py:class:: Tri Bases: :py:obj:`NamedTuple` Small bevel triangle between original and offset geometry. :ivar orig0: Vertex on the original path. :ivar off0: First vertex on the offset path. :ivar off1: Second vertex on the offset path. .. py:attribute:: orig0 :type: svg_path_editor.geometry.Point .. py:attribute:: off0 :type: svg_path_editor.geometry.Point .. py:attribute:: off1 :type: svg_path_editor.geometry.Point .. py:property:: path :type: svg_path_editor.svg.SvgPath Return this triangle as a closed :class:`SvgPath`. .. py:method:: outward_normal(is_ccw) Return outward unit normal of this triangle. :param is_ccw: ``True`` iff the enclosing polygon is CCW. .. py:function:: _iter_segment_contexts(offsets, inters, items) Yield ``(orig_item, offset_geom, incoming_inter, outgoing_inter)`` per segment. .. py:function:: _arc_ante(orig, inter0) 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. .. py:function:: _arc_post(orig, inter1) Handle the outgoing side of an offset arc. Yields bevel triangles to emit after the arc segment. .. py:function:: _line_ante(orig, inter0) 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. .. py:function:: offset_path(path, *, d, prec = None) Offset a simple closed SVG path. The input must be a single closed subpath ``M … Z`` of straight lines and elliptical arcs. Every segment is offset by distance ``d`` (inwards for ``d > 0``), and consecutive offset segments are intersected to form the output path. :param path: Closed :class:`SvgPath` with exactly one subpath ``M … Z``, using only line and elliptical-arc segments. :param d: Offset distance. Positive values move edges towards the interior. :param prec: Intersection and offsetting precision: * ``"auto"``: decimal precision + :data:`additional_digits` for both offset geometry and intersections. * ``"auto-intersections"``: same automatic precision for intersections only; offsets remain symbolic. * :class:`Precision`: use this precision everywhere. * ``None``: purely symbolic where supported. :return: The offset closed path. :raises AssertionError: If ``path`` is not a single closed subpath of the expected form, or if an offset intersection cannot be computed. .. py:class:: BevelPolygon Bases: :py:obj:`NamedTuple` Planar bevel face bounded by straight segments. :ivar path: Closed :class:`SvgPath` describing the bevel polygon. :ivar outward_normal: Unit normal pointing out of the filled region. .. py:attribute:: path :type: svg_path_editor.svg.SvgPath .. py:attribute:: outward_normal :type: svg_path_editor.geometry.Point .. py:attribute:: ante_ext :type: bool :value: False .. py:attribute:: post_ext :type: bool :value: False .. py:class:: BevelArced Bases: :py:obj:`NamedTuple` Planar bevel face containing an elliptical-arc boundary. The path consists of two corresponding arc segments (original and offset) joined by straight segments. :ivar path: Closed :class:`SvgPath` describing the bevel face. :ivar c: Center of the supporting ellipse. :ivar r: Radii vector of the supporting ellipse. :ivar phi: Rotation of the ellipse in degrees. :ivar locally_convex: ``True`` iff the bevel is convex w.r.t. the interior. .. py:attribute:: path :type: svg_path_editor.svg.SvgPath .. py:attribute:: c :type: svg_path_editor.geometry.Point .. py:attribute:: r :type: svg_path_editor.geometry.Point .. py:attribute:: phi :type: decimal.Decimal .. py:attribute:: locally_convex :type: bool .. py:attribute:: ante_ext :type: bool :value: False .. py:attribute:: post_ext :type: bool :value: False .. py:function:: bevel_path(path, *, d, prec = None) Construct bevel faces for an offset of a simple closed path. Unlike :func:`offset_path`, this yields only the auxiliary faces that fill the bevel region between the original path and its offset. :param path: Closed :class:`SvgPath` with exactly one subpath ``M … Z``, using only line and elliptical-arc segments. :param d: Offset distance. Positive values move edges towards the interior. :param prec: Same semantics as in :func:`offset_path`. :return: Closed paths covering the bevel surface between original and offset. :raises AssertionError: If ``path`` is not a single closed subpath of the expected form, or if an offset intersection cannot be computed.