Documentation
¶
Overview ¶
Package svg provides an SVG export backend for gg's recording system.
This package registers an "svg" backend that can be used to export recorded drawing operations to SVG format.
Usage ¶
Import this package with a blank identifier to register the SVG backend:
import _ "github.com/gogpu/gg-svg"
Then use recording.NewBackend("svg") to create an SVG backend:
backend, err := recording.NewBackend("svg")
if err != nil {
log.Fatal(err)
}
// Record drawing operations
rec := recording.NewRecorder(800, 600)
// ... draw ...
r := rec.Finish()
// Playback to SVG backend
r.Playback(backend)
// Save to file
if fb, ok := backend.(recording.FileBackend); ok {
fb.SaveToFile("output.svg")
}
Index ¶
- type Backend
- func (b *Backend) Begin(width, height int) error
- func (b *Backend) ClearClip()
- func (b *Backend) DrawImage(img image.Image, src, dst recording.Rect, opts recording.ImageOptions)
- func (b *Backend) DrawText(s string, x, y float64, face text.Face, brush recording.Brush)
- func (b *Backend) End() error
- func (b *Backend) FillPath(path *gg.Path, brush recording.Brush, rule recording.FillRule)
- func (b *Backend) FillRect(rect recording.Rect, brush recording.Brush)
- func (b *Backend) Restore()
- func (b *Backend) Save()
- func (b *Backend) SaveToFile(path string) error
- func (b *Backend) SetClip(path *gg.Path, rule recording.FillRule)
- func (b *Backend) SetTransform(m recording.Matrix)
- func (b *Backend) StrokePath(path *gg.Path, brush recording.Brush, stroke recording.Stroke)
- func (b *Backend) WriteTo(w io.Writer) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend implements recording.Backend for SVG output. It generates SVG XML from recorded drawing commands.
func NewBackend ¶
func NewBackend() *Backend
NewBackend creates a new SVG backend. The backend starts in an uninitialized state. Call Begin() to initialize with specific dimensions before drawing.
func (*Backend) DrawImage ¶
DrawImage draws an image from the source rectangle to the destination rectangle.
func (*Backend) DrawText ¶
DrawText draws text at the given position with the specified font face and brush.
func (*Backend) Restore ¶
func (b *Backend) Restore()
Restore restores the graphics state from the stack.
func (*Backend) SaveToFile ¶
SaveToFile saves the SVG to a file at the given path. This implements recording.FileBackend.
func (*Backend) SetTransform ¶
SetTransform sets the current transformation matrix.
func (*Backend) StrokePath ¶
StrokePath strokes the given path with the brush and stroke style.