svg

package module
v0.0.0-...-52816d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2021 License: MIT Imports: 29 Imported by: 2

README

svg2

PkgGoDev codecov Go Report Card Test

A pure Go SVG renderer built on top of gg.

Note that this is very much a work in progress, and many features of SVG are not implemented. This includes (but is not limited to):

  • length units
  • radial gradients
  • patterns
  • context-fill
  • context-stroke
  • non-fragment URLs
  • use elements
  • switch elements
  • quadratic bezier curves
  • elliptical arcs
  • ellipse elements
  • line elements
  • polyline elements
  • tspan elements
  • image elements
  • foreignObject elements
  • transforms

Which is really to say that pretty much the only SVG elements that are supported are paths, groups, linear gradients, and text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any(x Element) any

func Decode

func Decode(r io.Reader) (image.Image, error)

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

func NewContext

func NewContext(svg *SVG) *gg.Context

NewContext creates a new render context for an SVG document.

func NewScaledContext

func NewScaledContext(svg *SVG, scale float64) *gg.Context

NewScaledContext creates a new render context for an SVG document with the given scaling factor.

func Render

func Render(ctx *gg.Context, svg *SVG) error

Render renders an SVG document to the given context.

Types

type BoxLengthPercentage

type BoxLengthPercentage struct {
	LengthPercentage

	Value string
}

func (*BoxLengthPercentage) UnmarshalText

func (blp *BoxLengthPercentage) UnmarshalText(text []byte) error

type Circle

type Circle struct {
	ElementAttributes

	XMLName xml.Name `xml:"circle"`

	PathLength float64 `xml:"pathLength,attr"`

	Cx LengthPercentage `xml:"cx,attr"`
	Cy LengthPercentage `xml:"cy,attr"`

	R LengthPercentage `xml:"r,attr"`

	Children []any `xml:",any"`
}

Circle represents an SVG `circle` element.

type ClipPath

type ClipPath string

type ClosePath

type ClosePath struct{}

ClosePath represents an SVG `closepath` command.

type Color

type Color struct {
	Value color.Color
}

Color represents a color.

func (*Color) UnmarshalText

func (c *Color) UnmarshalText(text []byte) error

type CubicBezier

type CubicBezier struct {
	IsAbsolute bool
	IsSmooth   bool

	Coordinates []CubicBezierCoordinates
}

CubicBezier represents an SVG cubic Bezier curve command.

type CubicBezierCoordinates

type CubicBezierCoordinates struct {
	Point

	X1 float64
	Y1 float64
	X2 float64
	Y2 float64
}

CubicBezierCoordinates represents a set of cubic Bezier curve coordinates.

type Cursor

type Cursor string

type DashArray

type DashArray string

type Defs

type Defs struct {
	ElementAttributes

	XMLName xml.Name `xml:"defs"`

	Children []any `xml:",any"`
}

Defs represents an SVG `defs` element.

type Element

type Element interface {
	// contains filtered or unexported methods
}

Element represents an SVG element.

type ElementAttributes

