svg/document.go
Structs
type Document struct
type Document struct {
// ViewBox defines the SVG coordinate system (minX, minY, width, height).
ViewBox ViewBox
// Width and Height are the explicit width/height from the SVG root element.
// If zero, ViewBox dimensions are used.
Width, Height float64
// RootFill is the fill attribute from the
type ViewBox struct
ViewBox represents the SVG viewBox attribute.
type ViewBox struct {
MinX, MinY, Width, Height float64
}
type Attrs struct
Attrs holds common SVG presentation attributes shared by all elements.
type Attrs struct {
Fill string // "#hex", "none", "rgb(...)", named color, ""
FillRule string // "evenodd", "nonzero", ""
FillOpacity float64 // 0-1, default 1
Stroke string // "#hex", "none", "rgb(...)", named color, ""
StrokeWidth float64 // default 1
StrokeCap string // "round", "square", "butt", ""
StrokeJoin string // "round", "bevel", "miter", ""
StrokeOpacity float64 // 0-1, default 1
Opacity float64 // element-level opacity, default 1
Transform string // raw transform string
ClipRule string // "evenodd", "nonzero", ""
}
type PathElement struct
PathElement represents an SVG
type PathElement struct {
Attrs Attrs
D string // SVG path data string
}
type CircleElement struct
CircleElement represents an SVG
type CircleElement struct {
Attrs Attrs
CX, CY float64
R float64
}
type RectElement struct
RectElement represents an SVG
type RectElement struct {
Attrs Attrs
X, Y, W, H float64
RX, RY float64 // corner radii
}
type EllipseElement struct
EllipseElement represents an SVG
type EllipseElement struct {
Attrs Attrs
CX, CY float64
RX, RY float64
}
type LineElement struct
LineElement represents an SVG
type LineElement struct {
Attrs Attrs
X1, Y1, X2, Y2 float64
}
type PolygonElement struct
PolygonElement represents an SVG
type PolygonElement struct {
Attrs Attrs
Points []float64 // alternating x, y values
}
type PolylineElement struct
PolylineElement represents an SVG
type PolylineElement struct {
Attrs Attrs
Points []float64 // alternating x, y values
}
type GroupElement struct
GroupElement represents an SVG
type GroupElement struct {
Attrs Attrs
Children []Element
}
Interfaces
type Element interface
Element is the interface implemented by all SVG element types.
type Element interface {
// attrs returns the common presentation attributes for this element.
attrs() *Attrs
}
Document represents a parsed SVG document.
It can be rendered multiple times at different sizes, making it suitable
for caching parsed SVG icons.