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 path elements and text labels for quick debugging drawings and examples.

pub type ThingToDraw {
  StyledPath(svg_path.Path, String)
  Text(String, String, vec2.Vec2(Float), Int)
}

Constructors

  • StyledPath(svg_path.Path, String)

    A <path> element.

    The first field is serialized as the element’s d attribute. The second field is used directly as the element’s style attribute after XML attribute escaping.

  • Text(String, String, vec2.Vec2(Float), Int)

    A <text> element.

    The fields are text content, raw CSS declarations for the style attribute, 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: vec2.Vec2(Float),
  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.

Search Document