~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/ajstarks/svgo/doc.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
4
 
 
5
Supported SVG elements and functions
 
6
 
 
7
Shapes, lines, text
 
8
 
 
9
 circle, ellipse, polygon, polyline, rect (including roundrects), line, text
 
10
 
 
11
Paths
 
12
 
 
13
 general, arc, cubic and quadratic bezier paths,
 
14
 
 
15
Image and Gradients
 
16
 
 
17
 image, linearGradient, radialGradient,
 
18
 
 
19
Transforms
 
20
 
 
21
 translate, rotate, scale, skewX, skewY
 
22
 
 
23
Filter Effects
 
24
 
 
25
 filter, feBlend, feColorMatrix, feColorMatrix, feComponentTransfer, feComposite, feConvolveMatrix, feDiffuseLighting,
 
26
 feDisplacementMap, feDistantLight, feFlood, feGaussianBlur, feImage, feMerge, feMorphology, feOffset, fePointLight,
 
27
 feSpecularLighting, feSpotLight,feTile, feTurbulence
 
28
 
 
29
 
 
30
Metadata elements
 
31
 
 
32
 desc, defs, g (style, transform, id), mask, marker, pattern, title, (a)ddress, link, script, use
 
33
 
 
34
Usage: (assuming GOPATH is set)
 
35
 
 
36
        go get github.com/ajstarks/svgo
 
37
        go install github.com/ajstarks/svgo/...
 
38
 
 
39
 
 
40
You can use godoc to browse the documentation from the command line:
 
41
 
 
42
        $ godoc github.com/ajstarks/svgo
 
43
 
 
44
 
 
45
a minimal program, to generate SVG to standard output.
 
46
 
 
47
        package main
 
48
 
 
49
        import (
 
50
                "github.com/ajstarks/svgo"
 
51
                "os"
 
52
        )
 
53
 
 
54
        func main() {
 
55
                width := 500
 
56
                height := 500
 
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")
 
61
                canvas.End()
 
62
        }
 
63
 
 
64
Drawing in a web server: (http://localhost:2003/circle)
 
65
 
 
66
        package main
 
67
 
 
68
        import (
 
69
                "log"
 
70
                "github.com/ajstarks/svgo"
 
71
                "net/http"
 
72
        )
 
73
 
 
74
        func main() {
 
75
                http.Handle("/circle", http.HandlerFunc(circle))
 
76
                err := http.ListenAndServe(":2003", nil)
 
77
                if err != nil {
 
78
                        log.Fatal("ListenAndServe:", err)
 
79
                }
 
80
        }
 
81
 
 
82
        func circle(w http.ResponseWriter, req *http.Request) {
 
83
          w.Header().Set("Content-Type", "image/svg+xml")
 
84
          s := svg.New(w)
 
85
          s.Start(500, 500)
 
86
          s.Circle(250, 250, 125, "fill:none;stroke:black")
 
87
          s.End()
 
88
        }
 
89
 
 
90
Functions and types
 
91
 
 
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>)
 
96
 
 
97
The Offcolor type:
 
98
 
 
99
        type Offcolor struct {
 
100
                Offset  uint8
 
101
                Color   string
 
102
                Opacity float
 
103
        }
 
104
 
 
105
is used to specify the offset, color, and opacity of stop colors in linear and radial gradients
 
106
 
 
107
The Filterspec type:
 
108
 
 
109
        type Filterspec struct {
 
110
                In string
 
111
                In2 string
 
112
                Result string
 
113
        }
 
114
 
 
115
is used to specify inputs and results for filter effects
 
116
 
 
117
*/
 
118
package svg