Skip to content

Commit

Permalink
Added attributes to svg.Startview and svg.StartviewUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
countcb committed Jul 15, 2017
1 parent fec71ff commit 21f982e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
14 changes: 8 additions & 6 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -221,24 +221,26 @@ is used to specify inputs and results for filter effects
(such as additional namespaces or scripting events)
<http://www.w3.org/TR/SVG11/struct.html#SVGElement>

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

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


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


StartviewUnit(w, h int, unit string, minx, miny, vw, vh int)
begin the SVG document with the width w, height h, in the specified unit, with a viewBox at minx, miny, vw, vh.
StartviewUnit(w, h int, unit string, minx, miny, vw, vh int, attributes ...string)
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
(such as additional namespaces or scripting events)
<http://www.w3.org/TR/SVG11/struct.html#SVGElement>

End()
Expand Down
26 changes: 15 additions & 11 deletions svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,45 +88,49 @@ func (svg *SVG) genattr(ns []string) {
// Start begins the SVG document with the width w and height h.
// Other attributes may be optionally added, for example viewbox or additional namespaces
// Standard Reference: http://www.w3.org/TR/SVG11/struct.html#SVGElement
func (svg *SVG) Start(w int, h int, ns ...string) {
func (svg *SVG) Start(w int, h int, attributes ...string) {
svg.printf(svginitfmt, svgtop, w, "", h, "")
svg.genattr(ns)
svg.genattr(attributes)
}

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

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

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

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

// Startraw begins the SVG document, passing arbitrary attributes
func (svg *SVG) Startraw(ns ...string) {
func (svg *SVG) Startraw(attributes ...string) {
svg.printf(svgtop)
svg.genattr(ns)
svg.genattr(attributes)
}

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

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

0 comments on commit 21f982e

Please sign in to comment.