svg_path/parse

SVG path data parser.

This module parses the d attribute syntax used by SVG paths. It supports comma and whitespace separators, compact signed numbers, relative commands, implicit repeated commands, smooth curves, and arcs.

Types

Errors returned while parsing SVG path data.

pub type Error {
  Core(svg_path.Error)
  ExpectedArcFlag
  ExpectedCommand
  ExpectedMove
  ExpectedNumber
  InvalidNumber(String)
  UnsupportedCommand(String)
}

Constructors

  • A parsed path was internally invalid according to the core path model.

  • ExpectedArcFlag

    An arc flag was not 0 or 1.

  • ExpectedCommand

    A command letter was expected.

  • ExpectedMove

    Path data must begin with a move command.

  • ExpectedNumber

    A numeric argument was expected.

  • InvalidNumber(String)

    A numeric token could not be parsed as a float.

  • UnsupportedCommand(String)

    The command letter is not supported by this library.

Values

pub fn path(input: String) -> Result(svg_path.Path, Error)

Parse an SVG path data string into a Path.

Empty strings parse as an empty path. Move-only subpaths are ignored by the core path model because they contain no drawable segments.

Search Document