type ElementAttributes struct {
	ID string `xml:"id,attr"`

	AlignmentBaseline         Ident                        `xml:"alignment-baseline,attr"`
	BaselineShift             *LengthPercentageIdent       `xml:"baseline-shift,attr"`
	ClipPath                  *ClipPath                    `xml:"clip-path,attr"`
	ClipRule                  Ident                        `xml:"clip-rule,attr"`
	Color                     *Color                       `xml:"color,attr"`
	ColorInterpolation        Ident                        `xml:"color-interpolation,attr"`
	ColorInterpolationFilters Ident                        `xml:"color-interpolation-filters,attr"`
	ColorRendering            Ident                        `xml:"color-rendering,attr"`
	Cursor                    *Cursor                      `xml:"cursor,attr"`
	Direction                 Ident                        `xml:"direction,attr"`
	Display                   Ident                        `xml:"display,attr"`
	DominantBaseline          Ident                        `xml:"dominant-baseline,attr"`
	Fill                      *Paint                       `xml:"fill,attr"`
	FillOpacity               *NumberPercentage            `xml:"fill-opacity,attr"`
	FillRule                  Ident                        `xml:"fill-rule,attr"`
	Filter                    *FilterList                  `xml:"filter,attr"`
	FloodColor                *Color                       `xml:"flood-color,attr"`
	FloodOpacity              *NumberPercentage            `xml:"flood-opacity,attr"`
	FontFamily                *FontFamily                  `xml:"font-family,attr"`
	FontSize                  *LengthPercentageNumberIdent `xml:"font-size,attr"`
	FontSizeAdjust            *NumberIdent                 `xml:"font-size-adjust,attr"`
	FontStretch               Ident                        `xml:"font-stretch,attr"`
	FontStyle                 Ident                        `xml:"font-style,attr"`
	FontVariant               Ident                        `xml:"font-variant,attr"`
	FontWeight                *NumberIdent                 `xml:"font-weight,attr"`
	ImageRendering            Ident                        `xml:"image-rendering,attr"`
	LetterSpacing             *LengthIdent                 `xml:"letter-spacing,attr"`
	LightingColor             *Color                       `xml:"lighting-color,attr"`
	MarkerEnd                 *URLIdent                    `xml:"marker-end,attr"`
	MarkerMid                 *URLIdent                    `xml:"marker-mid,attr"`
	MarkerStart               *URLIdent                    `xml:"marker-start,attr"`
	Mask                      *Mask                        `xml:"mask,attr"`
	Opacity                   *NumberIdent                 `xml:"opacity,attr"`
	Overflow                  Ident                        `xml:"overflow,attr"`
	PaintOrder                Ident                        `xml:"paint-order,attr"`
	PointerEvents             Ident                        `xml:"pointer-events,attr"`
	ShapeRendering            Ident                        `xml:"shape-rendering,attr"`
	Stroke                    *Paint                       `xml:"stroke,attr"`
	StrokeDasharray           *DashArray                   `xml:"stroke-dasharray,attr"`
	StrokeDashoffset          *LengthPercentage            `xml:"stroke-dashoffset,attr"`
	StrokeLinecap             Ident                        `xml:"stroke-linecap,attr"`
	StrokeLinejoin            Ident                        `xml:"stroke-linejoin,attr"`
	StrokeMiterlimit          *float64                     `xml:"stroke-miterlimit,attr"`
	StrokeOpacity             *NumberPercentage            `xml:"stroke-opacity,attr"`
	StrokeWidth               *LengthPercentage            `xml:"stroke-width,attr"`
	TextAnchor                Ident                        `xml:"text-anchor,attr"`
	TextDecoration            Ident                        `xml:"text-decoration,attr"`
	TextOverflow              Ident                        `xml:"text-overflow,attr"`
	TextRendering             Ident                        `xml:"text-rendering,attr"`
	Transform                 []Transform                  `xml:"transform,attr"`
	UnicodeBidi               Ident                        `xml:"unicode-bidi,attr"`
	VectorEffect              *VectorEffect                `xml:"vector-effect,attr"`
	Visibility                Ident                        `xml:"visibility,attr"`
	WhiteSpace                Ident                        `xml:"white-space,attr"`
	WordSpacing               *LengthIdent                 `xml:"word-spacing,attr"`
	WritingMode               Ident                        `xml:"writing-mode,attr"`
}

ElementAttributes contains standard SVG element attributes.

type Ellipse

type Ellipse struct {
	ElementAttributes

	XMLName xml.Name `xml:"ellipse"`

	PathLength float64 `xml:"pathLength,attr"`

	Cx LengthPercentage `xml:"cx,attr"`
	Cy LengthPercentage `xml:"cy,attr"`

	Rx BoxLengthPercentage `xml:"rx,attr"`
	Ry BoxLengthPercentage `xml:"ry,attr"`

	Children []any `xml:",any"`
}

Ellipse represents an SVG `ellipse` element.

type EllipticalArc

type EllipticalArc struct {
	IsAbsolute bool

	Coordinates []EllipticalArcCoordinates
}

EllipticalArc represents an SVG elliptical arc command.

type EllipticalArcCoordinates

type EllipticalArcCoordinates struct {
	Point

	Rx            float64
	Ry            float64
	XAxisRotation float64
	LargeArc      bool
	Sweep         bool
}

EllipticalArcCoordinates represents a set of elliptical arc coordinates.

type FilterList

type FilterList string

type FontFamily

type FontFamily struct {
	Values []string
}

func (*FontFamily) UnmarshalText

func (ff *FontFamily) UnmarshalText(text []byte) error

type ForeignObject

type ForeignObject struct {
	ElementAttributes

	XMLName xml.Name `xml:"foreignObject"`

	X      LengthPercentage    `xml:"x,attr"`
	Y      LengthPercentage    `xml:"y,attr"`
	Width  BoxLengthPercentage `xml:"width,attr"`
	Height BoxLengthPercentage `xml:"height,attr"`

	InnerXML []byte `xml:",innerxml"`
}

