Documentation ¶
Overview ¶
Package svg implements parsing of SVG images. It transforms SVG text files into an in-memory structure that is easy to draw. CSS is supported via the `css` package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GradientSpread ¶ added in v0.0.2
type GradientSpread uint8
GradientSpread defines how a gradient should be repeated.
const ( NoRepeat GradientSpread = iota Repeat Reflect )
func (GradientSpread) LinearGradient ¶ added in v0.0.2
func (spread GradientSpread) LinearGradient(positions []Fl, colors []parser.RGBA, x1, y1, dx, dy, vectorLength Fl) backend.GradientLayout
LinearGradient handle spread (repeat) for linear gradients It is used for SVG and CSS gradient rendering.
func (GradientSpread) RadialGradient ¶ added in v0.0.2
func (spread GradientSpread) RadialGradient(positions []Fl, colors []parser.RGBA, fx, fy, fr, cx, cy, r, width, height Fl) backend.GradientLayout
type ImageLoader ¶
ImageLoader is used to resolve and process image url found in SVG files.
type SVGImage ¶
type SVGImage struct {
// contains filtered or unexported fields
}
func Parse ¶
func Parse(svg io.Reader, baseURL string, imageLoader ImageLoader, urlFetcher utils.UrlFetcher) (*SVGImage, error)
Parse parsed the given SVG source data. Warnings are logged for unsupported elements. An error is returned for invalid documents. `baseURL` is used as base path for url resources. `urlFetcher` is required to handle linked SVG documents like in <use> tags. `imageLoader` is required to handle inner images.
func ParseNode ¶ added in v0.0.2
func ParseNode(root *html.Node, baseURL string, imageLoader ImageLoader, urlFetcher utils.UrlFetcher) (*SVGImage, error)
ParseNode is the same as Parse but works with an already parsed svg input.
func (*SVGImage) DisplayedSize ¶
DisplayedSize returns the value of the "width" and "height" attributes of the <svg> root element, which discribe the displayed size of the rectangular viewport. If no value is specified, it default to 100% (auto).
type Unit ¶
type Unit uint8
Unit is an enum type for units supported in SVG images.
const ( Px Unit Cm Mm Pt In Q Pc // Special case : percentage (%) relative to the viewbox Perc // Special case : relative to the font size Em Rem // Special case : relative to the font size Ex )
Units supported.