131 lines
1.7 KiB
Go
131 lines
1.7 KiB
Go
package svg
|
|
|
|
import (
|
|
"bytes"
|
|
"html"
|
|
"io"
|
|
)
|
|
|
|
type (
|
|
// Text models an <text> element
|
|
Text = Element[TextTag, TextAttribute, TextChild]
|
|
TextTag struct{}
|
|
TextAttribute interface {
|
|
Attribute
|
|
IsTextAttribute()
|
|
}
|
|
TextChild interface {
|
|
MarshalerReader
|
|
IsTextChild()
|
|
}
|
|
|
|
RawText string
|
|
)
|
|
|
|
func NewText(t string) *Text {
|
|
return &Text{
|
|
Children: []TextChild{
|
|
RawText(t),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (t TextTag) PrintTag() string {
|
|
return "text"
|
|
}
|
|
|
|
func (t RawText) GetMarkup() string {
|
|
return html.EscapeString(string(t))
|
|
}
|
|
|
|
func (t RawText) GetMarkupReader() io.Reader {
|
|
return bytes.NewReader([]byte(t.GetMarkup()))
|
|
}
|
|
|
|
func (t RawText) IsTextChild() {
|
|
}
|
|
|
|
func (X) IsTextAttribute() {
|
|
}
|
|
|
|
func (XP) IsTextAttribute() {
|
|
}
|
|
|
|
func (Y) IsTextAttribute() {
|
|
}
|
|
|
|
func (YP) IsTextAttribute() {
|
|
}
|
|
|
|
func (DX) IsTextAttribute() {
|
|
}
|
|
|
|
func (DXP) IsTextAttribute() {
|
|
}
|
|
|
|
func (DY) IsTextAttribute() {
|
|
}
|
|
|
|
func (DYP) IsTextAttribute() {
|
|
}
|
|
|
|
func (Rotate) IsTextAttribute() {
|
|
}
|
|
|
|
func (RotateAuto) IsTextAttribute() {
|
|
}
|
|
|
|
func (RotateAutoReverse) IsTextAttribute() {
|
|
}
|
|
|
|
func (Fill) IsTextAttribute() {
|
|
}
|
|
|
|
func (TextLength) IsTextAttribute() {
|
|
}
|
|
|
|
func (TextLengthP) IsTextAttribute() {
|
|
}
|
|
|
|
func (LengthAdjust) IsTextAttribute() {
|
|
}
|
|
|
|
func (TextAnchor) IsTextAttribute() {
|
|
}
|
|
|
|
func (FontSize) IsTextAttribute() {
|
|
}
|
|
|
|
func (FontSizeP) IsTextAttribute() {
|
|
}
|
|
|
|
func (Transform) IsTextAttribute() {
|
|
}
|
|
|
|
func (TransformRotate) IsTextAttribute() {
|
|
}
|
|
|
|
func (TransformRotateAbout) IsTextAttribute() {
|
|
}
|
|
|
|
func (TransformTranslate) IsTextAttribute() {
|
|
}
|
|
|
|
func (TransformSkewX) IsTextAttribute() {
|
|
}
|
|
|
|
func (TransformSkewY) IsTextAttribute() {
|
|
}
|
|
|
|
func (TransformScale) IsTextAttribute() {
|
|
}
|
|
|
|
func (DominantBaseline) IsTextAttribute() {
|
|
}
|
|
|
|
func (Style) IsTextAttribute() {
|
|
}
|
|
|
|
func (Class) IsTextAttribute() {
|
|
}
|