Relative Line Command Accumulator

Accumulate the bounded SVG M/m/L/l branch into absolute move/line coordinates, preserving subpath starts and implicit lineto expansion. Reject curves, closepath and incomplete coordinate pairs; not a complete SVG path renderer.

Description

Accumulate the bounded SVG M/m/L/l branch into absolute move/line coordinates, preserving subpath starts and implicit lineto expansion. Reject curves, closepath and incomplete coordinate pairs; not a complete SVG path renderer.

Relative SVG line coordinates depend on the current point. Absolute commands can be recovered by accumulating those displacements.

When to use this tool

Accumulate the bounded SVG M/m/L/l branch into absolute move/line coordinates, preserving subpath starts and implicit lineto expansion. Reject curves, closepath and incomplete coordinate pairs; not a complete SVG path renderer.

  • Prepare the supplied pathData fields for this operation.
  • Compare the complete example with the representation used by your own input before carrying the result into another step.

How to use the tool and how it works

  1. Enter pathData. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. Read result.absoluteCommands. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Parse only M/m/L/l path commands with an initial moveto, expanding extra moveto coordinate pairs into line commands. Starting at (0,0), add relative coordinates or replace absolute ones and emit uppercase absolute command records.1

Input fieldMeaning and representationAccepted input
pathDatapath data.Text; at most 8,192 UTF-16 code units, subject to the grammar above
Output fieldInterpretation
resultObject containing the named outputs below.
result.absoluteCommandsThe absolute commands list in the ordering and representation described above.
json
{
  "input": {
    "pathData": "M1 2 l3 4 L0 1 l-1 2"
  },
  "output": {
    "result": {
      "absoluteCommands": [
        {
          "command": "M",
          "x": 1,
          "y": 2
        },
        {
          "command": "L",
          "x": 4,
          "y": 6
        },
        {
          "command": "L",
          "x": 0,
          "y": 1
        },
        {
          "command": "L",
          "x": -1,
          "y": 3
        }
      ]
    }
  }
}

Limitations and assumptions

  • Curves, closepath, other SVG commands and DOM behavior are unsupported. Multiple movetos are retained without inventing connecting segments.
  • Point pairs use [x,y], rectangles and viewBox use [x,y,width,height], and all coordinate units must be consistent. This tool does not read, render or modify an SVG document.
  • Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
  • String lists have at most 128 entries of at most 128 code units; matrices have at most 128 rows and columns. Larger numeric lists and parsed JSON have separate bounded budgets. Nonfinite results and excessively large serialized outputs are rejected.
  • Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.

Alternative or Complementary methods

Use a full SVG parser or rendering engine when the task includes commands and CSS values outside the documented branch. Compare coordinates and transforms under the same units and viewport convention.

References

  1. Tool behavior and example: Relative Line Command Accumulator — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies