Documentation
¶
Overview ¶
Package svg parses SVG documents and draws them into pixels, for the icons and pictures of package ui, in Go alone.
It draws paths and the basic shapes, groups, nested svg elements, use and symbol elements, transforms, fills and strokes (with joins, caps and dashes) of colors, currentColor and linear and radial gradients, opacity, clip paths and masks, and style sheets of simple selectors (type, class and id). Text, embedded images, patterns, markers and filters are not drawn.
Index ¶
Constants ¶
const ( PathMove = opMove PathLine = opLine PathCubic = opCubic PathClose = opClose )
The segments of path data: a move to a point, a line to one, a cubic Bézier curve through two control points to its end, and a close.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Doc ¶
type Doc struct {
// contains filtered or unexported fields
}
Doc is a parsed SVG document. Draw may draw it from any goroutine.
func (*Doc) Draw ¶
Draw draws the document over the pixels of dst, fitting its viewBox in them as its preserveAspectRatio says, or stretched to them with stretch. currentColor is current where the document does not set the color property.
func (*Doc) DrawRotated ¶
DrawRotated draws the document as Draw does in a box w×h pixels at the center of dst, turned by degrees clockwise around it.
func (*Doc) Size ¶
Size returns the document's size in pixels: its width and height, or those of its viewBox.
func (*Doc) UsesCurrentColor ¶
UsesCurrentColor reports whether the color Draw takes for currentColor changes what it draws.
type PathOp ¶ added in v0.1.17
type PathOp = pathOp
PathOp is what a segment of path data ParsePath parsed does.
func ParsePath ¶ added in v0.1.17
ParsePath parses SVG path data, as a path element's d attribute holds it, into its segments, in user units: ops, each taking its points from pts in turn, a move and a line one, a cubic curve three, a close none; quadratic curves and arcs become cubic ones. At an error it stops, as SVG draws a path up to its first error, and returns the error, with the segments before it.