Documentation
¶
Overview ¶
Package svg parses SVG markup and adapts it to Paper components.
Index ¶
- Variables
- func Rasterize(data []byte, widthMM, heightMM float64) ([]byte, int, int, error)
- func RasterizeWithLimit(data []byte, widthMM, heightMM float64, maxPixels int64) ([]byte, int, int, error)
- type AspectAlign
- type AspectMeetOrSlice
- type Node
- type PreserveAspectRatio
- type SVG
- func (s *SVG) AspectRatio() float64
- func (s *SVG) AutoRow(rectProps ...props.Rect) core.Row
- func (s *SVG) Bytes() []byte
- func (s *SVG) Col(size int, rectProps ...props.Rect) core.Col
- func (s *SVG) Component(rectProps ...props.Rect) core.Component
- func (s *SVG) Defs() map[string]*Node
- func (s *SVG) Height() float64
- func (s *SVG) PreserveAspectRatio() PreserveAspectRatio
- func (s *SVG) Rasterize(widthMM, heightMM float64) ([]byte, int, int, error)
- func (s *SVG) Root() *Node
- func (s *SVG) Row(height float64, rectProps ...props.Rect) core.Row
- func (s *SVG) ViewBox() ViewBox
- func (s *SVG) Width() float64
- type ViewBox
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSVGHasZeroDimensions is returned when SVG rasterization cannot infer dimensions. ErrSVGHasZeroDimensions = svgraster.ErrSVGHasZeroDimensions // ErrSVGTooLarge is returned when rasterization would exceed the pixel limit. ErrSVGTooLarge = svgraster.ErrSVGTooLarge // ErrNilDocument is returned when a method requiring an SVG document is called on nil. ErrNilDocument = errors.New("svg: nil document") // ErrNoSVGElement is returned when parsed XML does not contain an <svg> element. ErrNoSVGElement = errors.New("svg: no <svg> element found") // ErrEmptyDocument is returned when the SVG input has no XML element. ErrEmptyDocument = errors.New("svg: empty document") )
Functions ¶
Types ¶
type AspectAlign ¶
type AspectAlign int
AspectAlign controls how the viewBox is positioned within the viewport.
const ( // AlignXMidYMid centers the viewBox on both axes. AlignXMidYMid AspectAlign = iota // AlignXMinYMin aligns to the minimum x and minimum y edge. AlignXMinYMin // AlignXMidYMin centers x and aligns to the minimum y edge. AlignXMidYMin // AlignXMaxYMin aligns to the maximum x and minimum y edge. AlignXMaxYMin // AlignXMinYMid aligns to the minimum x edge and centers y. AlignXMinYMid // AlignXMaxYMid aligns to the maximum x edge and centers y. AlignXMaxYMid // AlignXMinYMax aligns to the minimum x and maximum y edge. AlignXMinYMax // AlignXMidYMax centers x and aligns to the maximum y edge. AlignXMidYMax // AlignXMaxYMax aligns to the maximum x and maximum y edge. AlignXMaxYMax )
type AspectMeetOrSlice ¶
type AspectMeetOrSlice int
AspectMeetOrSlice selects the uniform-scaling strategy.
const ( // ScaleMeet scales uniformly so the entire viewBox fits. ScaleMeet AspectMeetOrSlice = iota // ScaleSlice scales uniformly so the viewport is covered. ScaleSlice )
type PreserveAspectRatio ¶
type PreserveAspectRatio struct {
Align AspectAlign
MeetOrSlice AspectMeetOrSlice
None bool
}
PreserveAspectRatio captures the parsed preserveAspectRatio attribute.
func DefaultPreserveAspectRatio ¶
func DefaultPreserveAspectRatio() PreserveAspectRatio
DefaultPreserveAspectRatio returns the SVG default: xMidYMid meet.
type SVG ¶
type SVG struct {
// contains filtered or unexported fields
}
SVG is a parsed SVG document.
func ParseBytes ¶
ParseBytes parses SVG markup from bytes.
func ParseReader ¶
ParseReader parses SVG markup from a reader.
func (*SVG) AspectRatio ¶
AspectRatio returns width / height, or zero if dimensions are unavailable.
func (*SVG) AutoRow ¶
AutoRow returns an automatic-height Paper row containing this SVG as an image component.
func (*SVG) Height ¶
Height returns the explicit SVG height, or the viewBox height when height is absent.
func (*SVG) PreserveAspectRatio ¶
func (s *SVG) PreserveAspectRatio() PreserveAspectRatio
PreserveAspectRatio returns the parsed preserveAspectRatio attribute.
func (*SVG) Rasterize ¶
Rasterize converts this SVG to PNG bytes at the requested millimetre dimensions.