Skip to content

Commit

Permalink
feat: expose attribute and children fields
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed May 13, 2024
1 parent dbf4ca5 commit 9501c2c
Show file tree
Hide file tree
Showing 6 changed files with 1,687 additions and 1,838 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Package `svg` provides convenience methods for creating and writing SVG document

```go
func ExampleNew() {
svgElement := svg.New().WidthHeight(4, 4, svg.CM).ViewBox(0, 0, 400, 400).Children(
svgElement := svg.New().WidthHeight(4, 4, svg.CM).ViewBox(0, 0, 400, 400).AppendChildren(
svg.Title(svg.CharData("Example triangle01- simple example of a 'path'")),
svg.Desc(svg.CharData("A path that draws a triangle")),
svg.Rect().XYWidthHeight(1, 1, 398, 398, svg.Number).Fill("none").Stroke("blue"),
Expand All @@ -36,7 +36,6 @@ func ExampleNew() {
Output:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<svg height="4cm" version="1.1" viewBox="0 0 400 400" width="4cm" xmlns="http://www.w3.org/2000/svg">
<title>Example triangle01- simple example of a &#39;path&#39;</title>
<desc>A path that draws a triangle</desc>
Expand Down
2 changes: 1 addition & 1 deletion cmd/svgclock/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func svgClock(t time.Time) *svg.SVGElement {
).Stroke(hand.stroke).StrokeWidth(hand.strokeWidth)
handElements = append(handElements, handElement)
}
return svg.New().WidthHeight(width, height, svg.Number).ViewBox(0, 0, width, height).Children(
return svg.New().WidthHeight(width, height, svg.Number).ViewBox(0, 0, width, height).AppendChildren(
svg.Circle().CXCYR(width/2, height/2, radius, svg.Number).Fill("none").Stroke("black"),
).AppendChildren(handElements...)
}
Expand Down
Loading

0 comments on commit 9501c2c

Please sign in to comment.