svg/document.go

Structs Interfaces

Structs

type Document struct

Document represents a parsed SVG document.

It can be rendered multiple times at different sizes, making it suitable

for caching parsed SVG icons.

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  root element.
	// In SVG, presentation attributes on  are inherited by children.
	// Common in expui icons: fill="none" on root.
	RootFill	string

	// Elements contains the top-level SVG elements.
	Elements	[]Element
}

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 element.

type PathElement struct {
	Attrs	Attrs
	D	string	// SVG path data string
}

type CircleElement struct

CircleElement represents an SVG element.

type CircleElement struct {
	Attrs	Attrs
	CX, CY	float64
	R	float64
}

type RectElement struct

RectElement represents an SVG element.

type RectElement struct {
	Attrs		Attrs
	X, Y, W, H	float64
	RX, RY		float64	// corner radii
}

type EllipseElement struct

EllipseElement represents an SVG element.

type EllipseElement struct {
	Attrs	Attrs
	CX, CY	float64
	RX, RY	float64
}

type LineElement struct

LineElement represents an SVG element.

type LineElement struct {
	Attrs		Attrs
	X1, Y1, X2, Y2	float64
}

type PolygonElement struct

PolygonElement represents an SVG element.

type PolygonElement struct {
	Attrs	Attrs
	Points	[]float64	// alternating x, y values
}

type PolylineElement struct

PolylineElement represents an SVG element.

type PolylineElement struct {
	Attrs	Attrs
	Points	[]float64	// alternating x, y values
}

type GroupElement struct

GroupElement represents an SVG element with children.

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
}