Skip to content

Commit 21f982e

Browse files
committed
Added attributes to svg.Startview and svg.StartviewUnit
1 parent fec71ff commit 21f982e

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

README.markdown

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,24 +221,26 @@ is used to specify inputs and results for filter effects
221221
(such as additional namespaces or scripting events)
222222
<http://www.w3.org/TR/SVG11/struct.html#SVGElement>
223223

224-
Startview(w, h, minx, miny, vw, vh int)
225-
begin the SVG document with the width w, height h, with a viewBox at minx, miny, vw, vh.
224+
Startview(w, h, minx, miny, vw, vh int, attributes ...string)
225+
begin the SVG document with the width w, height h, with a viewBox at minx, miny, vw, vh. Optionally add additional elements
226+
(such as additional namespaces or scripting events)
226227
<http://www.w3.org/TR/SVG11/struct.html#SVGElement>
227228

228-
Startunit(w int, h int, unit string, ns ...string)
229+
Startunit(w int, h int, unit string, attributes ...string)
229230
begin the SVG document, with width and height in the specified units. Optionally add additional elements
230231
(such as additional namespaces or scripting events)
231232
<http://www.w3.org/TR/SVG11/struct.html#SVGElement>
232233

233234

234-
Startpercent(w int, h int, ns ...string)
235+
Startpercent(w int, h int, attributes ...string)
235236
begin the SVG document, with width and height in percent. Optionally add additional elements
236237
(such as additional namespaces or scripting events)
237238
<http://www.w3.org/TR/SVG11/struct.html#SVGElement>
238239

239240

240-
StartviewUnit(w, h int, unit string, minx, miny, vw, vh int)
241-
begin the SVG document with the width w, height h, in the specified unit, with a viewBox at minx, miny, vw, vh.
241+
StartviewUnit(w, h int, unit string, minx, miny, vw, vh int, attributes ...string)
242+
begin the SVG document with the width w, height h, in the specified unit, with a viewBox at minx, miny, vw, vh. Optionally add additional elements
243+
(such as additional namespaces or scripting events)
242244
<http://www.w3.org/TR/SVG11/struct.html#SVGElement>
243245

244246
End()

svg.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,45 +88,49 @@ func (svg *SVG) genattr(ns []string) {
8888
// Start begins the SVG document with the width w and height h.
8989
// Other attributes may be optionally added, for example viewbox or additional namespaces
9090
// Standard Reference: http://www.w3.org/TR/SVG11/struct.html#SVGElement
91-
func (svg *SVG) Start(w int, h int, ns ...string) {
91+
func (svg *SVG) Start(w int, h int, attributes ...string) {
9292
svg.printf(svginitfmt, svgtop, w, "", h, "")
93-
svg.genattr(ns)
93+
svg.genattr(attributes)
9494
}
9595

9696
// Startunit begins the SVG document, with width and height in the specified units
9797
// Other attributes may be optionally added, for example viewbox or additional namespaces
98-
func (svg *SVG) Startunit(w int, h int, unit string, ns ...string) {
98+
func (svg *SVG) Startunit(w int, h int, unit string, attributes ...string) {
9999
svg.printf(svginitfmt, svgtop, w, unit, h, unit)
100-
svg.genattr(ns)
100+
svg.genattr(attributes)
101101
}
102102

103103
// Startpercent begins the SVG document, with width and height as percentages
104104
// Other attributes may be optionally added, for example viewbox or additional namespaces
105-
func (svg *SVG) Startpercent(w int, h int, ns ...string) {
105+
func (svg *SVG) Startpercent(w int, h int, attributes ...string) {
106106
svg.printf(svginitfmt, svgtop, w, "%", h, "%")
107-
svg.genattr(ns)
107+
svg.genattr(attributes)
108108
}
109109

110110
// Startview begins the SVG document, with the specified width, height, and viewbox
111111
// Other attributes may be optionally added, for example viewbox or additional namespaces
112-
func (svg *SVG) Startview(w, h, minx, miny, vw, vh int) {
112+
func (svg *SVG) Startview(w, h, minx, miny, vw, vh int, attributes ...string) {
113113
svg.Start(w, h, fmt.Sprintf(vbfmt, minx, miny, vw, vh))
114+
svg.genattr(attributes)
114115
}
115116

116-
func (svg *SVG) StartviewUnit(w, h int, unit string, minx, miny, vw, vh int) {
117+
// Startunit begins the SVG document, with width and height in the specified units, and viewbox
118+
// Other attributes may be optionally added, for example viewbox or additional namespaces
119+
func (svg *SVG) StartviewUnit(w, h int, unit string, minx, miny, vw, vh int, attributes ...string) {
117120
svg.Startunit(w, h, unit, fmt.Sprintf(vbfmt, minx, miny, vw, vh))
121+
svg.genattr(attributes)
118122
}
119123

120124
// Startraw begins the SVG document, passing arbitrary attributes
121-
func (svg *SVG) Startraw(ns ...string) {
125+
func (svg *SVG) Startraw(attributes ...string) {
122126
svg.printf(svgtop)
123-
svg.genattr(ns)
127+
svg.genattr(attributes)
124128
}
125129

126130
// End the SVG document
127131
func (svg *SVG) End() { svg.println("</svg>") }
128132

129-
// linkembed defines an element with a specified type,
133+
// linkembed defines an element with a specified type,
130134
// (for example "application/javascript", or "text/css").
131135
// if the first variadic argument is a link, use only the link reference.
132136
// Otherwise, treat those arguments as the text of the script (marked up as CDATA).

0 commit comments

Comments
 (0)