An introduction to SVGo, includes a introduction to the Go programming language, a library overview, sketching with code with numerous examples, and drawing pictures from Internet services
generated code Start(w, h int, opEons ...string) Begin the SVG document, with opEons Startview(w, h, minx, miny, vw, vh int) Begin the document with a viewport Group(s ...string)/Gend() Begin a group with arbitrary a=ributes Gid(id string)/Gend() Begin/end a group with an id Gstyle(s string)/Gend() Begin/end a group style ClipPath(s ...string)/ClipEnd() Begin/end ClipPath Def(s string)/DefEnd() Begin/end definiEon block Title(s string) Specify the document Etle Desc(s string) Specify the document descripEon Link(href, Etle string)/LinkEnd() Link to content between Link and LinkEnd Use(x, y int, link string, style ...string) Use previously defined content End() End the SVG document
w, h int, s ...string) Polygon(x, y []int, s ...string) Ellipse(x, y, rx, ry int, s ...string) Circle(x, y, r int, s ...string) Roundrect(x, y, w, h, rx, ry int, s ...string) Square(x, y, w int, s ...string)
y1, x2, y2 int, s ...string) Arc(sx sy, ax, ay, r int, large, sweep bool, ex ey int, s ...string) Bezier(sx, sy, cx, cy, px, py, ex, ey int, s ...string) Path(d string, s ...string) Qbez(sx, sy, cx, cy, ex, ey int, s ...string)
ScaleXY(dx, dy float64) Translate(x, y int) Rotate(r float64) RotateTranslate(x, y int, r float64) TranslateRotate(x, y int, r float64) Gtransform(s string)
canvas.End() 1 2 3 4 function StartUp() { ... } function doStuff(element) { ... } example.com/myscript.js 1 2 3 4 Begin the document, load your funcEon specify the script, by reference specify SVG elements, operate on these end the SVG document
calls the API given a method with single name/value pair func flickrAPI(method, name, value string) string { return fmt.Sprintf(apifmt, method, apiKey, name, value) } // makeURI converts the elements of a photo into a Flickr photo URI func makeURI(p Photo, imsize string) string { im := p.Id + "_" + p.Secret if len(imsize) > 0 { im += "_" + imsize } return fmt.Sprintf(urifmt, p.Farm, p.Server, im) } // imageGrid reads the response from Flickr, and creates a grid of images func imageGrid(f FlickrResp, x, y, cols, gutter int, imgsize string) { if f.Stat != "ok" { fmt.Fprintf(os.Stderr, "%v\n", f) return } xpos := x for i, p := range f.Photos.Photo { if i%cols == 0 && i > 0 { xpos = x y += (imageHeight + gutter) } canvas.Link(makeURI(p, ""), p.Title) canvas.Image(xpos, y, imageWidth, imageHeight, makeURI(p, "s")) canvas.LinkEnd() xpos += (imageWidth + gutter) } }