ForeignObject represents an SVG `foreignObject` element.

type Gradient

type Gradient struct {
	ElementAttributes

	GradientUnits     Units       `xml:"gradientUnits,attr"`
	GradientTransform []Transform `xml:"gradientTransform,attr"`
	SpreadMethod      string      `xml:"spreadMethod,attr"`
	Href              string      `xml:"href,attr"`

	Stops []GradientStop `xml:"stop"`
}

Gradient holds fields common to the `linearGradient` and `radialGradient` elements.

type GradientStop

type GradientStop struct {
	ElementAttributes

	XMLName xml.Name `xml:"stop"`

	Offset  NumberPercentage `xml:"offset,attr"`
	Color   Color            `xml:"stop-color,attr"`
	Opacity NumberPercentage `xml:"stop-opacity,attr"`
}

GradientStop represents an SVG `stop` element.

type Grouping

type Grouping struct {
	ElementAttributes

	XMLName xml.Name `xml:"g"`

	Children []any `xml:",any"`
}

Grouping represents an SVG `g` element.

type Ident

type Ident string

func (*Ident) UnmarshalText

func (i *Ident) UnmarshalText(text []byte) error

type Image

type Image struct {
	ElementAttributes

	XMLName xml.Name `xml:"image"`

	PreserveAspectRatio string `xml:"preserveAspectRatio,attr"`
	Href                string `xml:"href,attr"`
	CrossOrigin         string `xml:"crossOrigin,attr"`

	X      LengthPercentage    `xml:"x,attr"`
	Y      LengthPercentage    `xml:"y,attr"`
	Width  BoxLengthPercentage `xml:"width,attr"`
	Height BoxLengthPercentage `xml:"height,attr"`
}

Image represents an SVG `image` element.

type Length

type Length struct {
	Value float64
	Units string
}

Length represents a CSS length.

func (*Length) UnmarshalText

func (l *Length) UnmarshalText(text []byte) error

type LengthIdent

type LengthIdent struct {
	Length Length
	Ident  string
}

func (*LengthIdent) UnmarshalText

func (lp *LengthIdent) UnmarshalText(text []byte) error

type LengthPercentage

type LengthPercentage struct {
	Length     Length
	Percentage float64
}

func (*LengthPercentage) UnmarshalText

func (lp *LengthPercentage) UnmarshalText(text []byte) error

type LengthPercentageIdent

type LengthPercentageIdent struct {
	LengthPercentage

	Ident string
}

func (*LengthPercentageIdent) UnmarshalText

func (lpi *LengthPercentageIdent) UnmarshalText(text []byte) error

type LengthPercentageNumber

type LengthPercentageNumber struct {
	LengthPercentage

	Number float64
}

func (*LengthPercentageNumber) UnmarshalText

func (lpn *LengthPercentageNumber) UnmarshalText(text []byte) error

type LengthPercentageNumberIdent

type LengthPercentageNumberIdent struct {
	LengthPercentageNumber

	Ident string
}

func (*LengthPercentageNumberIdent) UnmarshalText

func (lpni *LengthPercentageNumberIdent) UnmarshalText(text []byte) error

type LengthPercentageNumbers

type LengthPercentageNumbers struct {
	Values []LengthPercentageNumber
}

func (*LengthPercentageNumbers) UnmarshalText

func (ns *LengthPercentageNumbers) UnmarshalText(text []byte) error

type Line

type Line struct {
	ElementAttributes

	XMLName xml.Name `xml:"line"`

	PathLength float64 `xml:"pathLength,attr"`

	X1 LengthPercentageNumber `xml:"x1,attr"`
	Y1 LengthPercentageNumber `xml:"y1,attr"`
	X2 LengthPercentageNumber `xml:"x2,attr"`
	Y2 LengthPercentageNumber `xml:"y2,attr"`

	Children []any `xml:",any"`
}

Line represents an SVG `line` element.

type LineTo

type LineTo struct {
	IsAbsolute bool

	Points []Point
}

LineTo represents an SVG `lineto` command.

type LinearGradient

type LinearGradient struct {
	Gradient

	XMLName xml.Name `xml:"linearGradient"`

	X1 LengthPercentage `xml:"x1,attr"`
	Y1 LengthPercentage `xml:"y1,attr"`
	X2 LengthPercentage `xml:"x2,attr"`
	Y2 LengthPercentage `xml:"y2,attr"`
}

LinearGradient represents an SVG `linearGradient` element.

