svg_path/basic_shapes
Convert SVG basic shape elements into subpaths.
These helpers follow SVG’s equivalent path algorithms for rect,
circle, ellipse, line, polyline, and polygon.
Types
Errors returned by SVG primitive conversion helpers.
pub type Error {
InvalidRectWidth(width: Float)
InvalidRectHeight(height: Float)
InvalidRectRadiusX(rx: Float)
InvalidRectRadiusY(ry: Float)
InvalidCircleRadius(r: Float)
InvalidEllipseRadiusX(rx: Float)
InvalidEllipseRadiusY(ry: Float)
DisabledRendering
Core(svg_path.Error)
}
Constructors
-
InvalidRectWidth(width: Float)A
rectwidth was negative. -
InvalidRectHeight(height: Float)A
rectheight was negative. -
InvalidRectRadiusX(rx: Float)A
rectx-axis corner radius was negative. -
InvalidRectRadiusY(ry: Float)A
recty-axis corner radius was negative. -
InvalidCircleRadius(r: Float)A
circleradius was negative. -
InvalidEllipseRadiusX(rx: Float)An
ellipsex-axis radius was negative. -
InvalidEllipseRadiusY(ry: Float)An
ellipsey-axis radius was negative. -
DisabledRenderingThe SVG element would not render because at least one required extent is zero.
-
Core(svg_path.Error)An error from the core path model.
Values
pub fn circle(
cx cx: Float,
cy cy: Float,
r r: Float,
) -> Result(svg_path.Subpath, Error)
Convert an SVG circle element to a subpath.
The equivalent path starts at the 3 o’clock point and uses four quarter-arc segments.
pub fn ellipse(
cx cx: Float,
cy cy: Float,
rx rx: Float,
ry ry: Float,
) -> Result(svg_path.Subpath, Error)
Convert an SVG ellipse element to a subpath.
The equivalent path starts at the 3 o’clock point and uses four quarter-arc segments.
pub fn line(
x1 x1: Float,
y1 y1: Float,
x2 x2: Float,
y2 y2: Float,
) -> Result(svg_path.Subpath, Error)
Convert an SVG line element to a subpath.
pub fn polygon(
points: List(vec2.Vec2(Float)),
) -> Result(svg_path.Subpath, Error)
Convert an SVG polygon element to a subpath.
pub fn polyline(
points: List(vec2.Vec2(Float)),
) -> Result(svg_path.Subpath, Error)
Convert an SVG polyline element to a subpath.
pub fn rect(
x x: Float,
y y: Float,
width width: Float,
height height: Float,
rx rx: option.Option(Float),
ry ry: option.Option(Float),
) -> Result(svg_path.Subpath, Error)
Convert an SVG rect element to a subpath.
The equivalent path starts at (x + rx, y) and proceeds clockwise. If only
one corner radius is present, the missing radius uses the same value. Radii
are clamped so they are no greater than half the rectangle extent.