svg_path/effects

One-off artistic path effects.

Types

Errors returned by path effects.

pub type Error {
  InvalidDegeneracyTolerance(tolerance: Float)
  PathError(error: svg_path.Error)
  InvalidRadius(radius: Float)
  InvalidDistanceTolerance(tolerance: Float)
  InvalidAngularTolerance(tolerance: Float)
  CannotRoundCorner(index: Int)
  CornerTrimsOverlap(segment_index: Int)
  ConvexHullError(error: convex_hull.Error)
}

Constructors

  • InvalidDegeneracyTolerance(tolerance: Float)

    The degeneracy linearization tolerance must be finite and non-negative.

  • PathError(error: svg_path.Error)

    An underlying path operation failed.

  • InvalidRadius(radius: Float)

    The radius must be greater than zero.

  • InvalidDistanceTolerance(tolerance: Float)

    The distance tolerance must be finite and non-negative.

  • InvalidAngularTolerance(tolerance: Float)

    The angular tolerance must be finite and non-negative.

  • CannotRoundCorner(index: Int)

    The corner at the supplied index cannot be rounded with the current options.

  • CornerTrimsOverlap(segment_index: Int)

    Two rounded corners would consume too much of the segment at the supplied index.

  • ConvexHullError(error: convex_hull.Error)

    Convex-hull construction failed while normalizing degenerate segments.

What to do when an individual corner cannot be rounded.

pub type FailureMode {
  ErrorOnFailure
  LeaveCorner
  AdaptRadius
}

Constructors

  • ErrorOnFailure

    Return an error.

  • LeaveCorner

    Leave the corner untouched.

  • AdaptRadius

    Reduce corner radii as needed after considering all segment constraints. This first measures every eligible corner, collects the strongest per-segment limits, then applies them together in one scaling pass rather than adjusting each radius as segments are visited.

Options for corner rounding.

pub type RoundCornerOptions {
  RoundCornerOptions(
    failure: FailureMode,
    length_options: svg_path.LengthOptions,
    distance_tolerance: Float,
    angular_tolerance: Float,
  )
}

Constructors

Values

pub fn default_round_corner_options() -> RoundCornerOptions

Return default options for corner rounding.

pub fn normalize_degenerate_segments(
  subpath: svg_path.Subpath,
  tolerance tolerance: Float,
) -> Result(svg_path.Subpath, Error)

Replace maximal contiguous line-degenerate windows in a subpath.

Each selected window preserves its start, end, and two longitudinal support extrema in source traversal order; intermediate local reversals need not survive. This delegates to svg_path/degeneracy. Windows are considered from left to right. Their exact curve-preserving convex hull is grown one segment at a time, and the largest prefix certified to fit in a strip of the requested width is selected first. A 0.0 tolerance collapses a window only when its strip width is exactly zero.

pub fn round_corners(
  path: svg_path.Path,
  radius radius: Float,
) -> Result(svg_path.Path, Error)

Round eligible corners in every subpath of a path.

A rounded corner trims both incident segments and inserts a circular SVG arc. For a line-line corner, the arc is an exact circular fillet tangent to both lines. When either incident segment is curved, its endpoint direction determines the trim estimate, but the inserted arc is not guaranteed to be tangent to the curve at the resulting cut point.

If a corner is straight, degenerate, or lacks enough incident segment length, behavior is controlled by RoundCornerOptions.failure.

pub fn round_corners_with(
  path: svg_path.Path,
  radius radius: Float,
  options options: RoundCornerOptions,
) -> Result(svg_path.Path, Error)

Round eligible corners in every subpath of a path using explicit options.

pub fn round_subpath_corners(
  subpath: svg_path.Subpath,
  radius radius: Float,
) -> Result(svg_path.Subpath, Error)

Round eligible corners in a subpath.

pub fn round_subpath_corners_with(
  subpath: svg_path.Subpath,
  radius radius: Float,
  options options: RoundCornerOptions,
) -> Result(svg_path.Subpath, Error)

Round eligible corners in a subpath using explicit options.

pub fn stretch_to_join_endpoint_policy() -> svg_path.EndpointPolicy

Return an endpoint policy that stretches adjacent segments to meet.

For an ordinary adjacent pair, the shared endpoint is the midpoint of previous.end and next.start. For a closing pair, previous.end is moved to next.start, which is the fixed subpath start.

Search Document