svg_path/svg
Small helpers for rendering paths as complete SVG documents.
Types
One item to render inside a generated SVG document.
This type is intentionally small. It supports styled paths, rectangles, circles, ellipses, and text labels for quick debugging drawings and examples.
pub type ThingToDraw {
StyledPath(svg_path.Path, String)
Rectangle(svg_path.Point, Float, Float, String)
Circle(svg_path.Point, Float, String)
Ellipse(svg_path.Point, svg_path.Point, String)
Text(String, String, svg_path.Point, Int)
}
Constructors
-
StyledPath(svg_path.Path, String)A
<path>element.The first field is serialized as the element’s
dattribute. The second field is used directly as the element’sstyleattribute after XML attribute escaping. -
Rectangle(svg_path.Point, Float, Float, String)A
<rect>element.The fields are the top-left point, width, height, and raw CSS declarations for the
styleattribute. -
Circle(svg_path.Point, Float, String)A
<circle>element.The fields are the center point, radius, and raw CSS declarations for the
styleattribute. -
Ellipse(svg_path.Point, svg_path.Point, String)An
<ellipse>element.The fields are the center point, x/y radii, and raw CSS declarations for the
styleattribute. -
Text(String, String, svg_path.Point, Int)A
<text>element.The fields are text content, raw CSS declarations for the
styleattribute, the text position, and the font size in SVG user units.
A list of items to render inside a generated SVG document.
pub type ThingsToDraw =
List(ThingToDraw)
Values
pub fn document(
things things: List(ThingToDraw),
view_box view_box: svg_path.BoundingBox,
) -> String
Render styled paths and text labels as a complete SVG document.
The supplied bounding box is used directly as the document viewBox.
pub fn labeled_point(
label: String,
color: String,
point: svg_path.Point,
font_size: Int,
) -> List(ThingToDraw)
pub fn paths(
things things: List(ThingToDraw),
view_box view_box: svg_path.BoundingBox,
) -> String
Render styled paths and text labels as a complete SVG document.
This is an older name for document.