Documentation
¶
Index ¶
- Variables
- func Lookup(label string) (e encoding.Encoding, name string)
- func NewReaderLabel(label string, input io.Reader) (io.Reader, error)
- func ParseSVGColor(colorStr string) (color.Color, error)
- func ReadFloatList(numStr string) ([]float64, error)
- type CPoint
- type Contour
- type ErrorMode
- type Glyph
- type IconCursor
- func (c *IconCursor) PushState(name string, attrs []xml.Attr) error
- func (c *IconCursor) ReadGradAttr(attr xml.Attr) (err error)
- func (c *IconCursor) ReadGradURL(v string, defaultColor interface{}) (grad rasterx.Gradient, ok bool)
- func (cursor *IconCursor) ReadIconStream(stream io.Reader, errMode ...ErrorMode) (*SvgIcon, error)
- func (c *IconCursor) SetFonts(fonts []Ttx)
- type PathCursor
- type PathStyle
- type SvgIcon
- type SvgPath
- func (svgp *SvgPath) Draw(r *rasterx.Dasher, opacity float64)
- func (svgp *SvgPath) DrawTransformed(r *rasterx.Dasher, opacity float64, t rasterx.Matrix2D)
- func (svgp *SvgPath) GetFillColor() color.Color
- func (svgp *SvgPath) GetLineColor() color.Color
- func (svgp *SvgPath) SetFillColor(clr color.Color)
- func (svgp *SvgPath) SetLineColor(clr color.Color)
- type Ttx
Constants ¶
This section is empty.
Variables ¶
var DefaultStyle = PathStyle{1.0, 1.0, 2.0, 0.0, 20.0, nil, false, color.NRGBA{0x00, 0x00, 0x00, 0xff}, nil, nil, nil, rasterx.ButtCap, rasterx.Miter, rasterx.MatrixAdder{M: rasterx.Identity}}
DefaultStyle sets the default PathStyle to fill black, winding rule, full opacity, no stroke, ButtCap line end and Miter line connect.
Functions ¶
func NewReaderLabel ¶
NewReaderLabel returns a reader that converts from the specified charset to UTF-8. It uses Lookup to find the encoding that corresponds to label, and returns an error if Lookup returns nil. It is suitable for use as encoding/xml.Decoder's CharsetReader function.
func ParseSVGColor ¶
ParseSVGColor parses an SVG color string in all forms including all SVG1.1 names, obtained from the image.colornames package
func ReadFloatList ¶
ReadFloatList parses a comma or space separated list of numbers.
Types ¶
type ErrorMode ¶
type ErrorMode uint8
ErrorMode is the setting for how the parser reacts to unparsed elements
type Glyph ¶
type Glyph struct {
Name string
MaxX, MinX, MaxY, MinY int16
Width, Lsb, Height, Tsb int16
Code uint16
Contours []Contour
}
Glyph is a single font glyph with its metrics and outlines.
type IconCursor ¶
type IconCursor struct {
PathCursor
// contains filtered or unexported fields
}
IconCursor is used while parsing SVG files.
func NewIconCursor ¶
func NewIconCursor() *IconCursor
NewIconCursor returns an IconCursor with the default style and no icon set.
func (*IconCursor) PushState ¶
func (c *IconCursor) PushState(name string, attrs []xml.Attr) error
PushState parses the style element, and push it on the style stack. Only color and opacity are supported for fill. Note that this parses both the contents of a style attribute plus direct fill and opacity attributes.
func (*IconCursor) ReadGradAttr ¶
func (c *IconCursor) ReadGradAttr(attr xml.Attr) (err error)
ReadGradAttr reads an SVG gradient attribute.
func (*IconCursor) ReadGradURL ¶
func (c *IconCursor) ReadGradURL(v string, defaultColor interface{}) (grad rasterx.Gradient, ok bool)
ReadGradURL reads an SVG format gradient url Since the context of the gradient can affect the colors the current fill or line color is passed in and used in the case of a nil stopClor value
func (*IconCursor) ReadIconStream ¶
ReadIconStream reads the Icon from the stream using the cursor
func (*IconCursor) SetFonts ¶
func (c *IconCursor) SetFonts(fonts []Ttx)
SetFonts adds a set of fonts. Without fonts, text elements are not rendered.
type PathCursor ¶
type PathCursor struct {
rasterx.Path
ErrorMode ErrorMode
// contains filtered or unexported fields
}
PathCursor is used to parse SVG format path strings into a rasterx Path
func (*PathCursor) AddArcFromA ¶
func (c *PathCursor) AddArcFromA(points []float64)
AddArcFromA adds a path of an arc element to the cursor path to the PathCursor
func (*PathCursor) CompilePath ¶
func (c *PathCursor) CompilePath(svgPath string) error
CompilePath translates the svgPath description string into a rasterx path. All valid SVG path elements are interpreted to rasterx equivalents. The resulting path element is stored in the PathCursor.
func (*PathCursor) EllipseAt ¶
func (c *PathCursor) EllipseAt(cx, cy, rx, ry float64)
EllipseAt adds a path of an elipse centered at cx, cy of radius rx and ry to the PathCursor.
func (*PathCursor) GetPoints ¶
func (c *PathCursor) GetPoints(dataPoints string) error
GetPoints reads a set of floating point values from the SVG format number string, and add them to the cursor's points slice.
func (*PathCursor) ReadFloat ¶
func (c *PathCursor) ReadFloat(numStr string) error
ReadFloat reads a floating point value and adds it to the cursor's points slice.
type PathStyle ¶
type PathStyle struct {
FillOpacity, LineOpacity float64
LineWidth, DashOffset, MiterLimit float64
Dash []float64
UseNonZeroWinding bool
LineGap rasterx.GapFunc
LeadLineCap rasterx.CapFunc // This is used if different than LineCap
LineCap rasterx.CapFunc
LineJoin rasterx.JoinMode
// contains filtered or unexported fields
}
PathStyle holds the state of the SVG style.
type SvgIcon ¶
type SvgIcon struct {
ViewBox struct{ X, Y, W, H float64 }
Titles []string // Title elements collect here
Descriptions []string // Description elements collect here
Grads map[string]*rasterx.Gradient
Defs map[string][]definition
SVGPaths []SvgPath
Transform rasterx.Matrix2D
// contains filtered or unexported fields
}
SvgIcon holds data from parsed SVGs.
func ReadIcon ¶
ReadIcon reads the Icon from the named file. This only supports a sub-set of SVG, but is enough to draw many icons. If errMode is provided, the first value determines if the icon ignores, errors out, or logs a warning if it does not handle an element found in the icon file. Ignore warnings is the default if no ErrorMode value is provided.
func ReadIconStream ¶
ReadIconStream reads the Icon from the given io.Reader. This only supports a sub-set of SVG, but is enough to draw many icons. If errMode is provided, the first value determines if the icon ignores, errors out, or logs a warning if it does not handle an element found in the icon file. Ignore warnings is the default if no ErrorMode value is provided.
func ReadReplacingCurrentColor ¶
func ReadReplacingCurrentColor(stream io.Reader, currentColor string, errMode ...ErrorMode) (icon *SvgIcon, err error)
ReadReplacingCurrentColor replaces currentColor value with specified value and loads SvgIcon as ReadIconStream do. currentColor value should be valid hex, rgb or named color value.
type SvgPath ¶
SvgPath binds a style to a path.
func (*SvgPath) DrawTransformed ¶
DrawTransformed draws the compiled SvgPath into the Dasher while applying transform t.
func (*SvgPath) GetFillColor ¶
GetFillColor returns the fill color of the SvgPath if one is defined and otherwise returns colornames.Black
func (*SvgPath) GetLineColor ¶
GetLineColor returns the stroke color of the SvgPath if one is defined and otherwise returns colornames.Black
func (*SvgPath) SetFillColor ¶
SetFillColor sets the fill color of the SvgPath
func (*SvgPath) SetLineColor ¶
SetLineColor sets the line color of the SvgPath
type Ttx ¶
type Ttx struct {
Name string
Created, Modified string
MaxX, MinX, MaxY, MinY int16
UnitsPerEm int16
GlyphTable map[string]Glyph
CodeTable map[uint16]string
KernTable map[string]int16
}
Ttx holds the glyph, code and kerning tables of a parsed TTX font file.
func (*Ttx) GlyphForRune ¶
GlyphForRune returns the glyph for tk, reporting false if the font has none.
func (*Ttx) StringToPaths ¶
func (ttx *Ttx) StringToPaths(text string, m rasterx.Matrix2D, useKerning bool) (p rasterx.Path, advance fixed.Point26_6, consumed int)
StringToPaths converts text to a path in the font's units, transformed by m. It returns the path, the total advance and the number of runes consumed.




