Documentation
¶
Index ¶
- func BezierCurveSegment(p1, p2, p3, p4 *geo.Point, t0, t1 float64) (geo.Point, geo.Point, geo.Point, geo.Point)
- func CloseElement(name string) string
- func CompactEmptyElement(name string, attributes ...Attribute) string
- func EmptyElement(name string, attributes ...Attribute) string
- func EscapeAttribute(attribute string) string
- func EscapeText(text string) string
- func FormatFloat(value float64) string
- func GetStrokeDashAttributes(strokeWidth, dashGapSize float64) (float64, float64)
- func IsSupportedExternalDoctype(document, directive []byte) bool
- func LocalIRI(id ID) string
- func OpenClippedViewport(x, y, width, height, sourceY float64) string
- func OpenElement(name string, attributes ...Attribute) string
- func RenderAttributes(attributes ...Attribute) string
- func SVGID(text string) string
- func ScaledDimensions(width, height int, scale *float64) (string, error)
- func SplitPath(path string, percentage float64) (string, string, error)
- func UnderlineClips(progress float64) (decorated, plain string)
- type Attribute
- type Fragment
- type ID
- type PathCommand
- type PathCommandKind
- type SvgPathContext
- func (c *SvgPathContext) Absolute(x, y float64) *geo.Point
- func (c *SvgPathContext) C(isLowerCase bool, x1, y1, x2, y2, x3, y3 float64)
- func (c *SvgPathContext) H(isLowerCase bool, x float64)
- func (c *SvgPathContext) L(isLowerCase bool, x, y float64)
- func (c *SvgPathContext) PathCommands() []PathCommand
- func (c *SvgPathContext) PathData() string
- func (c *SvgPathContext) Relative(base *geo.Point, dx, dy float64) *geo.Point
- func (c *SvgPathContext) StartAt(p *geo.Point)
- func (c *SvgPathContext) V(isLowerCase bool, y float64)
- func (c *SvgPathContext) Z()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BezierCurveSegment ¶
func BezierCurveSegment(p1, p2, p3, p4 *geo.Point, t0, t1 float64) (geo.Point, geo.Point, geo.Point, geo.Point)
Given control points p1, p2, p3, p4, calculate the segment of this bezier curve from t0 -> t1 where {0 <= t0 < t1 <= 1}. Uses De Casteljau's algorithm, referenced: https://stackoverflow.com/questions/11703283/cubic-bezier-curve-segment/11704152#11704152
func CloseElement ¶ added in v0.10.0
func CompactEmptyElement ¶ added in v0.10.0
CompactEmptyElement is equivalent to EmptyElement but preserves the compact `/>` syntax used by older renderer output.
func EmptyElement ¶ added in v0.10.0
func EscapeAttribute ¶ added in v0.10.0
EscapeAttribute escapes a value for use in a double-quoted XML attribute. Single quotes are left unchanged because they cannot terminate that context. XML attribute whitespace is escaped so parsing preserves the original value.
func EscapeText ¶
func FormatFloat ¶ added in v0.9.0
FormatFloat serializes an SVG coordinate with the same six decimal places as %f, but omits redundant trailing zeros. Keeping the original rounding is important: formatting the full float or reducing precision changes geometry.
func GetStrokeDashAttributes ¶
func IsSupportedExternalDoctype ¶ added in v0.9.0
IsSupportedExternalDoctype reports whether directive is the encoding/xml token for one canonical W3C SVG 1.0 or SVG 1.1 external DOCTYPE declaration in document's raw prolog. Requiring both inputs prevents encoding/xml's directive normalization from widening the accepted raw syntax. It accepts no internal subset and performs no DTD resolution. Callers remain responsible for enforcing that the declaration occurs at most once and before the root.
func OpenClippedViewport ¶ added in v0.10.0
OpenClippedViewport clips the child artwork to a rectangle and translates it vertically by placing sourceY at the top of the viewport.
func OpenElement ¶ added in v0.10.0
OpenElement and EmptyElement serialize element boundaries while validating the renderer-controlled tag name.
func RenderAttributes ¶ added in v0.10.0
RenderAttributes serializes attributes in the supplied order. The returned string is empty or begins with one space, so it can be appended directly to an opening element name.
func ScaledDimensions ¶ added in v0.10.0
ScaledDimensions returns the outer SVG's explicit size. An absent scale leaves sizing to the containing document.
func SplitPath ¶
Splits an SVG path into two SVG paths, with the first path being ~{percentage}% of the path
func UnderlineClips ¶ added in v0.10.0
UnderlineClips returns complementary CSS clip-path values for the underlined and plain portions of one text line. fill-box anchors the cut to the actual font's glyph run, including when the label uses a fallback font.
Types ¶
type Attribute ¶ added in v0.10.0
type Attribute struct {
// contains filtered or unexported fields
}
Attribute is an SVG attribute whose name has been validated and whose value is escaped when rendered. Its fields are intentionally private so callers cannot accidentally construct an unescaped attribute fragment.
func Attr ¶ added in v0.10.0
Attr constructs an SVG attribute. The name must be a static XML attribute name and must not be an event-handler attribute. Invalid names panic because attribute names are a programmer-controlled part of the renderer, never diagram input.
func HrefAttributes ¶ added in v0.10.0
HrefAttributes returns the SVG 2 href attribute and its SVG 1.1 compatibility equivalent. This function only serializes the URL; callers must continue to apply the appropriate link or asset policy first.
func ParseAttributes ¶ added in v0.10.0
ParseAttributes converts the legacy textual attribute-list form into typed attributes. It rejects malformed XML, duplicate attributes, and event handlers instead of copying the fragment into renderer output.
type Fragment ¶ added in v0.10.0
type Fragment struct {
// contains filtered or unexported fields
}
Fragment is content that is already safe to place between SVG element tags. Use Text for untrusted strings and TrustedFragment only for renderer-generated SVG.
func TrustedFragment ¶ added in v0.10.0
type ID ¶ added in v0.10.0
type ID struct {
// contains filtered or unexported fields
}
ID is an identifier that is safe to use both as an XML id and in an unquoted local IRI such as url(#identifier).
func EncodedID ¶ added in v0.10.0
EncodedID encodes an arbitrary non-empty value using SVGID's stable base32 representation.
func LiteralID ¶ added in v0.10.0
LiteralID constructs an ID from a renderer-generated value. It panics if the value contains syntax that could change the meaning of a local IRI.
func ParseLocalIRI ¶ added in v0.10.0
ParseLocalIRI validates the deprecated textual local-reference form.
func ScopedID ¶ added in v0.10.0
ScopedID builds a stable identifier from trusted prefix/suffix strings and an arbitrary component. Ordinary safe components retain their spelling. Unsafe values and values beginning with the reserved encoding prefix are base32 encoded, keeping the mapping injective without changing common IDs.
type PathCommand ¶ added in v0.9.0
type PathCommand struct {
Kind PathCommandKind
Control1 geo.Point
Control2 geo.Point
End geo.Point
}
PathCommand contains absolute path geometry. End is used by move, line, and cubic commands. Control1 and Control2 are additionally used by cubic commands.
type PathCommandKind ¶ added in v0.9.0
type PathCommandKind uint8
PathCommandKind identifies one of the renderer-neutral path operations produced by SvgPathContext. SvgPathContext normalizes horizontal and vertical SVG commands to PathCommandLine so consumers only need to handle absolute move, line, cubic, and close operations.
const ( PathCommandMove PathCommandKind = iota PathCommandLine PathCommandCubic PathCommandClose )
type SvgPathContext ¶
type SvgPathContext struct {
Path []geo.Intersectable
Commands []string
Start *geo.Point
Current *geo.Point
TopLeft *geo.Point
ScaleX float64
ScaleY float64
// contains filtered or unexported fields
}
func NewSVGPathContext ¶
func NewSVGPathContext(tl *geo.Point, sx, sy float64) *SvgPathContext
func (*SvgPathContext) C ¶
func (c *SvgPathContext) C(isLowerCase bool, x1, y1, x2, y2, x3, y3 float64)
func (*SvgPathContext) H ¶
func (c *SvgPathContext) H(isLowerCase bool, x float64)
func (*SvgPathContext) L ¶
func (c *SvgPathContext) L(isLowerCase bool, x, y float64)
func (*SvgPathContext) PathCommands ¶ added in v0.9.0
func (c *SvgPathContext) PathCommands() []PathCommand
PathCommands returns a defensive copy of the absolute typed path commands.
func (*SvgPathContext) PathData ¶
func (c *SvgPathContext) PathData() string
func (*SvgPathContext) StartAt ¶
func (c *SvgPathContext) StartAt(p *geo.Point)
func (*SvgPathContext) V ¶
func (c *SvgPathContext) V(isLowerCase bool, y float64)
func (*SvgPathContext) Z ¶
func (c *SvgPathContext) Z()