Discover Packages
github.com/SwishHQ/waffle
internal
svgparse
package
Version:
v1.0.1
Opens a new window with list of versions in this module.
Published: Oct 5, 2026
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Jump to ...
Documentation
Overview
Index
Constants
Variables
Functions
Types
type Op
type Path
Circle(cx, cy, r)
Ellipse(cx, cy, rx, ry)
Line(x1, y1, x2, y2)
ParsePath(d)
Polygon(pts)
Polyline(pts)
Rect(x, y, w, h, rx, ry)
type Segment
Source Files
Documentation
Documentation
¶
Package svgparse parses SVG path data and basic shapes into a vector IR of
move/line/cubic/close segments, ready to emit as PDF path operators. It parses
geometry only (not rasterizing); presentation attributes and the wider SVG
document model are handled by the SVG renderer.
type Op
type Path
func Circle(cx, cy, r float64) Path
func Ellipse(cx, cy, rx, ry float64) Path
func Line(x1, y1, x2, y2 float64) Path
func ParsePath(d string) (Path, error)
func Polygon(pts []float64) Path
func Polyline(pts []float64) Path
func Rect(x, y, w, h, rx, ry float64) Path
type Segment
Op is a path segment operator.
const (
MoveTo Op = iota
LineTo
CubicTo
Close
)
Path is a sequence of segments in absolute user coordinates.
Circle returns the path for a circle.
Ellipse returns the path for an ellipse as four cubic arcs.
Line returns the path for a line segment.
ParsePath parses an SVG path "d" string. Quadratic curves are converted to
cubics; smooth curves (S/T) reflect the previous control point. Arcs (A/a) are
approximated by a line to the endpoint for now (proper arc→cubic is a TODO).
Polygon returns a closed path through the given points.
Polyline returns an open path through the given [x0,y0,x1,y1,…] points.
Rect returns the path for a rectangle. rx/ry round the corners with cubic arcs
(each clamped to half the corresponding side).
type Segment struct {
Op Op
Args [6]float64
}
Segment is one path operation. MoveTo/LineTo use Args[0:2]; CubicTo uses all six.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.