Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added attributes to svg.Startview and svg.StartviewUnit #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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