type Marker

type Marker struct {
	ElementAttributes

	XMLName xml.Name `xml:"marker"`

	PreserveAspectRatio string `xml:"preserveAspectRatio,attr"`
	ViewBox             string `xml:"viewBox,attr"`

	RefX Length `xml:"refX,attr"`
	RefY Length `xml:"refY,attr"`

	MarkerUnits  string                 `xml:"markerUnits,attr"`
	MarkerWidth  LengthPercentageNumber `xml:"markerWidth,attr"`
	MarkerHeight LengthPercentageNumber `xml:"markerHeight,attr"`

	Orient string `xml:"orient,attr"`

	Children []any `xml:",any"`
}

Marker represents an SVG `marker` element.

type Mask

type Mask string

type MoveTo

type MoveTo struct {
	IsAbsolute bool

	Points []Point
}

MoveTo represents an SVG `moveto` command.

type NumberIdent

type NumberIdent struct {
	Number float64
	Ident  string
}

NumberIdent represents an XML number or identifier.

func (*NumberIdent) UnmarshalText

func (ni *NumberIdent) UnmarshalText(text []byte) error

type NumberPercentage

type NumberPercentage struct {
	Number     float64
	Percentage float64
}

NumberPercentage represents an XML number or percentage.

func (*NumberPercentage) UnmarshalText

func (np *NumberPercentage) UnmarshalText(text []byte) error

type Paint

type Paint struct {
	Context string
	URL     string
	Color   color.Color
}

Paint represents a paint color.

func (*Paint) UnmarshalText

func (p *Paint) UnmarshalText(text []byte) error

type PaintElement

type PaintElement interface {
	// contains filtered or unexported methods
}

type Path

type Path struct {
	ElementAttributes

	XMLName xml.Name `xml:"path"`

	PathLength float64  `xml:"pathLength,attr"`
	D          PathData `xml:"d,attr"`

	Children []any `xml:",any"`
}

Path represents an SVG `path` element.

type PathCommand

type PathCommand interface {
	// contains filtered or unexported methods
}

PathCommand represents an SVG path command.

func ParsePathCommands

func ParsePathCommands(commands string) ([]PathCommand, error)

ParsePathCommands parses a sequence of SVG path commands according to the SVG path grammar (reproduced below).

svg_path::= wsp* moveto? (moveto drawto_command*)?

drawto_command::=

moveto
| closepath
| lineto
| horizontal_lineto
| vertical_lineto
| curveto
| smooth_curveto
| quadratic_bezier_curveto
| smooth_quadratic_bezier_curveto
| elliptical_arc

moveto::=

( "M" | "m" ) wsp* coordinate_pair_sequence

closepath::=

("Z" | "z")

lineto::=

("L"|"l") wsp* coordinate_pair_sequence

horizontal_lineto::=

("H"|"h") wsp* coordinate_sequence

vertical_lineto::=

("V"|"v") wsp* coordinate_sequence

curveto::=

("C"|"c") wsp* curveto_coordinate_sequence

curveto_coordinate_sequence::=

coordinate_pair_triplet
| (coordinate_pair_triplet comma_wsp? curveto_coordinate_sequence)

smooth_curveto::=

("S"|"s") wsp* smooth_curveto_coordinate_sequence

smooth_curveto_coordinate_sequence::=

coordinate_pair_double
| (coordinate_pair_double comma_wsp? smooth_curveto_coordinate_sequence)

quadratic_bezier_curveto::=

("Q"|"q") wsp* quadratic_bezier_curveto_coordinate_sequence

quadratic_bezier_curveto_coordinate_sequence::=

coordinate_pair_double
| (coordinate_pair_double comma_wsp? quadratic_bezier_curveto_coordinate_sequence)

smooth_quadratic_bezier_curveto::=

("T"|"t") wsp* coordinate_pair_sequence

elliptical_arc::=

( "A" | "a" ) wsp* elliptical_arc_argument_sequence

elliptical_arc_argument_sequence::=

elliptical_arc_argument
| (elliptical_arc_argument comma_wsp? elliptical_arc_argument_sequence)

elliptical_arc_argument::=

number comma_wsp? number comma_wsp? number comma_wsp
flag comma_wsp? flag comma_wsp? coordinate_pair

coordinate_pair_double::=

coordinate_pair comma_wsp? coordinate_pair

coordinate_pair_triplet::=

coordinate_pair comma_wsp? coordinate_pair comma_wsp? coordinate_pair

coordinate_pair_sequence::=

