svg_path/effects

One-off artistic path effects.

Types

Errors returned by path effects.

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

Constructors

  • PathError(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 greater than zero.

  • InvalidAngularTolerance(tolerance: Float)

    The angular tolerance must be finite and non-negative.

  • CannotRoundCorner(index: Int)

    The requested corner cannot be rounded with the current options.

  • CornerTrimsOverlap(segment_index: Int)

    Two rounded corners would consume too much of a segment between them.

  • ConvexHullError(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, then repeatedly applies the strongest per-segment radius limits together so the result does not depend on segment order.

Options for corner rounding.

pub type RoundCornerOptions {
  RoundCornerOptions(
    failure: FailureMode,
    length: 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 is replaced by its ordered line traversal. 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.

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.

Search Document