Line Cap Extension Budget

Compute ideal axial line-cap extension budget for straight segments; round caps are not rectangular area bounds and joins are outside scope.

Description

Compute ideal axial line-cap extension budget for straight segments; round caps are not rectangular area bounds and joins are outside scope.

Stroke caps extend a straight segment axially by different amounts. The budget is separate from full stroke-outline geometry.1

When to use this tool

Compute ideal axial line-cap extension budget for straight segments; round caps are not rectangular area bounds and joins are outside scope.

  • Prepare the supplied strokeWidth, cap 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 strokeWidth, cap. 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.extensionPerEnd, result.totalAxialExtension. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Require nonnegative strokeWidth and cap exactly butt, round or square. Butt returns zero extension; round and square return half the width per end and the full width in total.2

Input fieldMeaning and representationAccepted input
strokeWidthstroke width.Finite number; zero or greater
capcap.Text; at most 8,192 UTF-16 code units, subject to the grammar above
Output fieldInterpretation
resultObject containing the named outputs below.
result.extensionPerEndThe extension per end value under the stated formula or text convention.
result.totalAxialExtensionThe total axial extension value under the stated formula or text convention.
json
{
  "input": {
    "strokeWidth": 4,
    "cap": "round"
  },
  "output": {
    "result": {
      "extensionPerEnd": 2,
      "totalAxialExtension": 4
    }
  }
}

Limitations and assumptions

  • No join, corner, marker or actual path bounding box is computed. Curves and degenerate segment rendering need separate treatment.
  • 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. SVG 2: Stroke line caps — W3C

  2. Tool behavior and example: Line Cap Extension Budget — tool.io

Similar or alternative tools

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