coordinate_pair | (coordinate_pair comma_wsp? coordinate_pair_sequence)

coordinate_sequence::=

coordinate | (coordinate comma_wsp? coordinate_sequence)

coordinate_pair::= coordinate comma_wsp? coordinate

coordinate::= sign? number

sign::= "+"|"-" number ::= ([0-9])+ flag::=("0"|"1") comma_wsp::=(wsp+ ","? wsp*) | ("," wsp*) wsp ::= (#x9 | #x20 | #xA | #xC | #xD)

type PathData

type PathData struct {
	Commands []PathCommand
}

PathData represents SVG path data.

func (*PathData) UnmarshalText

func (d *PathData) UnmarshalText(text []byte) error

type Pattern

type Pattern struct {
	ElementAttributes

	XMLName xml.Name `xml:"pattern"`

	ViewBox             string `xml:"viewBox,attr"`
	PreserveAspectRatio string `xml:"preserveAspectRatio,attr"`

	X      Length `xml:"x,attr"`
	Y      Length `xml:"y,attr"`
	Width  Length `xml:"width,attr"`
	Height Length `xml:"height,attr"`

	PatternUnits        Units `xml:"patternUnits,attr"`
	PatternContentUnits Units `xml:"patternContentUnits,attr"`

	PatternTransform []Transform `xml:"patternTransform,attr"`

	Href string `xml:"href,attr"`

	Children []any `xml:",any"`
}

Pattern represents an SVG `pattern` element.

type Point

type Point struct {
	X float64
	Y float64
}

type PolyPoints

type PolyPoints []Point

func (*PolyPoints) UnmarshalText

func (p *PolyPoints) UnmarshalText(text []byte) error

type Polygon

type Polygon struct {
	ElementAttributes

	XMLName xml.Name `xml:"polygon"`

	Points PolyPoints `xml:"points,attr"`

	Children []any `xml:",any"`
}

Polygon represents an SVG `polygon` element.

type Polyline

type Polyline struct {
	ElementAttributes

	XMLName xml.Name `xml:"polyline"`

	Points PolyPoints `xml:"points,attr"`

	Children []any `xml:",any"`
}

Polyline represents an SVG `polyline` element.

type QuadraticBezier

type QuadraticBezier struct {
	IsAbsolute bool

	Coordinates []QuadraticBezierCoordinates
}

QuadraticBezier represents an SVG cubic Bezier curve command.

type QuadraticBezierCoordinates

type QuadraticBezierCoordinates struct {
	Point

	X1 float64
	Y1 float64
}

QuadraticBezierCoordinates represents a set of cubic Bezier curve coordinates.

type RadialGradient

type RadialGradient struct {
	Gradient

	XMLName xml.Name `xml:"radialGradient"`

	Cx LengthPercentage `xml:"cx,attr"`
	Cy LengthPercentage `xml:"cy,attr"`
	R  LengthPercentage `xml:"r,attr"`
	Fx LengthPercentage `xml:"fx,attr"`
	Fy LengthPercentage `xml:"fy,attr"`
	Fr LengthPercentage `xml:"fr,attr"`
}

RadialGradient represents an SVG `radialGradient` element.

type Rect

type Rect struct {
	ElementAttributes

	XMLName xml.Name `xml:"rect"`

	PathLength float64 `xml:"pathLength,attr"`

	X      LengthPercentage    `xml:"x,attr"`
	Y      LengthPercentage    `xml:"y,attr"`
	Width  BoxLengthPercentage `xml:"width,attr"`
	Height BoxLengthPercentage `xml:"height,attr"`

	Rx *BoxLengthPercentage `xml:"rx,attr"`
	Ry *BoxLengthPercentage `xml:"ry,attr"`

	Children []any `xml:",any"`
}

Rect represents an SVG `rect` element.

type SVG

type SVG struct {
	XMLName xml.Name `xml:"svg"`

	Style *Style `xml:"style"`

	X      LengthPercentage    `xml:"x,attr"`
	Y      LengthPercentage    `xml:"y,attr"`
	Width  BoxLengthPercentage `xml:"width,attr"`
	Height BoxLengthPercentage `xml:"height,attr"`

	Children []any `xml:",any"`
}

SVG represents an SVG document.

type SVGImage

type SVGImage struct {
	// contains filtered or unexported fields
}

func (*SVGImage) At

func (i *SVGImage) At(x, y int) color.Color

func (*SVGImage) Bounds

func (i *SVGImage) Bounds() image.Rectangle

func (*SVGImage) ColorModel

func (i *SVGImage) ColorModel() color.Model

func (*SVGImage) Context

func (i *SVGImage) Context() *gg.Context

func (*SVGImage) SVG

func (i *SVGImage) SVG() *SVG

func (*SVGImage) Scale

func (i *SVGImage) Scale(factor float64) (*SVGImage, error)

type SolidColor

type SolidColor struct {
	color.Color
}

SolidColor represents a solid paint color.

type Style

type Style struct {
	XMLName xml.Name `xml:"style"`

	Type  string `xml:"type,attr"`
	Media string `xml:"media,attr"`
	Title string `xml:"title,attr`

	Style string `xml:",chardata"`
}

Style represents an SVG `style` element.

type Switch

type Switch struct {
	ElementAttributes

	XMLName xml.Name `xml:"switch"`

	Children []any `xml:",any"`
}

Switch represents an SVG `switch` element.

type Symbol

type Symbol struct {
	ElementAttributes

	XMLName xml.Name `xml:"symbol"`

	PreserveAspectRatio string `xml:"preserveAspectRatio,attr"`
	ViewBox             string `xml:"viewBox,attr"`

	RefX Length `xml:"refX,attr"`
	RefY Length `xml:"refY,attr"`

	X      LengthPercentage    `xml:"x,attr"`
	Y      LengthPercentage    `xml:"y,attr"`
	Width  BoxLengthPercentage `xml:"width,attr"`
	Height BoxLengthPercentage `xml:"height,attr"`

	Children []any `xml:",any"`
}

Symbol represents an SVG `symbol` element.

type TSpan

type TSpan struct {
	ElementAttributes

	XMLName xml.Name `xml:"tspan"`

	X  LengthPercentageNumbers `xml:"x,attr"`
	Y  LengthPercentageNumbers `xml:"y,attr"`
	Dx LengthPercentageNumbers `xml:"dx,attr"`
	Dy LengthPercentageNumbers `xml:"dy,attr"`

	Rotate LengthPercentageNumbers `xml:"rotate,attr"`

	TextLength   LengthPercentageNumber `xml:"textLength,attr"`
	LengthAdjust string                 `xml:"lengthAdjust,attr"`

	Value string `xml:",chardata"`
}

TSpan represents an SVG `tspan` element.

type Text

type Text struct {
	ElementAttributes

	XMLName xml.Name `xml:"text"`

	X  LengthPercentageNumbers `xml:"x,attr"`
	Y  LengthPercentageNumbers `xml:"y,attr"`
	Dx LengthPercentageNumbers `xml:"dx,attr"`
	Dy LengthPercentageNumbers `xml:"dy,attr"`

	Rotate LengthPercentageNumbers `xml:"rotate,attr"`

	TextLength LengthPercentageNumber `xml:"textLength,attr"`

	Value string `xml:",chardata"`
}

Text represents an SVG `text` element.

type TextPath

type TextPath struct {
	ElementAttributes

	XMLName xml.Name `xml:"textPath"`

	Path        PathData         `xml:"path,attr"`
	Href        string           `xml:"href,attr"`
	StartOffset LengthPercentage `xml:"startOffset,attr"`
	Method      string           `xml:"method,attr"`
	Spacing     string           `xml:"spacing,attr"`
	Side        string           `xml:"side,attr"`

	TextLength   LengthPercentageNumber `xml:"textLength,attr"`
	LengthAdjust string                 `xml:"lengthAdjust,attr"`

	Value string `xml:",chardata"`
}

TextPath represents an SVG `textPath` element.

type Transform

type Transform string

type URLIdent

type URLIdent struct {
	URL   string
	Ident string
}

func (*URLIdent) UnmarshalText

func (ui *URLIdent) UnmarshalText(text []byte) error

type Units

type Units string
const (
	UserSpaceOnUse    Units = "userSpaceOnUse"
	ObjectBoundingBox Units = "objectBoundingBox"
)

func (*Units) UnmarshalText

func (u *Units) UnmarshalText(text []byte) error

type Use

type Use struct {
	ElementAttributes

	XMLName xml.Name `xml:"use"`

	Href string `xml:"href,attr"`

	X      LengthPercentage    `xml:"x,attr"`
	Y      LengthPercentage    `xml:"y,attr"`
	Width  BoxLengthPercentage `xml:"width,attr"`
	Height BoxLengthPercentage `xml:"height,attr"`
}

Use represents an SVG `use` element.

type VectorEffect

type VectorEffect string

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL