Documentation
¶
Index ¶
- Constants
- type AnchorDef
- type CircleDef
- type DefsDef
- type GroupDef
- type PathDef
- type RectDef
- type SVG
- func (S *SVG) AddBackground(colorDef string)
- func (S *SVG) FindGroupsById(id any, findFirst bool) ([]*GroupDef, error)
- func (S *SVG) FindPathsById(id any, findFirst bool) ([]*PathDef, error)
- func (S *SVG) GetViewBox() (ViewBoxDef, error)
- func (S *SVG) GetXml() ([]byte, error)
- func (S *SVG) GetXmlIndented(indentPrefix, indentString string) ([]byte, error)
- func (S *SVG) SetViewBox(box ViewBoxDef)
- func (S *SVG) WriteFile(filename string) error
- type TSpanDef
- type TextDef
- type ViewBoxDef
Constants ¶
const ( FindFirst = true FindAll = false )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnchorDef ¶
type AnchorDef struct {
Id string `xml:"id,attr"`
Download string `xml:"Download,attr"`
Href string `xml:"href,attr"`
HrefLang string `xml:"hreflang,attr"`
ReferrerPolicy string `xml:"referrerpolicy,attr"`
Rel string `xml:"rel,attr"`
Target string `xml:"target,attr"`
Type string `xml:"type,attr"`
Xform string `xml:"transform,attr,omitempty"`
G []GroupDef `xml:"g"`
Rect []RectDef `xml:"rect"`
Circle []CircleDef `xml:"circle"`
}
type GroupDef ¶
type GroupDef struct {
G []GroupDef `xml:"g,omitempty"`
Id string `xml:"id,attr,omitempty"`
Xform string `xml:"transform,attr,omitempty"`
Style string `xml:"style,attr,omitempty"`
A []AnchorDef `xml:"a"`
Path []PathDef `xml:"path"`
Text []TextDef `xml:"text"`
Rect []RectDef `xml:"rect"`
Circle []CircleDef `xml:"circle"`
}
func (*GroupDef) FindPathsById ¶
FindGroupsById traverses a GroupDef object and returns a slice of PathDef with matching ids.
The supplied id may be a string or a compiled regular expression from the regexp package.
Use the FindFirst and FindAll constants as the second parameter to direct cause the method to return only the first matching element or all matching elements, respectively.
type RectDef ¶
type SVG ¶
type SVG struct {
Id string `xml:"id,attr"`
Width string `xml:"width,attr"`
Height string `xml:"height,attr"`
ViewBox string `xml:"viewBox,attr"`
Title string `xml:"title,attr,omitempty"`
Version string `xml:"version,attr"`
XMLNS string `xml:"xmlns,attr"`
XMLName xml.Name `xml:"svg"`
Defs DefsDef `xml:"defs"`
A []AnchorDef `xml:"a"`
G []GroupDef `xml:"g"`
Path []PathDef `xml:"path"`
Text []TextDef `xml:"text"`
Rect []RectDef `xml:"rect"`
Circle []CircleDef `xml:"circle"`
}
func NewFromBytes ¶
NewFromBytes() accepts a byte slice of SVG XML data and returns an SVG object pointer or an error.
func NewFromFile ¶
NewFromFile() accepts a filename containing SVG XML data and returns an object pointer or an error.
This method calls NewFromBytes() after successfully reading from the file named in the filename parameter.
func (*SVG) AddBackground ¶
AddBackground() takes a color definition, such as #<hex> or a name like "red", and creates a group containing a rect matching the image size and specified color.
The new group is prepended to the top-level G slice to ensure that it is the bottom-most element in the image.
func (*SVG) FindGroupsById ¶
FindGroupsById traverses a GroupDef object and returns a slice of GroupDef with matching ids.
The supplied id may be a string or a compiled regular expression from the regexp package.
Use the FindFirst and FindAll constants as the second parameter to direct cause the method to return only the first matching element or all matching elements, respectively.
func (*SVG) FindPathsById ¶
FindPathsById traverses an SVG object and returns a slice of PathDef with matching ids.
The supplied id may be a string or a compiled regular expression from the regexp package.
Use the FindFirst and FindAll constants as the second parameter to direct cause the method to return only the first matching element or all matching elements, respectively.
func (*SVG) GetViewBox ¶
func (S *SVG) GetViewBox() (ViewBoxDef, error)
func (*SVG) GetXmlIndented ¶
GetXml() returns the current object as a byte slice, using xml.MarshalIndent().
The indentPrefix and indentString parameters are passed directly to xml.MarshalIndent().
func (*SVG) SetViewBox ¶
func (S *SVG) SetViewBox(box ViewBoxDef)
type TextDef ¶
type TextDef struct {
// svgElem
Id string `xml:"id,attr"`
X string `xml:"x,attr"`
Y string `xml:"y,attr"`
Width string `xml:"width,attr,omitempty"`
Height string `xml:"height,attr,omitempty"`
Style string `xml:"style,attr,omitempty"`
Xform string `xml:"transform,attr,omitempty"`
TextLength string `xml:",attr,omitempty"`
Label string `xml:",chardata"`
TSpan []TSpanDef `xml:"tspan"`
}
type ViewBoxDef ¶
type ViewBoxDef struct {
X, Y, Width, Height float64
}