svg_path/stroke
Stroke outline construction.
This module turns path geometry into filled outline paths. An open subpath stroke is built as right offset, end cap, reversed left offset, start cap. A closed subpath stroke is built as the two offset contours with opposite traversal directions. Dash arrays are not part of this first pass; split paths can be stroked by calling these helpers on the visible pieces.
Types
Cap style used at open subpath endpoints.
pub type Cap {
Butt
Round
Square
}
Constructors
-
ButtConnect the two offset sides directly at the endpoint.
-
RoundAdd a half-circle cap at the endpoint.
-
SquareExtend the stroke by half the stroke width before capping.
Errors returned by stroke helpers.
pub type Error {
PathError(svg_path.Error)
OffsetError(offset.Error)
InvalidWidth(width: Float)
DegenerateTangent(t: Float)
}
Constructors
-
PathError(svg_path.Error)An underlying path operation failed.
-
OffsetError(offset.Error)An underlying offset operation failed.
-
InvalidWidth(width: Float)Stroke width must be greater than zero.
-
DegenerateTangent(t: Float)A segment tangent was too small to define a stable cap direction.
Options for stroke outline construction.
pub type Options {
Options(width: Float, cap: Cap, offset: offset.Options)
}
Constructors
-
Options(width: Float, cap: Cap, offset: offset.Options)
Values
pub fn path(
path: svg_path.Path,
width width: Float,
) -> Result(svg_path.Path, Error)
Stroke every subpath in a path using default options with the given width.
pub fn path_with(
path path: svg_path.Path,
options options: Options,
) -> Result(svg_path.Path, Error)
Stroke every subpath in a path using explicit options.
pub fn segment(
segment: svg_path.Segment,
width width: Float,
) -> Result(svg_path.Path, Error)
Stroke a segment using default options with the given width.
pub fn segment_with(
segment segment: svg_path.Segment,
options options: Options,
) -> Result(svg_path.Path, Error)
Stroke a segment using explicit options.
pub fn subpath(
subpath: svg_path.Subpath,
width width: Float,
) -> Result(svg_path.Path, Error)
Stroke a subpath using default options with the given width.
pub fn subpath_with(
subpath subpath: svg_path.Subpath,
options options: Options,
) -> Result(svg_path.Path, Error)
Stroke a subpath using explicit options.