svg_path/area

Signed and fill-rule area calculations for SVG path geometry.

Signed area is computed directly from segment line integrals. Fill-rule area linearizes curves, builds a planar line arrangement, and integrates the filled vertical intervals of each arrangement slab. Absolute winding area uses the same arrangement but weights each region by the absolute value of its winding number.

Values

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

Approximate a path’s absolute winding area using default linearization options.

This integrates abs(winding_number) over the path’s combined winding field. It is different from path(path, using: Nonzero) when some regions have winding magnitude greater than one.

pub fn absolute_path_with(
  path: svg_path.Path,
  options options: svg_path.LinearizeOptions,
) -> Result(Float, svg_path.Error)

Approximate a path’s absolute winding area using explicit linearization options.

Every nonempty subpath is implicitly closed. Move-only subpaths contribute no area. Curves are linearized before their line arrangement is decomposed into vertical slabs; each slab is then integrated exactly.

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

Approximate a subpath’s absolute winding area using default linearization options.

This integrates abs(winding_number) over the plane. A loop traced twice in the same direction contributes twice its ordinary fill area; coincident opposite loops cancel to zero because their total winding is zero.

pub fn absolute_subpath_with(
  subpath: svg_path.Subpath,
  options options: svg_path.LinearizeOptions,
) -> Result(Float, svg_path.Error)

Approximate a subpath’s absolute winding area using explicit linearization options.

options.tolerance is a geometric curve-to-line tolerance, not a direct bound on the final area error.

pub fn path(
  path: svg_path.Path,
  using fill_rule: svg_path.FillRule,
) -> Result(Float, svg_path.Error)

Approximate a path’s combined filled area using the default linearization options.

pub fn path_with(
  path: svg_path.Path,
  using fill_rule: svg_path.FillRule,
  options options: svg_path.LinearizeOptions,
) -> Result(Float, svg_path.Error)

Approximate a path’s combined filled area using explicit linearization options.

Every nonempty subpath is implicitly closed. Move-only subpaths contribute no area. Curves are linearized before their line arrangement is decomposed into vertical slabs; each slab is then integrated exactly.

pub fn signed_path(path: svg_path.Path) -> Float

Return the sum of the signed areas of a path’s subpaths.

This is algebraic area: repeated loops can multiply the value and opposite loops can cancel. Equivalently, this is the integral of the signed winding number over the plane. Use path for SVG fill-rule area and absolute_path when repeated loops should contribute by winding magnitude.

pub fn signed_points(points: List(svg_path.Point)) -> Float

Return the signed area of a polygonal point loop.

The final point is implicitly connected to the first. Lists with fewer than three points have zero area. Positive and negative signs represent opposite traversal directions.

pub fn signed_segment(segment: svg_path.Segment) -> Float

Return one segment’s contribution to a closed curve’s signed area.

Lines and Beziers are integrated exactly as polynomials. Elliptical arcs use their exact center parameterization. A degenerate arc contributes the same value as the straight line between its endpoints.

pub fn signed_subpath(subpath: svg_path.Subpath) -> Float

Return a subpath’s signed area, implicitly closing it when necessary.

The subpath’s closed field does not affect the result. Move-only subpaths have zero area.

pub fn subpath(
  subpath: svg_path.Subpath,
  using fill_rule: svg_path.FillRule,
) -> Result(Float, svg_path.Error)

Approximate a subpath’s filled area using the default linearization options.

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

Return a subpath’s area-based clockwiseness as a value from 0.0 to 1.0.

1.0 means fully clockwise, 0.0 means fully counterclockwise, and 0.5 means balanced or zero-area. Open subpaths are treated as if closed by a straight line from end to start, matching signed_subpath and absolute_subpath.

The value is computed from signed area divided by absolute winding area, so self-crossing or overlapping subpaths can return intermediate values. The final result is clamped to [0.0, 1.0] to avoid exposing numerical drift.

pub fn subpath_clockwiseness_with(
  subpath: svg_path.Subpath,
  options options: svg_path.LinearizeOptions,
) -> Result(Float, svg_path.Error)

Return a subpath’s area-based clockwiseness using explicit linearization options.

options.tolerance controls the curve-to-line approximation used by the absolute winding area denominator.

pub fn subpath_with(
  subpath: svg_path.Subpath,
  using fill_rule: svg_path.FillRule,
  options options: svg_path.LinearizeOptions,
) -> Result(Float, svg_path.Error)

Approximate a subpath’s filled area using explicit linearization options.

options.tolerance is a geometric curve-to-line tolerance, not a direct bound on the final area error.

Search Document