svg_path/effects

One-off artistic path effects.

Types

Errors returned by path effects.

pub type Error {
  PathError(svg_path.Error)
  InvalidRadius(radius: Float)
  CannotRoundCorner(index: Int)
  CornerTrimsOverlap(segment_index: Int)
}

Constructors

  • PathError(svg_path.Error)

    An underlying path operation failed.

  • InvalidRadius(radius: Float)

    The radius must be greater than zero.

  • 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.

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,
    tolerance: Float,
  )
}

Constructors

Values

pub fn default_round_corner_options() -> RoundCornerOptions

Return default options for corner rounding.

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 tangent to their endpoint derivatives. 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