svg_path/inspect

Human-readable structural inspection for path values.

This module is for debugging and tests, not for producing valid SVG path data. Use svg_path/serialize when you need a d attribute string.

Types

Formatting for digits to the left of the decimal point.

pub type LeftDecimalOptions {
  Succinct
  AutoLeftPadding
  LeftPadding(Int)
}

Constructors

  • Succinct

    Do not pad numbers on the left.

  • AutoLeftPadding

    Pre-scan the inspected value and choose the smallest shared left width that aligns its numbers.

  • LeftPadding(Int)

    Pad numbers to the given left width.

    The width includes a leading minus sign for negative numbers.

Options for structural inspection output.

pub type Options {
  Options(
    left_decimals: LeftDecimalOptions,
    right_decimals: RightDecimalOptions,
  )
}

Constructors

  • Options(
      left_decimals: LeftDecimalOptions,
      right_decimals: RightDecimalOptions,
    )

    Arguments

    left_decimals

    Formatting for digits to the left of the decimal point.

    right_decimals

    Formatting for digits to the right of the decimal point.

Formatting for digits to the right of the decimal point.

pub type RightDecimalOptions {
  System
  AtMost(Int)
  Fixed(Int)
}

Constructors

  • System

    Use the system float formatter, stripped of purely trailing decimal zeroes.

  • AtMost(Int)

    Use at most this many decimal places, stripping trailing zeroes.

  • Fixed(Int)

    Use exactly this many decimal places.

Values

pub fn decimal_options(decimal_places: Int) -> Options

Create options that round numbers to the given number of decimal places.

Trailing zeroes are stripped. Negative decimal places are clamped to zero.

pub fn default_options() -> Options

Default inspection options.

Defaults to raw float formatting with trailing decimal zeroes stripped.

pub fn fixed_decimal_options(decimal_places: Int) -> Options

Create options that round numbers and keep exactly the given number of decimal places.

Negative decimal places are clamped to zero.

pub fn path(path: svg_path.Path) -> String

Inspect a path as a multiline structural string.

pub fn path_code(path: svg_path.Path) -> String

Inspect a path as copy-pasteable Gleam code.

The generated code assumes the svg_path package is imported as svg_path.

pub fn path_code_with_options(
  path path: svg_path.Path,
  options options: Options,
) -> String

Inspect a path as copy-pasteable Gleam code with custom options.

pub fn path_with_options(
  path path: svg_path.Path,
  options options: Options,
) -> String

Inspect a path as a multiline structural string with custom options.

pub fn point(point: vec2.Vec2(Float)) -> String

Inspect a point as x,y.

pub fn point_code(point: vec2.Vec2(Float)) -> String

Inspect a point as copy-pasteable Gleam code.

The generated code assumes the svg_path package is imported as svg_path.

pub fn point_code_with_options(
  point point: vec2.Vec2(Float),
  options options: Options,
) -> String

Inspect a point as copy-pasteable Gleam code with custom options.

pub fn point_with_options(
  point point: vec2.Vec2(Float),
  options options: Options,
) -> String

Inspect a point as x,y with custom options.

pub fn segment(segment: svg_path.Segment) -> String

Inspect a segment as a single-line structural string.

pub fn segment_code(segment: svg_path.Segment) -> String

Inspect a segment as copy-pasteable Gleam code.

The generated code assumes the svg_path package is imported as svg_path.

pub fn segment_code_with_options(
  segment segment: svg_path.Segment,
  options options: Options,
) -> String

Inspect a segment as copy-pasteable Gleam code with custom options.

pub fn segment_with_options(
  segment segment: svg_path.Segment,
  options options: Options,
) -> String

Inspect a segment as a single-line structural string with custom options.

pub fn subpath(subpath: svg_path.Subpath) -> String

Inspect a subpath as a multiline structural string.

pub fn subpath_code(subpath: svg_path.Subpath) -> String

Inspect a subpath as copy-pasteable Gleam code.

The generated code assumes the svg_path package is imported as svg_path.

pub fn subpath_code_with_options(
  subpath subpath: svg_path.Subpath,
  options options: Options,
) -> String

Inspect a subpath as copy-pasteable Gleam code with custom options.

pub fn subpath_with_options(
  subpath subpath: svg_path.Subpath,
  options options: Options,
) -> String

Inspect a subpath as a multiline structural string with custom options.

pub fn with_left_decimals(
  options options: Options,
  left_decimals left_decimals: LeftDecimalOptions,
) -> Options

Set left-side decimal formatting for inspection options.

pub fn with_left_padding(
  options options: Options,
  left_padding left_padding: LeftDecimalOptions,
) -> Options

Set left-side number padding for inspection options.

pub fn with_right_decimals(
  options options: Options,
  right_decimals right_decimals: RightDecimalOptions,
) -> Options

Set right-side decimal formatting for inspection options.

Search Document