38 lines
598 B
Go
38 lines
598 B
Go
package svg
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
)
|
|
|
|
func ExampleSVG() {
|
|
s := NewSVG().
|
|
Attr(
|
|
NewLength(10).
|
|
AsX(),
|
|
NewLength(20).
|
|
AsY(),
|
|
Style{
|
|
"font-size": "8px",
|
|
},
|
|
).
|
|
Child(
|
|
Rect{
|
|
Attributes: []RectAttribute{
|
|
NewLength(30).
|
|
AsX(),
|
|
Percentage(40).
|
|
AsY(),
|
|
},
|
|
},
|
|
NewText("abc 123"),
|
|
)
|
|
|
|
b, err := io.ReadAll(s.GetMarkupReader())
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(string(b))
|
|
// Output: <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="10" y="20" style="font-size: 8px"><rect x="30" y="40%"/><text>abc 123</text></svg>
|
|
}
|