Documentation
¶
Overview ¶
Package svg provides SVG rendering classes, I/O parsing: full SVG rendering
SVG currently supports most of SVG, but not:
- Flow
- Filter Effects
- 3D Perspective transforms
See gi/examples/svg for a basic SVG viewer app, using the svg.Editor, which will ultimately be expanded to support more advanced editing. Also in that directory are a number of test files that stress different aspects of rendering.
svg.NodeBase is the base type for all SVG elements -- unlike Widget nodes, SVG nodes do not use layout logic, and just draw directly into a parent SVG viewport, with cumulative transforms determining drawing position, etc. The BBox values are only valid after rendering for these nodes.
It uses srwiley/rasterx for SVG-compatible rasterization, and the gi.Paint interface for drawing.
The Path element uses a compiled bytecode version of the Data path for increased speed.
Index ¶
- Constants
- Variables
- func AggCSS(agg *ki.Props, css ki.Props)
- func BBoxFromChildren(gi Node) image.Rectangle
- func EscapeText(w io.Writer, s []byte, escapeNewline bool) error
- func GradientReadPts(gr gradient.Gradient, dat []float32)
- func GradientWritePts(gr gradient.Gradient, dat *[]float32)
- func IncRefCount(k ki.Ki)
- func NameFromURL(url string) string
- func NameId(nm string, id int) string
- func NameToURL(nm string) string
- func NodePropURL(gi Node, prop string) string
- func PathCmdIsRel(pc PathCmds) bool
- func PathDataBBox(data []PathData) mat32.Box2
- func PathDataEnd(data []PathData) (vec mat32.Vec2, ang float32)
- func PathDataIterFunc(data []PathData, ...)
- func PathDataNext(data []PathData, i *int) float32
- func PathDataNextRel(data []PathData, i *int, cp mat32.Vec2) mat32.Vec2
- func PathDataNextVec(data []PathData, i *int) mat32.Vec2
- func PathDataRender(data []PathData, pc *paint.Context)
- func PathDataStart(data []PathData) (vec mat32.Vec2, ang float32)
- func PathDataString(data []PathData) string
- func PathDataTransformAbs(data []PathData, i *int, xf mat32.Mat2, lpt mat32.Vec2) mat32.Vec2
- func PathDataTransformRel(data []PathData, i *int, xf mat32.Mat2, cp mat32.Vec2) mat32.Vec2
- func PathDataValidate(data *[]PathData, errstr string) error
- func SVGNodeMarshalXML(itm ki.Ki, enc *XMLEncoder, setName string) string
- func SVGNodeTreeMarshalXML(itm Node, enc *XMLEncoder, setName string) (string, error)
- func SVGNodeXMLGrad(nd *Gradient, name string, enc *XMLEncoder)
- func SVGWalkPre(n Node, fun func(kni Node, knb *NodeBase) bool)
- func SetFloat32SliceLen(dat *[]float32, sz int)
- func SetStdXMLAttr(ni Node, name, val string) bool
- func SplitNameId(elnm, nm string) (bool, int)
- func SplitNameIdDig(nm string) (string, int)
- func XMLAddAttr(attr *[]xml.Attr, name, val string)
- type Circle
- func (g *Circle) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *Circle) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *Circle) CopyFieldsFrom(frm any)
- func (t *Circle) KiType() *gti.Type
- func (g *Circle) LocalBBox() mat32.Box2
- func (t *Circle) New() ki.Ki
- func (g *Circle) OnInit()
- func (g *Circle) ReadGeom(sv *SVG, dat []float32)
- func (g *Circle) Render(sv *SVG)
- func (g *Circle) SVGName() string
- func (t *Circle) SetClass(v string) *Circle
- func (g *Circle) SetPos(pos mat32.Vec2) *Circle
- func (t *Circle) SetRadius(v float32) *Circle
- func (g *Circle) SetSize(sz mat32.Vec2) *Circle
- func (g *Circle) WriteGeom(sv *SVG, dat *[]float32)
- type ClipPath
- type Ellipse
- func (g *Ellipse) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *Ellipse) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *Ellipse) CopyFieldsFrom(frm any)
- func (t *Ellipse) KiType() *gti.Type
- func (g *Ellipse) LocalBBox() mat32.Box2
- func (t *Ellipse) New() ki.Ki
- func (g *Ellipse) OnInit()
- func (g *Ellipse) ReadGeom(sv *SVG, dat []float32)
- func (g *Ellipse) Render(sv *SVG)
- func (g *Ellipse) SVGName() string
- func (t *Ellipse) SetClass(v string) *Ellipse
- func (g *Ellipse) SetPos(pos mat32.Vec2) *Ellipse
- func (t *Ellipse) SetRadii(v mat32.Vec2) *Ellipse
- func (g *Ellipse) SetSize(sz mat32.Vec2) *Ellipse
- func (g *Ellipse) WriteGeom(sv *SVG, dat *[]float32)
- type Filter
- type Flow
- type Gradient
- func (gr *Gradient) CopyFieldsFrom(frm any)
- func (gr *Gradient) GradientTypeName() string
- func (t *Gradient) KiType() *gti.Type
- func (t *Gradient) New() ki.Ki
- func (t *Gradient) SetClass(v string) *Gradient
- func (t *Gradient) SetGrad(v gradient.Gradient) *Gradient
- func (t *Gradient) SetStopsName(v string) *Gradient
- type Group
- func (g *Group) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *Group) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *Group) CopyFieldsFrom(frm any)
- func (g *Group) EnforceSVGName() bool
- func (t *Group) KiType() *gti.Type
- func (t *Group) New() ki.Ki
- func (g *Group) NodeBBox(sv *SVG) image.Rectangle
- func (g *Group) ReadGeom(sv *SVG, dat []float32)
- func (g *Group) Render(sv *SVG)
- func (g *Group) SVGName() string
- func (t *Group) SetClass(v string) *Group
- func (g *Group) WriteGeom(sv *SVG, dat *[]float32)
- type Image
- func (g *Image) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *Image) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *Image) CopyFieldsFrom(frm any)
- func (g *Image) DrawImage(sv *SVG)
- func (t *Image) KiType() *gti.Type
- func (g *Image) LocalBBox() mat32.Box2
- func (t *Image) New() ki.Ki
- func (g *Image) NodeBBox(sv *SVG) image.Rectangle
- func (g *Image) OpenImage(filename string, width, height float32) error
- func (g *Image) ReadGeom(sv *SVG, dat []float32)
- func (g *Image) Render(sv *SVG)
- func (g *Image) SVGName() string
- func (g *Image) SaveImage(filename string) error
- func (t *Image) SetClass(v string) *Image
- func (t *Image) SetFilename(v string) *Image
- func (g *Image) SetImage(img image.Image, width, height float32)
- func (g *Image) SetImageSize(nwsz image.Point)
- func (t *Image) SetPixels(v *image.RGBA) *Image
- func (t *Image) SetPos(v mat32.Vec2) *Image
- func (t *Image) SetPreserveAspectRatio(v bool) *Image
- func (t *Image) SetSize(v mat32.Vec2) *Image
- func (g *Image) WriteGeom(sv *SVG, dat *[]float32)
- type Line
- func (g *Line) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *Line) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *Line) CopyFieldsFrom(frm any)
- func (t *Line) KiType() *gti.Type
- func (g *Line) LocalBBox() mat32.Box2
- func (t *Line) New() ki.Ki
- func (g *Line) OnInit()
- func (g *Line) ReadGeom(sv *SVG, dat []float32)
- func (g *Line) Render(sv *SVG)
- func (g *Line) SVGName() string
- func (t *Line) SetClass(v string) *Line
- func (t *Line) SetEnd(v mat32.Vec2) *Line
- func (g *Line) SetPos(pos mat32.Vec2)
- func (g *Line) SetSize(sz mat32.Vec2)
- func (t *Line) SetStart(v mat32.Vec2) *Line
- func (g *Line) WriteGeom(sv *SVG, dat *[]float32)
- type Marker
- func (g *Marker) BBoxes(sv *SVG)
- func (g *Marker) CopyFieldsFrom(frm any)
- func (g *Marker) EnforceSVGName() bool
- func (t *Marker) KiType() *gti.Type
- func (t *Marker) New() ki.Ki
- func (g *Marker) Render(sv *SVG)
- func (mrk *Marker) RenderMarker(sv *SVG, vertexPos mat32.Vec2, vertexAng, strokeWidth float32)
- func (g *Marker) SVGName() string
- func (t *Marker) SetClass(v string) *Marker
- func (t *Marker) SetEffSize(v mat32.Vec2) *Marker
- func (t *Marker) SetOrient(v string) *Marker
- func (t *Marker) SetRefPos(v mat32.Vec2) *Marker
- func (t *Marker) SetSize(v mat32.Vec2) *Marker
- func (t *Marker) SetStrokeWidth(v float32) *Marker
- func (t *Marker) SetTransform(v mat32.Mat2) *Marker
- func (t *Marker) SetUnits(v MarkerUnits) *Marker
- func (t *Marker) SetVertexAngle(v float32) *Marker
- func (t *Marker) SetVertexPos(v mat32.Vec2) *Marker
- func (t *Marker) SetViewBox(v ViewBox) *Marker
- type MarkerUnits
- type MetaData
- type Node
- type NodeBase
- func (g *NodeBase) ApplyCSS(sv *SVG, key string, css ki.Props) bool
- func (g *NodeBase) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *NodeBase) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *NodeBase) AsNodeBase() *NodeBase
- func (g *NodeBase) BBoxes(sv *SVG)
- func (n *NodeBase) BaseIface() reflect.Type
- func (g *NodeBase) CopyFieldsFrom(frm any)
- func (g *NodeBase) DeltaTransform(trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2, self bool) (mat32.Mat2, mat32.Vec2)
- func (g *NodeBase) EnforceSVGName() bool
- func (g *NodeBase) GradientApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *NodeBase) GradientApplyTransformPt(sv *SVG, xf mat32.Mat2, pt mat32.Vec2)
- func (g *NodeBase) GradientReadPts(sv *SVG, dat []float32)
- func (g *NodeBase) GradientWritePts(sv *SVG, dat *[]float32)
- func (g *NodeBase) Init()
- func (g *NodeBase) IsDefs() bool
- func (t *NodeBase) KiType() *gti.Type
- func (g *NodeBase) LocalBBox() mat32.Box2
- func (g *NodeBase) LocalBBoxToWin(bb mat32.Box2) image.Rectangle
- func (g *NodeBase) LocalLineWidth() float32
- func (t *NodeBase) New() ki.Ki
- func (g *NodeBase) NodeBBox(sv *SVG) image.Rectangle
- func (g *NodeBase) PaintStyle() *styles.Paint
- func (g *NodeBase) ParTransform(self bool) mat32.Mat2
- func (g *NodeBase) PushTransform(sv *SVG) (bool, *paint.Context)
- func (g *NodeBase) ReadGeom(sv *SVG, dat []float32)
- func (g *NodeBase) ReadTransform(dat []float32, idx int)
- func (g *NodeBase) Render(sv *SVG)
- func (g *NodeBase) RenderChildren(sv *SVG)
- func (g *NodeBase) SVGName() string
- func (t *NodeBase) SetClass(v string) *NodeBase
- func (g *NodeBase) SetColorProps(prop, color string)
- func (g *NodeBase) SetPos(pos mat32.Vec2)
- func (g *NodeBase) SetSize(sz mat32.Vec2)
- func (g *NodeBase) Style(sv *SVG)
- func (g *NodeBase) StyleCSS(sv *SVG, css ki.Props)
- func (g *NodeBase) WriteGeom(sv *SVG, dat *[]float32)
- func (g *NodeBase) WriteTransform(dat []float32, idx int)
- type NodeFlags
- func (i NodeFlags) BitIndexString() string
- func (i NodeFlags) Desc() string
- func (i NodeFlags) HasFlag(f enums.BitFlag) bool
- func (i NodeFlags) Int64() int64
- func (i NodeFlags) IsValid() bool
- func (i NodeFlags) MarshalText() ([]byte, error)
- func (i *NodeFlags) SetFlag(on bool, f ...enums.BitFlag)
- func (i *NodeFlags) SetInt64(in int64)
- func (i *NodeFlags) SetString(s string) error
- func (i *NodeFlags) SetStringOr(s string) error
- func (i NodeFlags) String() string
- func (i *NodeFlags) UnmarshalText(text []byte) error
- func (i NodeFlags) Values() []enums.Enum
- type Path
- func (g *Path) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *Path) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *Path) ApplyTransformImpl(xf mat32.Mat2, lpt mat32.Vec2)
- func (g *Path) CopyFieldsFrom(frm any)
- func (t *Path) KiType() *gti.Type
- func (g *Path) LocalBBox() mat32.Box2
- func (t *Path) New() ki.Ki
- func (g *Path) ReadGeom(sv *SVG, dat []float32)
- func (g *Path) Render(sv *SVG)
- func (g *Path) SVGName() string
- func (t *Path) SetClass(v string) *Path
- func (g *Path) SetData(data string) error
- func (t *Path) SetDataStr(v string) *Path
- func (g *Path) SetPos(pos mat32.Vec2)
- func (g *Path) SetSize(sz mat32.Vec2)
- func (g *Path) WriteGeom(sv *SVG, dat *[]float32)
- type PathCmds
- type PathData
- type Polygon
- type Polyline
- func (g *Polyline) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *Polyline) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *Polyline) CopyFieldsFrom(frm any)
- func (t *Polyline) KiType() *gti.Type
- func (g *Polyline) LocalBBox() mat32.Box2
- func (t *Polyline) New() ki.Ki
- func (g *Polyline) ReadGeom(sv *SVG, dat []float32)
- func (g *Polyline) Render(sv *SVG)
- func (g *Polyline) SVGName() string
- func (t *Polyline) SetClass(v string) *Polyline
- func (t *Polyline) SetPoints(v []mat32.Vec2) *Polyline
- func (g *Polyline) SetPos(pos mat32.Vec2)
- func (g *Polyline) SetSize(sz mat32.Vec2)
- func (g *Polyline) WriteGeom(sv *SVG, dat *[]float32)
- type Rect
- func (g *Rect) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *Rect) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *Rect) CopyFieldsFrom(frm any)
- func (t *Rect) KiType() *gti.Type
- func (g *Rect) LocalBBox() mat32.Box2
- func (t *Rect) New() ki.Ki
- func (g *Rect) OnInit()
- func (g *Rect) ReadGeom(sv *SVG, dat []float32)
- func (g *Rect) Render(sv *SVG)
- func (g *Rect) SVGName() string
- func (t *Rect) SetClass(v string) *Rect
- func (t *Rect) SetPos(v mat32.Vec2) *Rect
- func (t *Rect) SetRadius(v mat32.Vec2) *Rect
- func (t *Rect) SetSize(v mat32.Vec2) *Rect
- func (g *Rect) WriteGeom(sv *SVG, dat *[]float32)
- type SVG
- func (sv *SVG) Base() color.RGBA
- func (sv *SVG) Config(width, height int)
- func (sv *SVG) CopyFrom(fr *SVG)
- func (sv *SVG) DeleteAll()
- func (sv *SVG) FillViewport()
- func (sv *SVG) FindDefByName(defnm string) Node
- func (sv *SVG) FindNamedElement(name string) Node
- func (sv *SVG) GatherIds()
- func (sv *SVG) GradientByName(n Node, grnm string) *Gradient
- func (sv *SVG) GradientCloneNodeProp(n Node, prop string) *Gradient
- func (sv *SVG) GradientDeleteForNode(n Node, grnm string) bool
- func (sv *SVG) GradientDeleteNodeProp(n Node, prop string) bool
- func (sv *SVG) GradientNew(radial bool) (*Gradient, string)
- func (sv *SVG) GradientNewForNode(n Node, radial bool, stops string) (*Gradient, string)
- func (sv *SVG) GradientUpdateAllStops()
- func (sv *SVG) GradientUpdateNodePoints(n Node, prop string)
- func (sv *SVG) GradientUpdateNodeProp(n Node, prop string, radial bool, stops string) (*Gradient, string)
- func (sv *SVG) GradientUpdateStops(gr *Gradient)
- func (sv *SVG) ImageByURL(url string) image.Image
- func (sv *SVG) MarkerByName(gi Node, marker string) *Marker
- func (sv *SVG) MarshalXMLx(enc *XMLEncoder, se xml.StartElement) error
- func (sv *SVG) NewUniqueId() int
- func (sv *SVG) NodeEnsureUniqueId(ni Node)
- func (sv *SVG) NodeFindURL(gi Node, url string) Node
- func (sv *SVG) OpenFS(fsys fs.FS, fname string) error
- func (sv *SVG) OpenXML(fname string) error
- func (sv *SVG) ReadXML(reader io.Reader) error
- func (sv *SVG) RemoveOrphanedDefs() bool
- func (sv *SVG) Render()
- func (sv *SVG) Resize(nwsz image.Point)
- func (sv *SVG) SavePNG(fname string) error
- func (sv *SVG) SaveXML(fname string) error
- func (sv *SVG) SetDPITransform(logicalDPI float32)
- func (sv *SVG) SetRootTransform()
- func (sv *SVG) SetUnitContext(pc *styles.Paint, el, par mat32.Vec2)
- func (sv *SVG) Style()
- func (sv *SVG) UnmarshalXML(decoder *xml.Decoder, se xml.StartElement) error
- func (sv *SVG) WriteXML(wr io.Writer, indent bool) error
- type SVGNode
- func (g *SVGNode) CopyFieldsFrom(frm any)
- func (g *SVGNode) EnforceSVGName() bool
- func (t *SVGNode) KiType() *gti.Type
- func (t *SVGNode) New() ki.Ki
- func (g *SVGNode) NodeBBox(sv *SVG) image.Rectangle
- func (g *SVGNode) SVGName() string
- func (t *SVGNode) SetClass(v string) *SVGNode
- func (t *SVGNode) SetViewBox(v ViewBox) *SVGNode
- type StyleSheet
- func (ss *StyleSheet) CSSProps() ki.Props
- func (ss *StyleSheet) CopyFieldsFrom(frm any)
- func (t *StyleSheet) KiType() *gti.Type
- func (t *StyleSheet) New() ki.Ki
- func (ss *StyleSheet) ParseString(str string) error
- func (t *StyleSheet) SetClass(v string) *StyleSheet
- func (t *StyleSheet) SetSheet(v *css.Stylesheet) *StyleSheet
- type Text
- func (g *Text) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
- func (g *Text) ApplyTransform(sv *SVG, xf mat32.Mat2)
- func (g *Text) CopyFieldsFrom(frm any)
- func (g *Text) IsParText() bool
- func (t *Text) KiType() *gti.Type
- func (g *Text) LocalBBox() mat32.Box2
- func (t *Text) New() ki.Ki
- func (g *Text) NodeBBox(sv *SVG) image.Rectangle
- func (g *Text) ReadGeom(sv *SVG, dat []float32)
- func (g *Text) Render(sv *SVG)
- func (g *Text) RenderText(sv *SVG)
- func (g *Text) SVGName() string
- func (t *Text) SetAdjustGlyphs(v bool) *Text
- func (t *Text) SetCharPosDx(v []float32) *Text
- func (t *Text) SetCharPosDy(v []float32) *Text
- func (t *Text) SetCharPosX(v []float32) *Text
- func (t *Text) SetCharPosY(v []float32) *Text
- func (t *Text) SetCharRots(v []float32) *Text
- func (t *Text) SetClass(v string) *Text
- func (t *Text) SetLastBbox(v mat32.Box2) *Text
- func (t *Text) SetLastPos(v mat32.Vec2) *Text
- func (g *Text) SetPos(pos mat32.Vec2) *Text
- func (g *Text) SetSize(sz mat32.Vec2) *Text
- func (t *Text) SetText(v string) *Text
- func (t *Text) SetTextLength(v float32) *Text
- func (t *Text) SetTextRender(v paint.Text) *Text
- func (t *Text) SetWidth(v float32) *Text
- func (g *Text) TextBBox() mat32.Box2
- func (g *Text) WriteGeom(sv *SVG, dat *[]float32)
- type ViewBox
- type ViewBoxAlign
- type ViewBoxMeetOrSlice
- func (i ViewBoxMeetOrSlice) Desc() string
- func (i ViewBoxMeetOrSlice) Int64() int64
- func (i ViewBoxMeetOrSlice) IsValid() bool
- func (i ViewBoxMeetOrSlice) MarshalText() ([]byte, error)
- func (i *ViewBoxMeetOrSlice) SetInt64(in int64)
- func (i *ViewBoxMeetOrSlice) SetString(s string) error
- func (i ViewBoxMeetOrSlice) String() string
- func (i *ViewBoxMeetOrSlice) UnmarshalText(text []byte) error
- func (i ViewBoxMeetOrSlice) Values() []enums.Enum
- type ViewBoxPreserveAspectRatio
- type XMLEncoder
- func (xe *XMLEncoder) EncodeToken(t xml.Token) error
- func (xe *XMLEncoder) EscapeString(s string, escapeNewline bool)
- func (xe *XMLEncoder) Flush()
- func (xe *XMLEncoder) Indent(prefix, indent string)
- func (xe *XMLEncoder) WriteEOL()
- func (xe *XMLEncoder) WriteEnd(name string) error
- func (xe *XMLEncoder) WriteIndent()
- func (xe *XMLEncoder) WriteStart(start *xml.StartElement) error
- func (xe *XMLEncoder) WriteString(str string)
Constants ¶
const ( // Version is the version of this package being used Version = "v0.1.28" // GitCommit is the commit just before the latest version commit GitCommit = "b0c8aa8" // VersionDate is the date-time of the latest version commit in UTC (in the format 'YYYY-MM-DD HH:MM', which is the Go format '2006-01-02 15:04') VersionDate = "2023-12-26 23:35" )
const SVGRefCountKey = "SVGRefCount"
Variables ¶
var CircleType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Circle", ShortName: "svg.Circle", IDName: "circle", Doc: "Circle is a SVG circle", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Pos", >i.Field{Name: "Pos", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "position of the center of the circle", Directives: gti.Directives{}, Tag: "xml:\"{cx,cy}\" set:\"-\""}}, {"Radius", >i.Field{Name: "Radius", Type: "float32", LocalType: "float32", Doc: "radius of the circle", Directives: gti.Directives{}, Tag: "xml:\"r\""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Circle{}, })
CircleType is the gti.Type for Circle
var ClipPathType = gti.AddType(>i.Type{ Name: "goki.dev/svg.ClipPath", ShortName: "svg.ClipPath", IDName: "clip-path", Doc: "ClipPath is used for holding a path that renders as a clip path", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &ClipPath{}, })
ClipPathType is the gti.Type for ClipPath
var EllipseType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Ellipse", ShortName: "svg.Ellipse", IDName: "ellipse", Doc: "Ellipse is a SVG ellipse", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Pos", >i.Field{Name: "Pos", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "position of the center of the ellipse", Directives: gti.Directives{}, Tag: "xml:\"{cx,cy}\" set:\"-\""}}, {"Radii", >i.Field{Name: "Radii", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "radii of the ellipse in the horizontal, vertical axes", Directives: gti.Directives{}, Tag: "xml:\"{rx,ry}\""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Ellipse{}, })
EllipseType is the gti.Type for Ellipse
var FilterType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Filter", ShortName: "svg.Filter", IDName: "filter", Doc: "Filter represents SVG filter* elements", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"FilterType", >i.Field{Name: "FilterType", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Filter{}, })
FilterType is the gti.Type for Filter
var FlowType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Flow", ShortName: "svg.Flow", IDName: "flow", Doc: "Flow represents SVG flow* elements", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"FlowType", >i.Field{Name: "FlowType", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Flow{}, })
FlowType is the gti.Type for Flow
var GradientType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Gradient", ShortName: "svg.Gradient", IDName: "gradient", Doc: "Gradient is used for holding a specified color gradient.\nThe name is the id for lookup in url", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Grad", >i.Field{Name: "Grad", Type: "goki.dev/colors/gradient.Gradient", LocalType: "gradient.Gradient", Doc: "the color gradient", Directives: gti.Directives{}, Tag: ""}}, {"StopsName", >i.Field{Name: "StopsName", Type: "string", LocalType: "string", Doc: "name of another gradient to get stops from", Directives: gti.Directives{}, Tag: ""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Gradient{}, })
GradientType is the gti.Type for Gradient
var GroupType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Group", ShortName: "svg.Group", IDName: "group", Doc: "Group groups together SVG elements.\nProvides a common transform for all group elements\nand shared style properties.", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Group{}, })
GroupType is the gti.Type for Group
var ImageType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Image", ShortName: "svg.Image", IDName: "image", Doc: "Image is an SVG image (bitmap)", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Pos", >i.Field{Name: "Pos", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "position of the top-left of the image", Directives: gti.Directives{}, Tag: "xml:\"{x,y}\""}}, {"Size", >i.Field{Name: "Size", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "rendered size of the image (imposes a scaling on image when it is rendered)", Directives: gti.Directives{}, Tag: "xml:\"{width,height}\""}}, {"PreserveAspectRatio", >i.Field{Name: "PreserveAspectRatio", Type: "bool", LocalType: "bool", Doc: "directs resize operations to preserve aspect ratio", Directives: gti.Directives{}, Tag: "xml:\"preserveAspectRatio\""}}, {"Filename", >i.Field{Name: "Filename", Type: "string", LocalType: "string", Doc: "file name of image loaded -- set by OpenImage", Directives: gti.Directives{}, Tag: ""}}, {"Pixels", >i.Field{Name: "Pixels", Type: "*image.RGBA", LocalType: "*image.RGBA", Doc: "the image pixels", Directives: gti.Directives{}, Tag: "copy:\"-\" xml:\"-\" json:\"-\" view:\"-\""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Image{}, })
ImageType is the gti.Type for Image
var InkscapeProps = map[string]bool{ "isstock": true, "stockid": true, }
InkscapeProps are property keys that should be prefixed with "inkscape:"
var LineType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Line", ShortName: "svg.Line", IDName: "line", Doc: "Line is a SVG line", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Start", >i.Field{Name: "Start", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "position of the start of the line", Directives: gti.Directives{}, Tag: "xml:\"{x1,y1}\""}}, {"End", >i.Field{Name: "End", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "position of the end of the line", Directives: gti.Directives{}, Tag: "xml:\"{x2,y2}\""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Line{}, })
LineType is the gti.Type for Line
var MarkerType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Marker", ShortName: "svg.Marker", IDName: "marker", Doc: "Marker represents marker elements that can be drawn along paths (arrow heads, etc)", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"RefPos", >i.Field{Name: "RefPos", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "reference position to align the vertex position with, specified in ViewBox coordinates", Directives: gti.Directives{}, Tag: "xml:\"{refX,refY}\""}}, {"Size", >i.Field{Name: "Size", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "size of marker to render, in Units units", Directives: gti.Directives{}, Tag: "xml:\"{markerWidth,markerHeight}\""}}, {"Units", >i.Field{Name: "Units", Type: "goki.dev/svg.MarkerUnits", LocalType: "MarkerUnits", Doc: "units to use", Directives: gti.Directives{}, Tag: "xml:\"markerUnits\""}}, {"ViewBox", >i.Field{Name: "ViewBox", Type: "goki.dev/svg.ViewBox", LocalType: "ViewBox", Doc: "viewbox defines the internal coordinate system for the drawing elements within the marker", Directives: gti.Directives{}, Tag: ""}}, {"Orient", >i.Field{Name: "Orient", Type: "string", LocalType: "string", Doc: "orientation of the marker -- either 'auto' or an angle", Directives: gti.Directives{}, Tag: "xml:\"orient\""}}, {"VertexPos", >i.Field{Name: "VertexPos", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "current vertex position", Directives: gti.Directives{}, Tag: ""}}, {"VertexAngle", >i.Field{Name: "VertexAngle", Type: "float32", LocalType: "float32", Doc: "current vertex angle in radians", Directives: gti.Directives{}, Tag: ""}}, {"StrokeWidth", >i.Field{Name: "StrokeWidth", Type: "float32", LocalType: "float32", Doc: "current stroke width", Directives: gti.Directives{}, Tag: ""}}, {"Transform", >i.Field{Name: "Transform", Type: "goki.dev/mat32/v2.Mat2", LocalType: "mat32.Mat2", Doc: "net transform computed from settings and current values -- applied prior to rendering", Directives: gti.Directives{}, Tag: ""}}, {"EffSize", >i.Field{Name: "EffSize", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "effective size for actual rendering", Directives: gti.Directives{}, Tag: ""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Marker{}, })
MarkerType is the gti.Type for Marker
var MetaDataType = gti.AddType(>i.Type{ Name: "goki.dev/svg.MetaData", ShortName: "svg.MetaData", IDName: "meta-data", Doc: "MetaData is used for holding meta data info", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"MetaData", >i.Field{Name: "MetaData", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &MetaData{}, })
MetaDataType is the gti.Type for MetaData
var NodeBaseType = gti.AddType(>i.Type{ Name: "goki.dev/svg.NodeBase", ShortName: "svg.NodeBase", IDName: "node-base", Doc: "svg.NodeBase is the base type for elements within the SVG scenegraph", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Class", >i.Field{Name: "Class", Type: "string", LocalType: "string", Doc: "user-defined class name(s) used primarily for attaching CSS styles to different display elements -- multiple class names can be used to combine properties: use spaces to separate per css standard", Directives: gti.Directives{}, Tag: ""}}, {"CSS", >i.Field{Name: "CSS", Type: "goki.dev/ki/v2.Props", LocalType: "ki.Props", Doc: "cascading style sheet at this level -- these styles apply here and to everything below, until superceded -- use .class and #name Props elements to apply entire styles to given elements, and type for element type", Directives: gti.Directives{}, Tag: "xml:\"css\" set:\"-\""}}, {"CSSAgg", >i.Field{Name: "CSSAgg", Type: "goki.dev/ki/v2.Props", LocalType: "ki.Props", Doc: "aggregated css properties from all higher nodes down to me", Directives: gti.Directives{}, Tag: "copy:\"-\" json:\"-\" xml:\"-\" set:\"-\" view:\"no-inline\""}}, {"BBox", >i.Field{Name: "BBox", Type: "image.Rectangle", LocalType: "image.Rectangle", Doc: "bounding box for the node within the SVG Pixels image -- this one can be outside the visible range of the SVG image -- VpBBox is intersected and only shows visible portion.", Directives: gti.Directives{}, Tag: "copy:\"-\" json:\"-\" xml:\"-\" set:\"-\""}}, {"VisBBox", >i.Field{Name: "VisBBox", Type: "image.Rectangle", LocalType: "image.Rectangle", Doc: "visible bounding box for the node intersected with the SVG image geometry", Directives: gti.Directives{}, Tag: "copy:\"-\" json:\"-\" xml:\"-\" set:\"-\""}}, {"Paint", >i.Field{Name: "Paint", Type: "goki.dev/girl/styles.Paint", LocalType: "styles.Paint", Doc: "paint style information for this node", Directives: gti.Directives{}, Tag: "json:\"-\" xml:\"-\" set:\"-\""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Node", >i.Field{Name: "Node", Type: "goki.dev/ki/v2.Node", LocalType: "ki.Node", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &NodeBase{}, })
NodeBaseType is the gti.Type for NodeBase
var PathCmdNMap = map[PathCmds]int{ PcM: 2, Pcm: 2, PcL: 2, Pcl: 2, PcH: 1, Pch: 1, PcV: 1, Pcv: 1, PcC: 6, Pcc: 6, PcS: 4, Pcs: 4, PcQ: 4, Pcq: 4, PcT: 2, Pct: 2, PcA: 7, Pca: 7, PcZ: 0, Pcz: 0, }
PathCmdNMap gives the number of points per each command
var PathCmdToRune = map[PathCmds]rune{}
PathCmdToRune maps command to rune
var PathRuneToCmd = map[rune]PathCmds{ 'M': PcM, 'm': Pcm, 'L': PcL, 'l': Pcl, 'H': PcH, 'h': Pch, 'V': PcV, 'v': Pcv, 'C': PcC, 'c': Pcc, 'S': PcS, 's': Pcs, 'Q': PcQ, 'q': Pcq, 'T': PcT, 't': Pct, 'A': PcA, 'a': Pca, 'Z': PcZ, 'z': Pcz, }
PathRuneToCmd maps rune to path command
var PathType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Path", ShortName: "svg.Path", IDName: "path", Doc: "Path renders SVG data sequences that can render just about anything", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Data", >i.Field{Name: "Data", Type: "[]goki.dev/svg.PathData", LocalType: "[]PathData", Doc: "the path data to render -- path commands and numbers are serialized, with each command specifying the number of floating-point coord data points that follow", Directives: gti.Directives{}, Tag: "xml:\"-\" set:\"-\""}}, {"DataStr", >i.Field{Name: "DataStr", Type: "string", LocalType: "string", Doc: "string version of the path data", Directives: gti.Directives{}, Tag: "xml:\"d\""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Path{}, })
PathType is the gti.Type for Path
var PolygonType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Polygon", ShortName: "svg.Polygon", IDName: "polygon", Doc: "Polygon is a SVG polygon", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Polyline", >i.Field{Name: "Polyline", Type: "goki.dev/svg.Polyline", LocalType: "Polyline", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Polygon{}, })
PolygonType is the gti.Type for Polygon
var PolylineType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Polyline", ShortName: "svg.Polyline", IDName: "polyline", Doc: "Polyline is a SVG multi-line shape", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Points", >i.Field{Name: "Points", Type: "[]goki.dev/mat32/v2.Vec2", LocalType: "[]mat32.Vec2", Doc: "the coordinates to draw -- does a moveto on the first, then lineto for all the rest", Directives: gti.Directives{}, Tag: "xml:\"points\""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Polyline{}, })
PolylineType is the gti.Type for Polyline
var RectType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Rect", ShortName: "svg.Rect", IDName: "rect", Doc: "Rect is a SVG rectangle, optionally with rounded corners", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Pos", >i.Field{Name: "Pos", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "position of the top-left of the rectangle", Directives: gti.Directives{}, Tag: "xml:\"{x,y}\""}}, {"Size", >i.Field{Name: "Size", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "size of the rectangle", Directives: gti.Directives{}, Tag: "xml:\"{width,height}\""}}, {"Radius", >i.Field{Name: "Radius", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "radii for curved corners, as a proportion of width, height", Directives: gti.Directives{}, Tag: "xml:\"{rx,ry}\""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Rect{}, })
RectType is the gti.Type for Rect
var SVGNodeType = gti.AddType(>i.Type{ Name: "goki.dev/svg.SVGNode", ShortName: "svg.SVGNode", IDName: "svg-node", Doc: "SVGNode represents the root of an SVG tree", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"ViewBox", >i.Field{Name: "ViewBox", Type: "goki.dev/svg.ViewBox", LocalType: "ViewBox", Doc: "viewbox defines the coordinate system for the drawing -- these units are mapped into the screen space allocated for the SVG during rendering", Directives: gti.Directives{}, Tag: ""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Group", >i.Field{Name: "Group", Type: "goki.dev/svg.Group", LocalType: "Group", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &SVGNode{}, })
SVGNodeType is the gti.Type for SVGNode
var StyleSheetType = gti.AddType(>i.Type{ Name: "goki.dev/svg.StyleSheet", ShortName: "svg.StyleSheet", IDName: "style-sheet", Doc: "StyleSheet is a Node2D node that contains a stylesheet -- property values\ncontained in this sheet can be transformed into ki.Props and set in CSS\nfield of appropriate node", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Sheet", >i.Field{Name: "Sheet", Type: "*github.com/aymerick/douceur/css.Stylesheet", LocalType: "*css.Stylesheet", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &StyleSheet{}, })
StyleSheetType is the gti.Type for StyleSheet
var TextType = gti.AddType(>i.Type{ Name: "goki.dev/svg.Text", ShortName: "svg.Text", IDName: "text", Doc: "Text renders SVG text, handling both text and tspan elements.\ntspan is nested under a parent text -- text has empty Text string.", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Pos", >i.Field{Name: "Pos", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "position of the left, baseline of the text", Directives: gti.Directives{}, Tag: "xml:\"{x,y}\" set:\"-\""}}, {"Width", >i.Field{Name: "Width", Type: "float32", LocalType: "float32", Doc: "width of text to render if using word-wrapping", Directives: gti.Directives{}, Tag: "xml:\"width\""}}, {"Text", >i.Field{Name: "Text", Type: "string", LocalType: "string", Doc: "text string to render", Directives: gti.Directives{}, Tag: "xml:\"text\""}}, {"TextRender", >i.Field{Name: "TextRender", Type: "goki.dev/girl/paint.Text", LocalType: "paint.Text", Doc: "render version of text", Directives: gti.Directives{}, Tag: "xml:\"-\" json:\"-\""}}, {"CharPosX", >i.Field{Name: "CharPosX", Type: "[]float32", LocalType: "[]float32", Doc: "character positions along X axis, if specified", Directives: gti.Directives{}, Tag: ""}}, {"CharPosY", >i.Field{Name: "CharPosY", Type: "[]float32", LocalType: "[]float32", Doc: "character positions along Y axis, if specified", Directives: gti.Directives{}, Tag: ""}}, {"CharPosDX", >i.Field{Name: "CharPosDX", Type: "[]float32", LocalType: "[]float32", Doc: "character delta-positions along X axis, if specified", Directives: gti.Directives{}, Tag: ""}}, {"CharPosDY", >i.Field{Name: "CharPosDY", Type: "[]float32", LocalType: "[]float32", Doc: "character delta-positions along Y axis, if specified", Directives: gti.Directives{}, Tag: ""}}, {"CharRots", >i.Field{Name: "CharRots", Type: "[]float32", LocalType: "[]float32", Doc: "character rotations, if specified", Directives: gti.Directives{}, Tag: ""}}, {"TextLength", >i.Field{Name: "TextLength", Type: "float32", LocalType: "float32", Doc: "author's computed text length, if specified -- we attempt to match", Directives: gti.Directives{}, Tag: ""}}, {"AdjustGlyphs", >i.Field{Name: "AdjustGlyphs", Type: "bool", LocalType: "bool", Doc: "in attempting to match TextLength, should we adjust glyphs in addition to spacing?", Directives: gti.Directives{}, Tag: ""}}, {"LastPos", >i.Field{Name: "LastPos", Type: "goki.dev/mat32/v2.Vec2", LocalType: "mat32.Vec2", Doc: "last text render position -- lower-left baseline of start", Directives: gti.Directives{}, Tag: "xml:\"-\" json:\"-\""}}, {"LastBBox", >i.Field{Name: "LastBBox", Type: "goki.dev/mat32/v2.Box2", LocalType: "mat32.Box2", Doc: "last actual bounding box in display units (dots)", Directives: gti.Directives{}, Tag: "xml:\"-\" json:\"-\""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"NodeBase", >i.Field{Name: "NodeBase", Type: "goki.dev/svg.NodeBase", LocalType: "NodeBase", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}), Instance: &Text{}, })
Functions ¶
func BBoxFromChildren ¶
BBoxFromChildren sets the Group BBox from children
func EscapeText ¶
XMLEscapeText writes to w the properly escaped XML equivalent of the plain text data s. If escapeNewline is true, newline XMLcharacters will be escaped.
func GradientReadPts ¶
GradientReadPoints reads the gradient points from a slice of floating point numbers, reading from the end.
func GradientWritePts ¶
GradientWritePoints writes the gradient points to a slice of floating point numbers, appending to end of slice.
func IncRefCount ¶
func IncRefCount(k ki.Ki)
func NameFromURL ¶
NameFromURL returns just the name referred to in a url(#name) if it is not a url(#) format then returns empty string.
func NodePropURL ¶
NodePropURL returns a url(#name) url from given prop name on node, or empty string if none. Returned value is just the 'name' part of the url, not the full string.
func PathCmdIsRel ¶
PathCmdIsRel returns true if the path command is relative, false for absolute
func PathDataBBox ¶
func PathDataBBox(data []PathData) mat32.Box2
PathDataBBox traverses the path data and extracts the local bounding box
func PathDataEnd ¶
PathDataEnd gets the ending coords and angle from the path
func PathDataIterFunc ¶
func PathDataIterFunc(data []PathData, fun func(idx int, cmd PathCmds, ptIdx int, cp mat32.Vec2, ctrls []mat32.Vec2) bool)
PathDataIterFunc traverses the path data and calls given function on each coordinate point, passing overall starting index of coords in data stream, command, index of the points within that command, and coord values (absolute, not relative, regardless of the command type), including special control points for path commands that have them (else nil). If function returns false (use ki.Break vs. ki.Continue) then traversal is aborted. For Control points, order is in same order as in standard path stream when multiple, e.g., C,S. For A: order is: nc, prv, rad, mat32.Vec2{X: ang}, mat32.V2(laf, sf)}
func PathDataNext ¶
PathDataNext gets the next path data point, incrementing the index
func PathDataNextRel ¶
PathDataNextRel gets the next 2 path data points as a relative vector and returns that relative vector added to current point
func PathDataNextVec ¶
PathDataNextVec gets the next 2 path data points as a vector
func PathDataRender ¶
PathDataRender traverses the path data and renders it using paint. We assume all the data has been validated and that n's are sufficient, etc
func PathDataStart ¶
PathDataStart gets the starting coords and angle from the path
func PathDataString ¶
PathDataString returns the string representation of the path data
func PathDataTransformAbs ¶ added in v0.1.18
PathDataTransformAbs does the transform of next two data points as absolute coords
func PathDataTransformRel ¶ added in v0.1.18
PathDataTransformRel does the transform of next two data points as relative coords compared to given cp coordinate. returns new *absolute* coordinate
func PathDataValidate ¶
PathDataValidate validates the path data and emits error messages on log
func SVGNodeMarshalXML ¶
func SVGNodeMarshalXML(itm ki.Ki, enc *XMLEncoder, setName string) string
SVGNodeMarshalXML encodes just the given node under SVG to XML. returns name of node, for end tag -- if empty, then children will not be output.
func SVGNodeTreeMarshalXML ¶
func SVGNodeTreeMarshalXML(itm Node, enc *XMLEncoder, setName string) (string, error)
SVGNodeTreeMarshalXML encodes item and any children to XML. returns any error, and name of element that enc.WriteEnd() should be called with -- allows for extra elements to be added at end of list.
func SVGNodeXMLGrad ¶
func SVGNodeXMLGrad(nd *Gradient, name string, enc *XMLEncoder)
SVGNodeXMLGrad adds the XML for the given gradient to the given encoder. This is not in goki.dev/colors/gradient because it uses a lot of SVG and XML infrastructure defined here.
func SVGWalkPre ¶ added in v0.1.26
SVGWalkPre does ki WalkPre on given node using given walk function with SVG Node parameters. Automatically filters nil or deleted items. Return ki.Continue (true) to continue, and ki.Break (false) to terminate.
func SetFloat32SliceLen ¶
SetFloat32SliceLen is a utility function to set given slice of float32 values to given length, reusing existing where possible and making a new one as needed. For use in WriteGeom routines.
func SetStdXMLAttr ¶
SetStdXMLAttr sets standard attributes of node given XML-style name / attribute values (e.g., from parsing XML / SVG files) -- returns true if handled
func SplitNameId ¶
SplitNameId splits name after the element name (e.g., 'rect') returning true if it starts with element name, and numerical id part after that element. if numerical id part is 0, then it didn't parse. SVG object names are element names + numerical id
func SplitNameIdDig ¶
SplitNameIdDig splits name into numerical end part and preceding name, based on string of digits from end of name. If Id == 0 then it was not specified or didn't parse. SVG object names are element names + numerical id
func XMLAddAttr ¶
Types ¶
type Circle ¶
type Circle struct { NodeBase // position of the center of the circle Pos mat32.Vec2 `xml:"{cx,cy}" set:"-"` // radius of the circle Radius float32 `xml:"r"` }
Circle is a SVG circle
func NewCircle ¶
NewCircle adds a new Circle with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Circle) ApplyDeltaTransform ¶ added in v0.1.18
func (g *Circle) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*Circle) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node each node must define this for itself
func (*Circle) CopyFieldsFrom ¶
func (*Circle) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
type ClipPath ¶
type ClipPath struct {
NodeBase
}
ClipPath is used for holding a path that renders as a clip path
func NewClipPath ¶
NewClipPath adds a new ClipPath with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*ClipPath) CopyFieldsFrom ¶
type Ellipse ¶
type Ellipse struct { NodeBase // position of the center of the ellipse Pos mat32.Vec2 `xml:"{cx,cy}" set:"-"` // radii of the ellipse in the horizontal, vertical axes Radii mat32.Vec2 `xml:"{rx,ry}"` }
Ellipse is a SVG ellipse
func NewEllipse ¶
NewEllipse adds a new Ellipse with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Ellipse) ApplyDeltaTransform ¶ added in v0.1.18
func (g *Ellipse) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*Ellipse) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node each node must define this for itself
func (*Ellipse) CopyFieldsFrom ¶
func (*Ellipse) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
type Filter ¶
Filter represents SVG filter* elements
func NewFilter ¶
NewFilter adds a new Filter with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Filter) CopyFieldsFrom ¶
func (*Filter) SetFilterType ¶ added in v0.1.18
SetFilterType sets the [Filter.FilterType]
type Flow ¶
Flow represents SVG flow* elements
func NewFlow ¶
NewFlow adds a new Flow with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Flow) CopyFieldsFrom ¶
func (*Flow) SetFlowType ¶ added in v0.1.18
SetFlowType sets the [Flow.FlowType]
type Gradient ¶
type Gradient struct { NodeBase // the color gradient Grad gradient.Gradient // name of another gradient to get stops from StopsName string }
Gradient is used for holding a specified color gradient. The name is the id for lookup in url
func NewGradient ¶
NewGradient adds a new Gradient with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Gradient) CopyFieldsFrom ¶
func (*Gradient) GradientTypeName ¶
GradientTypeName returns the SVG-style type name of gradient: linearGradient or radialGradient
func (*Gradient) SetStopsName ¶ added in v0.1.18
SetStopsName sets the [Gradient.StopsName]: name of another gradient to get stops from
type Group ¶
type Group struct {
NodeBase
}
Group groups together SVG elements. Provides a common transform for all group elements and shared style properties.
func NewGroup ¶
NewGroup adds a new Group with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Group) ApplyDeltaTransform ¶ added in v0.1.18
func (g *Group) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*Group) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node each node must define this for itself
func (*Group) CopyFieldsFrom ¶ added in v0.1.26
func (*Group) EnforceSVGName ¶
func (*Group) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
type Image ¶
type Image struct { NodeBase // position of the top-left of the image Pos mat32.Vec2 `xml:"{x,y}"` // rendered size of the image (imposes a scaling on image when it is rendered) Size mat32.Vec2 `xml:"{width,height}"` // directs resize operations to preserve aspect ratio PreserveAspectRatio bool `xml:"preserveAspectRatio"` // file name of image loaded -- set by OpenImage Filename string // the image pixels Pixels *image.RGBA `copy:"-" xml:"-" json:"-" view:"-"` }
Image is an SVG image (bitmap)
func NewImage ¶
NewImage adds a new Image with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Image) ApplyDeltaTransform ¶ added in v0.1.18
func (g *Image) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*Image) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node each node must define this for itself
func (*Image) CopyFieldsFrom ¶
func (*Image) OpenImage ¶
OpenImage opens an image for the bitmap, and resizes to the size of the image or the specified size -- pass 0 for width and/or height to use the actual image size for that dimension
func (*Image) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
func (*Image) SetFilename ¶ added in v0.1.18
SetFilename sets the [Image.Filename]: file name of image loaded -- set by OpenImage
func (*Image) SetImage ¶
SetImage sets an image for the bitmap, and resizes to the size of the image or the specified size -- pass 0 for width and/or height to use the actual image size for that dimension. Copies from given image into internal image for this bitmap.
func (*Image) SetImageSize ¶
SetImageSize sets size of the bitmap image. This does not resize any existing image, just makes a new image if the size is different
func (*Image) SetPreserveAspectRatio ¶ added in v0.1.18
SetPreserveAspectRatio sets the [Image.PreserveAspectRatio]: directs resize operations to preserve aspect ratio
type Line ¶
type Line struct { NodeBase // position of the start of the line Start mat32.Vec2 `xml:"{x1,y1}"` // position of the end of the line End mat32.Vec2 `xml:"{x2,y2}"` }
Line is a SVG line
func NewLine ¶
NewLine adds a new Line with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Line) ApplyDeltaTransform ¶ added in v0.1.18
func (g *Line) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*Line) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node each node must define this for itself
func (*Line) CopyFieldsFrom ¶
func (*Line) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
type Marker ¶
type Marker struct { NodeBase // reference position to align the vertex position with, specified in ViewBox coordinates RefPos mat32.Vec2 `xml:"{refX,refY}"` // size of marker to render, in Units units Size mat32.Vec2 `xml:"{markerWidth,markerHeight}"` // units to use Units MarkerUnits `xml:"markerUnits"` // viewbox defines the internal coordinate system for the drawing elements within the marker ViewBox ViewBox // orientation of the marker -- either 'auto' or an angle Orient string `xml:"orient"` // current vertex position VertexPos mat32.Vec2 // current vertex angle in radians VertexAngle float32 // current stroke width StrokeWidth float32 // net transform computed from settings and current values -- applied prior to rendering Transform mat32.Mat2 // effective size for actual rendering EffSize mat32.Vec2 }
Marker represents marker elements that can be drawn along paths (arrow heads, etc)
func NewMarker ¶
NewMarker adds a new Marker with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Marker) CopyFieldsFrom ¶
func (*Marker) EnforceSVGName ¶
func (*Marker) RenderMarker ¶
RenderMarker renders the marker using given vertex position, angle (in radians), and stroke width
func (*Marker) SetEffSize ¶ added in v0.1.18
SetEffSize sets the [Marker.EffSize]: effective size for actual rendering
func (*Marker) SetOrient ¶ added in v0.1.18
SetOrient sets the [Marker.Orient]: orientation of the marker -- either 'auto' or an angle
func (*Marker) SetRefPos ¶ added in v0.1.18
SetRefPos sets the [Marker.RefPos]: reference position to align the vertex position with, specified in ViewBox coordinates
func (*Marker) SetSize ¶ added in v0.1.18
SetSize sets the [Marker.Size]: size of marker to render, in Units units
func (*Marker) SetStrokeWidth ¶ added in v0.1.18
SetStrokeWidth sets the [Marker.StrokeWidth]: current stroke width
func (*Marker) SetTransform ¶ added in v0.1.18
SetTransform sets the [Marker.Transform]: net transform computed from settings and current values -- applied prior to rendering
func (*Marker) SetUnits ¶ added in v0.1.18
func (t *Marker) SetUnits(v MarkerUnits) *Marker
SetUnits sets the [Marker.Units]: units to use
func (*Marker) SetVertexAngle ¶ added in v0.1.18
SetVertexAngle sets the [Marker.VertexAngle]: current vertex angle in radians
func (*Marker) SetVertexPos ¶ added in v0.1.18
SetVertexPos sets the [Marker.VertexPos]: current vertex position
func (*Marker) SetViewBox ¶ added in v0.1.18
SetViewBox sets the [Marker.ViewBox]: viewbox defines the internal coordinate system for the drawing elements within the marker
type MarkerUnits ¶
type MarkerUnits int32 //enum: enum
MarkerUnits specifies units to use for svg marker elements
const ( StrokeWidth MarkerUnits = iota UserSpaceOnUse MarkerUnitsN )
type MetaData ¶
MetaData is used for holding meta data info
func NewMetaData ¶
NewMetaData adds a new MetaData with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*MetaData) CopyFieldsFrom ¶
func (*MetaData) SetMetaData ¶ added in v0.1.18
SetMetaData sets the [MetaData.MetaData]
type Node ¶
type Node interface { ki.Ki // AsNodeBase returns a generic svg.NodeBase for our node -- gives generic // access to all the base-level data structures without requiring // interface methods. AsNodeBase() *NodeBase // PaintStyle returns the SVG Paint style object for this node PaintStyle() *styles.Paint // Style updates the Paint style for this node Style(sv *SVG) // Render draws the node to the svg image Render(sv *SVG) // BBoxes computes BBox and VisBBox during Render BBoxes(sv *SVG) // LocalBBox returns the bounding box of node in local dimensions LocalBBox() mat32.Box2 // NodeBBox returns the bounding box in image coordinates for this node NodeBBox(sv *SVG) image.Rectangle // ApplyTransform applies the given 2D transform to the geometry of this node // this just does a direct transform multiplication on coordinates. ApplyTransform(sv *SVG, xf mat32.Mat2) // ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node // relative to given point. Trans translation and point are in top-level coordinates, // so must be transformed into local coords first. // Point is upper left corner of selection box that anchors the translation and scaling, // and for rotation it is the center point around which to rotate ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2) // WriteGeom writes the geometry of the node to a slice of floating point numbers // the length and ordering of which is specific to each node type. // Slice must be passed and will be resized if not the correct length. WriteGeom(sv *SVG, dat *[]float32) // ReadGeom reads the geometry of the node from a slice of floating point numbers // the length and ordering of which is specific to each node type. ReadGeom(sv *SVG, dat []float32) // SVGName returns the SVG element name (e.g., "rect", "path" etc) SVGName() string // EnforceSVGName returns true if in general this element should // be named with its SVGName plus a unique id. // Groups and Markers are false. EnforceSVGName() bool }
Node is the interface for all SVG nodes
func FirstNonGroupNode ¶
FirstNonGroupNode returns the first item that is not a group recursing into groups until a non-group item is found.
type NodeBase ¶
type NodeBase struct { ki.Node // user-defined class name(s) used primarily for attaching CSS styles to different display elements -- multiple class names can be used to combine properties: use spaces to separate per css standard Class string // cascading style sheet at this level -- these styles apply here and to everything below, until superceded -- use .class and #name Props elements to apply entire styles to given elements, and type for element type CSS ki.Props `xml:"css" set:"-"` // aggregated css properties from all higher nodes down to me CSSAgg ki.Props `copy:"-" json:"-" xml:"-" set:"-" view:"no-inline"` // bounding box for the node within the SVG Pixels image -- this one can be outside the visible range of the SVG image -- VpBBox is intersected and only shows visible portion. BBox image.Rectangle `copy:"-" json:"-" xml:"-" set:"-"` // visible bounding box for the node intersected with the SVG image geometry VisBBox image.Rectangle `copy:"-" json:"-" xml:"-" set:"-"` // paint style information for this node Paint styles.Paint `json:"-" xml:"-" set:"-"` }
svg.NodeBase is the base type for elements within the SVG scenegraph
func NewNodeBase ¶
NewNodeBase adds a new NodeBase with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*NodeBase) ApplyCSS ¶
ApplyCSS applies css styles to given node, using key to select sub-props from overall properties list
func (*NodeBase) ApplyDeltaTransform ¶ added in v0.1.18
func (g *NodeBase) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*NodeBase) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node this just does a direct transform multiplication on coordinates.
func (*NodeBase) AsNodeBase ¶
func (*NodeBase) BBoxes ¶
ComputeBBox is called by default in render to compute bounding boxes for gui interaction -- can only be done in rendering because that is when all the proper transforms are all in place -- VpBBox is intersected with parent SVG
func (*NodeBase) CopyFieldsFrom ¶
func (*NodeBase) DeltaTransform ¶ added in v0.1.18
func (g *NodeBase) DeltaTransform(trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2, self bool) (mat32.Mat2, mat32.Vec2)
DeltaTransform computes the net transform matrix for given delta transform parameters and the transformed version of the reference point. If self is true, then include the current node self transform, otherwise don't. Groups do not but regular rendering nodes do.
func (*NodeBase) EnforceSVGName ¶
func (*NodeBase) GradientApplyTransform ¶ added in v0.1.18
GradientApplyTransform applies the given transform to any gradients for this node, that are using specific coordinates (not bounding box which is automatic)
func (*NodeBase) GradientApplyTransformPt ¶ added in v0.1.18
GradientApplyTransformPt applies the given transform with ctr point to any gradients for this node, that are using specific coordinates (not bounding box which is automatic)
func (*NodeBase) GradientReadPts ¶
GradientReadPts reads the geometry of the gradients for this node from a slice of floating point numbers, reading from the end.
func (*NodeBase) GradientWritePts ¶
GradientWritePts writes the geometry of the gradients for this node to a slice of floating point numbers, appending to end of slice.
func (*NodeBase) LocalBBoxToWin ¶
LocalBBoxToWin converts a local bounding box to SVG coordinates
func (*NodeBase) LocalLineWidth ¶
LocalLineWidth returns the line width in local coordinates
func (*NodeBase) PaintStyle ¶
func (*NodeBase) ParTransform ¶ added in v0.1.18
ParTransform returns the full compounded 2D transform matrix for all of the parents of this node. If self is true, then include our own transform too.
func (*NodeBase) PushTransform ¶ added in v0.1.18
PushTransform checks our bounding box and visibility, returning false if out of bounds. If visible, pushes our transform. Must be called as first step in Render.
func (*NodeBase) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
func (*NodeBase) ReadTransform ¶ added in v0.1.18
ReadTransform reads the node transform from slice at starting index.
func (*NodeBase) RenderChildren ¶
func (*NodeBase) SetClass ¶ added in v0.1.18
SetClass sets the [NodeBase.Class]: user-defined class name(s) used primarily for attaching CSS styles to different display elements -- multiple class names can be used to combine properties: use spaces to separate per css standard
func (*NodeBase) SetColorProps ¶
SetColorProps sets color property from a string representation. It breaks color alpha out as opacity. prop is either "stroke" or "fill"
func (*NodeBase) StyleCSS ¶
StyleCSS applies css style properties to given SVG node parsing out type, .class, and #name selectors
func (*NodeBase) WriteGeom ¶
WriteGeom writes the geometry of the node to a slice of floating point numbers the length and ordering of which is specific to each node type. Slice must be passed and will be resized if not the correct length.
func (*NodeBase) WriteTransform ¶ added in v0.1.18
WriteTransform writes the node transform to slice at starting index. slice must already be allocated sufficiently.
type NodeFlags ¶
type NodeFlags ki.Flags //enums:bitflag
NodeFlags extend ki.Flags to hold SVG node state
const NodeFlagsN NodeFlags = 8
NodeFlagsN is the highest valid value for type NodeFlags, plus one.
func NodeFlagsValues ¶
func NodeFlagsValues() []NodeFlags
NodeFlagsValues returns all possible values for the type NodeFlags.
func (NodeFlags) BitIndexString ¶
BitIndexString returns the string representation of this NodeFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (NodeFlags) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*NodeFlags) SetFlag ¶
SetFlag sets the value of the given flags in these flags to the given value.
func (*NodeFlags) SetString ¶
SetString sets the NodeFlags value from its string representation, and returns an error if the string is invalid.
func (*NodeFlags) SetStringOr ¶
SetStringOr sets the NodeFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (*NodeFlags) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Path ¶
type Path struct { NodeBase // the path data to render -- path commands and numbers are serialized, with each command specifying the number of floating-point coord data points that follow Data []PathData `xml:"-" set:"-"` // string version of the path data DataStr string `xml:"d"` }
Path renders SVG data sequences that can render just about anything
func NewPath ¶
NewPath adds a new Path with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Path) ApplyDeltaTransform ¶ added in v0.1.18
func (g *Path) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*Path) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node each node must define this for itself
func (*Path) ApplyTransformImpl ¶ added in v0.1.18
func (g *Path) ApplyTransformImpl(xf mat32.Mat2, lpt mat32.Vec2)
ApplyTransformImpl does the implementation of applying a transform to all points
func (*Path) CopyFieldsFrom ¶
func (*Path) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
func (*Path) SetData ¶
SetData sets the path data to given string, parsing it into an optimized form used for rendering
func (*Path) SetDataStr ¶ added in v0.1.18
SetDataStr sets the [Path.DataStr]: string version of the path data
type PathCmds ¶
type PathCmds byte //enum: enum
PathCmds are the commands within the path SVG drawing data type
const ( // move pen, abs coords PcM PathCmds = iota // move pen, rel coords Pcm // lineto, abs PcL // lineto, rel Pcl // horizontal lineto, abs PcH // relative lineto, rel Pch // vertical lineto, abs PcV // vertical lineto, rel Pcv // Bezier curveto, abs PcC // Bezier curveto, rel Pcc // smooth Bezier curveto, abs PcS // smooth Bezier curveto, rel Pcs // quadratic Bezier curveto, abs PcQ // quadratic Bezier curveto, rel Pcq // smooth quadratic Bezier curveto, abs PcT // smooth quadratic Bezier curveto, rel Pct // elliptical arc, abs PcA // elliptical arc, rel Pca // close path PcZ // close path Pcz // error -- invalid command PcErr )
func PathDataNextCmd ¶
PathDataNextCmd gets the next path data command, incrementing the index -- ++ not an expression so its clunky
func PathDecodeCmd ¶
PathDecodeCmd decodes rune into corresponding command
type PathData ¶
type PathData float32
PathData encodes the svg path data, using 32-bit floats which are converted into uint32 for path commands, and contain the command as the first 5 bits, and the remaining 27 bits are the number of data points following the path command to interpret as numbers.
func PathDataParse ¶
PathDataParse parses a string representation of the path data into compiled path data
type Polygon ¶
type Polygon struct {
Polyline
}
Polygon is a SVG polygon
func NewPolygon ¶
NewPolygon adds a new Polygon with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
type Polyline ¶
type Polyline struct { NodeBase // the coordinates to draw -- does a moveto on the first, then lineto for all the rest Points []mat32.Vec2 `xml:"points"` }
Polyline is a SVG multi-line shape
func NewPolyline ¶
NewPolyline adds a new Polyline with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Polyline) ApplyDeltaTransform ¶ added in v0.1.18
func (g *Polyline) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*Polyline) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node each node must define this for itself
func (*Polyline) CopyFieldsFrom ¶
func (*Polyline) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
type Rect ¶
type Rect struct { NodeBase // position of the top-left of the rectangle Pos mat32.Vec2 `xml:"{x,y}"` // size of the rectangle Size mat32.Vec2 `xml:"{width,height}"` // radii for curved corners, as a proportion of width, height Radius mat32.Vec2 `xml:"{rx,ry}"` }
Rect is a SVG rectangle, optionally with rounded corners
func NewRect ¶
NewRect adds a new Rect with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Rect) ApplyDeltaTransform ¶ added in v0.1.18
func (g *Rect) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*Rect) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node each node must define this for itself
func (*Rect) CopyFieldsFrom ¶
func (*Rect) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
func (*Rect) SetRadius ¶ added in v0.1.18
SetRadius sets the [Rect.Radius]: radii for curved corners, as a proportion of width, height
type SVG ¶
type SVG struct { // Name is the name of the SVG -- e.g., the filename if loaded Name string // the title of the svg Title string `xml:"title"` // the description of the svg Desc string `xml:"desc"` // fill the viewport with Background Fill bool // image/color to fill background with if Fill is on Background image.Image // Color can be set to provide a default Fill and Stroke Color value Color image.Image // Size is size of image, Pos is offset within any parent viewport. // Node bounding boxes are based on 0 Pos offset within Pixels image Geom mat32.Geom2DInt // physical width of the drawing, e.g., when printed -- does not affect rendering -- metadata PhysWidth units.Value // physical height of the drawing, e.g., when printed -- does not affect rendering -- metadata PhysHeight units.Value // Norm installs a transform that renormalizes so that the specified // ViewBox exactly fits within the allocated SVG size. Norm bool // InvertY, when doing Norm transform, also flip the Y axis so that // the smallest Y value is at the bottom of the SVG box, // instead of being at the top as it is by default. InvertY bool // Translate specifies a translation to apply beyond what is specified in the SVG, // and in addition to the effects of Norm if active. Translate mat32.Vec2 // Scale specifies a zoom scale factor to apply beyond what is specified in the SVG, // and in addition to the effects of Norm if active. Scale float32 // render state for rendering RenderState paint.State `copy:"-" json:"-" xml:"-" edit:"-"` // live pixels that we render into Pixels *image.RGBA `copy:"-" json:"-" xml:"-" edit:"-"` // all defs defined elements go here (gradients, symbols, etc) Defs Group // root of the svg tree -- top-level viewbox and paint style here Root SVGNode // map of def names to index -- uses starting index to find element -- always updated after each search DefIdxs map[string]int `view:"-" json:"-" xml:"-"` // map of unique numeric ids for all elements -- used for allocating new unique id numbers, appended to end of elements -- see NewUniqueId, GatherIds UniqueIds map[int]struct{} `view:"-" json:"-" xml:"-"` // mutex for protecting rendering RenderMu sync.Mutex `view:"-" json:"-" xml:"-"` }
SVG is an SVG object.
func (*SVG) Base ¶ added in v0.1.6
Base returns the current Color activated in the context. Color has support for special color names that are relative to this current color.
func (*SVG) Config ¶
Config configures the SVG, setting image to given size and initializing all relevant fields.
func (*SVG) DeleteAll ¶
func (sv *SVG) DeleteAll()
DeleteAll deletes any existing elements in this svg
func (*SVG) FillViewport ¶
func (sv *SVG) FillViewport()
func (*SVG) FindDefByName ¶
FindDefByName finds Defs item by name, using cached indexes for speed
func (*SVG) FindNamedElement ¶
func (*SVG) GatherIds ¶
func (sv *SVG) GatherIds()
GatherIds gathers all the numeric id suffixes currently in use. It automatically renames any that are not unique or empty.
func (*SVG) GradientByName ¶
GradientByName returns the gradient of given name, stored on SVG node
func (*SVG) GradientCloneNodeProp ¶
GradientCloneNodeProp creates a new clone of the existing gradient for node if set for given property key ("fill" or "stroke"). returns new gradient.
func (*SVG) GradientDeleteForNode ¶
GradientDeleteForNode deletes the node-specific gradient on given node of given name, which can be a full url(# name or just the bare name. Returns true if deleted.
func (*SVG) GradientDeleteNodeProp ¶
GradientDeleteNodeProp deletes any existing gradient for node if set for given property key ("fill" or "stroke"). Returns true if deleted.
func (*SVG) GradientNew ¶
GradientNew adds a new gradient, either linear or radial, with a new unique id
func (*SVG) GradientNewForNode ¶
GradientNewForNode adds a new gradient specific to given node that points to given stops name. returns the new gradient and the url that points to it (nil if parent svg cannot be found). Initializes gradient to use bounding box of object, but using userSpaceOnUse setting
func (*SVG) GradientUpdateAllStops ¶
func (sv *SVG) GradientUpdateAllStops()
GradientUpdateAllStops removes any items from Defs that are not actually referred to by anything in the current SVG tree. Returns true if items were removed. Does not remove gradients with StopsName = "" with extant stops -- these should be removed manually, as they are not automatically generated.
func (*SVG) GradientUpdateNodePoints ¶
GradientUpdateNodePoints updates the points for node based on current bbox
func (*SVG) GradientUpdateNodeProp ¶
func (sv *SVG) GradientUpdateNodeProp(n Node, prop string, radial bool, stops string) (*Gradient, string)
GradientUpdateNodeProp ensures that node has a gradient property of given type
func (*SVG) GradientUpdateStops ¶
GradientUpdateStops copies stops from StopsName gradient if it is set
func (*SVG) ImageByURL ¶ added in v0.1.26
ImageByURL finds a Node by an element name (URL-like path), and attempts to convert it to an image.Image. Used for color styling based on url() value.
func (*SVG) MarkerByName ¶
MarkerByName finds marker property of given name, or generic "marker" type, and if set, attempts to find that marker and return it
func (*SVG) MarshalXMLx ¶
func (sv *SVG) MarshalXMLx(enc *XMLEncoder, se xml.StartElement) error
MarshalXMLx marshals the svg using XMLEncoder
func (*SVG) NewUniqueId ¶
NewUniqueId returns a new unique numerical id number, for naming an object
func (*SVG) NodeEnsureUniqueId ¶
NodeEnsureUniqueId ensures that the given node has a unique Id Call this on any newly-created nodes.
func (*SVG) NodeFindURL ¶
NodeFindURL finds a url element in the parent SVG of given node. Returns nil if not found. Works with full 'url(#Name)' string or plain name or "none"
func (*SVG) OpenFS ¶ added in v0.1.6
OpenFS Opens XML-formatted SVG input from given file, filesystem FS
func (*SVG) ReadXML ¶
ReadXML reads XML-formatted SVG input from io.Reader, and uses xml.Decoder to create the SVG scenegraph for corresponding SVG drawing. Removes any existing content in SVG first. To process a byte slice, pass: bytes.NewReader([]byte(str)) -- all errors are logged and also returned.
func (*SVG) RemoveOrphanedDefs ¶
RemoveOrphanedDefs removes any items from Defs that are not actually referred to by anything in the current SVG tree. Returns true if items were removed. Does not remove gradients with StopsName = "" with extant stops -- these should be removed manually, as they are not automatically generated.
func (*SVG) SetDPITransform ¶ added in v0.1.18
SetDPITransform sets a scaling transform to compensate for a given LogicalDPI factor. svg rendering is done within a 96 DPI context.
func (*SVG) SetRootTransform ¶ added in v0.1.26
func (sv *SVG) SetRootTransform()
SetRootTransform sets the Root node transform based on Norm, Translate, Scale parameters set on the SVG object.
func (*SVG) SetUnitContext ¶
SetUnitContext sets the unit context based on size of viewport, element, and parent element (from bbox) and then caches everything out in terms of raw pixel dots for rendering -- call at start of render
func (*SVG) UnmarshalXML ¶
UnmarshalXML unmarshals the svg using xml.Decoder
type SVGNode ¶
type SVGNode struct { Group // viewbox defines the coordinate system for the drawing -- these units are mapped into the screen space allocated for the SVG during rendering ViewBox ViewBox }
SVGNode represents the root of an SVG tree
func NewSVGNode ¶
NewSVGNode adds a new SVGNode with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*SVGNode) CopyFieldsFrom ¶
func (*SVGNode) EnforceSVGName ¶
func (*SVGNode) SetViewBox ¶ added in v0.1.18
SetViewBox sets the [SVGNode.ViewBox]: viewbox defines the coordinate system for the drawing -- these units are mapped into the screen space allocated for the SVG during rendering
type StyleSheet ¶
type StyleSheet struct { NodeBase Sheet *css.Stylesheet }
StyleSheet is a Node2D node that contains a stylesheet -- property values contained in this sheet can be transformed into ki.Props and set in CSS field of appropriate node
func AddNewStyleSheet ¶
func AddNewStyleSheet(parent ki.Ki, name string) *StyleSheet
AddNewStyleSheet adds a new CSS stylesheet to given parent node, with given name.
func NewStyleSheet ¶
func NewStyleSheet(par ki.Ki, name ...string) *StyleSheet
NewStyleSheet adds a new StyleSheet with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*StyleSheet) CSSProps ¶
func (ss *StyleSheet) CSSProps() ki.Props
CSSProps returns the properties for each of the rules in this style sheet, suitable for setting the CSS value of a node -- returns nil if empty sheet
func (*StyleSheet) CopyFieldsFrom ¶
func (ss *StyleSheet) CopyFieldsFrom(frm any)
func (*StyleSheet) KiType ¶ added in v0.1.2
func (t *StyleSheet) KiType() *gti.Type
KiType returns the *gti.Type of StyleSheet
func (*StyleSheet) ParseString ¶
func (ss *StyleSheet) ParseString(str string) error
ParseString parses the string into a StyleSheet of rules, which can then be used for extracting properties
func (*StyleSheet) SetClass ¶ added in v0.1.18
func (t *StyleSheet) SetClass(v string) *StyleSheet
SetClass sets the [StyleSheet.Class]
func (*StyleSheet) SetSheet ¶ added in v0.1.18
func (t *StyleSheet) SetSheet(v *css.Stylesheet) *StyleSheet
SetSheet sets the [StyleSheet.Sheet]
type Text ¶
type Text struct { NodeBase // position of the left, baseline of the text Pos mat32.Vec2 `xml:"{x,y}" set:"-"` // width of text to render if using word-wrapping Width float32 `xml:"width"` // text string to render Text string `xml:"text"` // render version of text TextRender paint.Text `xml:"-" json:"-"` // character positions along X axis, if specified CharPosX []float32 // character positions along Y axis, if specified CharPosY []float32 // character delta-positions along X axis, if specified CharPosDX []float32 // character delta-positions along Y axis, if specified CharPosDY []float32 // character rotations, if specified CharRots []float32 // author's computed text length, if specified -- we attempt to match TextLength float32 // in attempting to match TextLength, should we adjust glyphs in addition to spacing? AdjustGlyphs bool // last text render position -- lower-left baseline of start LastPos mat32.Vec2 `xml:"-" json:"-"` // last actual bounding box in display units (dots) LastBBox mat32.Box2 `xml:"-" json:"-"` }
Text renders SVG text, handling both text and tspan elements. tspan is nested under a parent text -- text has empty Text string.
func NewText ¶
NewText adds a new Text with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*Text) ApplyDeltaTransform ¶ added in v0.1.18
func (g *Text) ApplyDeltaTransform(sv *SVG, trans mat32.Vec2, scale mat32.Vec2, rot float32, pt mat32.Vec2)
ApplyDeltaTransform applies the given 2D delta transforms to the geometry of this node relative to given point. Trans translation and point are in top-level coordinates, so must be transformed into local coords first. Point is upper left corner of selection box that anchors the translation and scaling, and for rotation it is the center point around which to rotate
func (*Text) ApplyTransform ¶ added in v0.1.18
ApplyTransform applies the given 2D transform to the geometry of this node each node must define this for itself
func (*Text) CopyFieldsFrom ¶
func (*Text) IsParText ¶
IsParText returns true if this element serves as a parent text element to tspan elements within it. This is true if NumChildren() > 0 and Text == ""
func (*Text) ReadGeom ¶
ReadGeom reads the geometry of the node from a slice of floating point numbers the length and ordering of which is specific to each node type.
func (*Text) RenderText ¶
RenderText renders the text in full coords
func (*Text) SetAdjustGlyphs ¶ added in v0.1.18
SetAdjustGlyphs sets the [Text.AdjustGlyphs]: in attempting to match TextLength, should we adjust glyphs in addition to spacing?
func (*Text) SetCharPosDx ¶ added in v0.1.18
SetCharPosDx sets the [Text.CharPosDX]: character delta-positions along X axis, if specified
func (*Text) SetCharPosDy ¶ added in v0.1.18
SetCharPosDy sets the [Text.CharPosDY]: character delta-positions along Y axis, if specified
func (*Text) SetCharPosX ¶ added in v0.1.18
SetCharPosX sets the [Text.CharPosX]: character positions along X axis, if specified
func (*Text) SetCharPosY ¶ added in v0.1.18
SetCharPosY sets the [Text.CharPosY]: character positions along Y axis, if specified
func (*Text) SetCharRots ¶ added in v0.1.18
SetCharRots sets the [Text.CharRots]: character rotations, if specified
func (*Text) SetLastBbox ¶ added in v0.1.18
SetLastBbox sets the [Text.LastBBox]: last actual bounding box in display units (dots)
func (*Text) SetLastPos ¶ added in v0.1.18
SetLastPos sets the [Text.LastPos]: last text render position -- lower-left baseline of start
func (*Text) SetTextLength ¶ added in v0.1.18
SetTextLength sets the [Text.TextLength]: author's computed text length, if specified -- we attempt to match
func (*Text) SetTextRender ¶ added in v0.1.18
SetTextRender sets the [Text.TextRender]: render version of text
func (*Text) SetWidth ¶ added in v0.1.18
SetWidth sets the [Text.Width]: width of text to render if using word-wrapping
type ViewBox ¶
type ViewBox struct { // offset or starting point in parent Viewport2D Min mat32.Vec2 // size of viewbox within parent Viewport2D Size mat32.Vec2 // how to scale the view box within parent PreserveAspectRatio ViewBoxPreserveAspectRatio }
ViewBox is used in SVG to define the coordinate system
type ViewBoxAlign ¶
type ViewBoxAlign int32
ViewBoxAlign defines values for the PreserveAspectRatio alignment factor
const ( NoAlign ViewBoxAlign = 1 << iota // do not preserve uniform scaling XMin // align ViewBox.Min with smallest values of Viewport XMid // align ViewBox.Min with midpoint values of Viewport XMax // align ViewBox.Min+Size with maximum values of Viewport XMask ViewBoxAlign = XMin + XMid + XMax // mask for X values -- clear all X before setting new one YMin ViewBoxAlign = 1 << iota // align ViewBox.Min with smallest values of Viewport YMid // align ViewBox.Min with midpoint values of Viewport YMax // align ViewBox.Min+Size with maximum values of Viewport YMask ViewBoxAlign = YMin + YMid + YMax // mask for Y values -- clear all Y before setting new one )
type ViewBoxMeetOrSlice ¶
type ViewBoxMeetOrSlice int32 //enums:enum
ViewBoxMeetOrSlice defines values for the PreserveAspectRatio meet or slice factor
const ( // Meet means the entire ViewBox is visible within Viewport, and it is // scaled up as much as possible to meet the align constraints Meet ViewBoxMeetOrSlice = iota // Slice means the entire ViewBox is covered by the ViewBox, and the // ViewBox is scaled down as much as possible, while still meeting the // align constraints Slice )
const ViewBoxMeetOrSliceN ViewBoxMeetOrSlice = 2
ViewBoxMeetOrSliceN is the highest valid value for type ViewBoxMeetOrSlice, plus one.
func ViewBoxMeetOrSliceValues ¶
func ViewBoxMeetOrSliceValues() []ViewBoxMeetOrSlice
ViewBoxMeetOrSliceValues returns all possible values for the type ViewBoxMeetOrSlice.
func (ViewBoxMeetOrSlice) Desc ¶
func (i ViewBoxMeetOrSlice) Desc() string
Desc returns the description of the ViewBoxMeetOrSlice value.
func (ViewBoxMeetOrSlice) Int64 ¶
func (i ViewBoxMeetOrSlice) Int64() int64
Int64 returns the ViewBoxMeetOrSlice value as an int64.
func (ViewBoxMeetOrSlice) IsValid ¶
func (i ViewBoxMeetOrSlice) IsValid() bool
IsValid returns whether the value is a valid option for type ViewBoxMeetOrSlice.
func (ViewBoxMeetOrSlice) MarshalText ¶
func (i ViewBoxMeetOrSlice) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*ViewBoxMeetOrSlice) SetInt64 ¶
func (i *ViewBoxMeetOrSlice) SetInt64(in int64)
SetInt64 sets the ViewBoxMeetOrSlice value from an int64.
func (*ViewBoxMeetOrSlice) SetString ¶
func (i *ViewBoxMeetOrSlice) SetString(s string) error
SetString sets the ViewBoxMeetOrSlice value from its string representation, and returns an error if the string is invalid.
func (ViewBoxMeetOrSlice) String ¶
func (i ViewBoxMeetOrSlice) String() string
String returns the string representation of this ViewBoxMeetOrSlice value.
func (*ViewBoxMeetOrSlice) UnmarshalText ¶
func (i *ViewBoxMeetOrSlice) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (ViewBoxMeetOrSlice) Values ¶
func (i ViewBoxMeetOrSlice) Values() []enums.Enum
Values returns all possible values for the type ViewBoxMeetOrSlice.
type ViewBoxPreserveAspectRatio ¶
type ViewBoxPreserveAspectRatio struct { // how to align x,y coordinates within viewbox Align ViewBoxAlign `svg:"align"` // how to scale the view box relative to the viewport MeetOrSlice ViewBoxMeetOrSlice `svg:"meetOrSlice"` }
ViewBoxPreserveAspectRatio determines how to scale the view box within parent Viewport2D
type XMLEncoder ¶
type XMLEncoder struct { Writer io.Writer DoIndent bool IndBytes []byte PreBytes []byte CurIndent int CurStart string NoEndIndent bool }
XMLEncoder is a minimal XML encoder that formats output with Attr each on a new line, using same API as xml.Encoder
func NewXMLEncoder ¶
func NewXMLEncoder(wr io.Writer) *XMLEncoder
func (*XMLEncoder) EncodeToken ¶
func (xe *XMLEncoder) EncodeToken(t xml.Token) error
func (*XMLEncoder) EscapeString ¶
func (xe *XMLEncoder) EscapeString(s string, escapeNewline bool)
EscapeString writes to p the properly escaped XML equivalent of the plain text data s.
func (*XMLEncoder) Flush ¶
func (xe *XMLEncoder) Flush()
func (*XMLEncoder) Indent ¶
func (xe *XMLEncoder) Indent(prefix, indent string)
func (*XMLEncoder) WriteEOL ¶
func (xe *XMLEncoder) WriteEOL()
func (*XMLEncoder) WriteEnd ¶
func (xe *XMLEncoder) WriteEnd(name string) error
func (*XMLEncoder) WriteIndent ¶
func (xe *XMLEncoder) WriteIndent()
func (*XMLEncoder) WriteStart ¶
func (xe *XMLEncoder) WriteStart(start *xml.StartElement) error
func (*XMLEncoder) WriteString ¶
func (xe *XMLEncoder) WriteString(str string)