2
Package svg generates SVG as defined by the Scalable Vector Graphics 1.1 Specification (<http://www.w3.org/TR/SVG11/>).
3
Output goes to the specified io.Writer.
5
Supported SVG elements and functions
9
circle, ellipse, polygon, polyline, rect (including roundrects), line, text
13
general, arc, cubic and quadratic bezier paths,
17
image, linearGradient, radialGradient,
21
translate, rotate, scale, skewX, skewY
25
filter, feBlend, feColorMatrix, feColorMatrix, feComponentTransfer, feComposite, feConvolveMatrix, feDiffuseLighting,
26
feDisplacementMap, feDistantLight, feFlood, feGaussianBlur, feImage, feMerge, feMorphology, feOffset, fePointLight,
27
feSpecularLighting, feSpotLight,feTile, feTurbulence
32
desc, defs, g (style, transform, id), mask, marker, pattern, title, (a)ddress, link, script, use
34
Usage: (assuming GOPATH is set)
36
go get github.com/ajstarks/svgo
37
go install github.com/ajstarks/svgo/...
40
You can use godoc to browse the documentation from the command line:
42
$ godoc github.com/ajstarks/svgo
45
a minimal program, to generate SVG to standard output.
50
"github.com/ajstarks/svgo"
57
canvas := svg.New(os.Stdout)
58
canvas.Start(width, height)
59
canvas.Circle(width/2, height/2, 100)
60
canvas.Text(width/2, height/2, "Hello, SVG", "text-anchor:middle;font-size:30px;fill:white")
64
Drawing in a web server: (http://localhost:2003/circle)
70
"github.com/ajstarks/svgo"
75
http.Handle("/circle", http.HandlerFunc(circle))
76
err := http.ListenAndServe(":2003", nil)
78
log.Fatal("ListenAndServe:", err)
82
func circle(w http.ResponseWriter, req *http.Request) {
83
w.Header().Set("Content-Type", "image/svg+xml")
86
s.Circle(250, 250, 125, "fill:none;stroke:black")
92
Many functions use x, y to specify an object's location, and w, h to specify the object's width and height.
93
Where applicable, a final optional argument specifies the style to be applied to the object.
94
The style strings follow the SVG standard; name:value pairs delimited by semicolons, or a
95
series of name="value" pairs. For example: `"fill:none; opacity:0.3"` or `fill="none" opacity="0.3"` (see: <http://www.w3.org/TR/SVG11/styling.html>)
99
type Offcolor struct {
105
is used to specify the offset, color, and opacity of stop colors in linear and radial gradients
109
type Filterspec struct {
115
is used to specify inputs and results for filter effects