Documentation ¶
Overview ¶
Package vgsvg uses svgo (github.com/ajstarks/svgo) as a backend for vg.
Example ¶
package main import ( "log" "github.com/elamre/plot" "github.com/elamre/plot/plotter" "github.com/elamre/plot/vg" ) func main() { p, err := plot.New() if err != nil { log.Fatalf("could not create plot: %v", err) } p.Title.Text = "Scatter plot" p.X.Label.Text = "X" p.Y.Label.Text = "Y" scatter, err := plotter.NewScatter(plotter.XYs{{X: 1, Y: 1}, {X: 0, Y: 1}, {X: 0, Y: 0}}) if err != nil { log.Fatalf("could not create scatter: %v", err) } p.Add(scatter) err = p.Save(5*vg.Centimeter, 5*vg.Centimeter, "testdata/scatter.svg") if err != nil { log.Fatalf("could not save SVG plot: %v", err) } }
Output:
Index ¶
- Constants
- func UseWH(w, h vg.Length) option
- type Canvas
- func (c *Canvas) DrawImage(rect vg.Rectangle, img image.Image)
- func (c *Canvas) Fill(path vg.Path)
- func (c *Canvas) FillString(font vg.Font, pt vg.Point, str string)
- func (c *Canvas) Pop()
- func (c *Canvas) Push()
- func (c *Canvas) Rotate(rot float64)
- func (c *Canvas) Scale(x, y float64)
- func (c *Canvas) SetColor(clr color.Color)
- func (c *Canvas) SetLineDash(dashes []vg.Length, offs vg.Length)
- func (c *Canvas) SetLineWidth(w vg.Length)
- func (c *Canvas) Size() (w, h vg.Length)
- func (c *Canvas) Stroke(path vg.Path)
- func (c *Canvas) Translate(pt vg.Point)
- func (c *Canvas) WriteTo(w io.Writer) (int64, error)
Examples ¶
Constants ¶
View Source
const ( // DefaultWidth and DefaultHeight are the default canvas // dimensions. DefaultWidth = 4 * vg.Inch DefaultHeight = 4 * vg.Inch )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
func NewWith ¶
func NewWith(opts ...option) *Canvas
NewWith returns a new image canvas created according to the specified options. The currently accepted options is UseWH. If size is not specified, the default is used.
func (*Canvas) FillString ¶
FillString draws str at position pt using the specified font. Text passed to FillString is escaped with html.EscapeString.
func (*Canvas) SetLineWidth ¶
Click to show internal directories.
Click to hide internal directories.