Documentation
¶
Overview ¶
Package widget wraps the go-widgets/toolkit `Widget` interface with two write-to-io.Writer conveniences:
widget.Snapshot(w, wg, width, height, theme, label) // SVG envelope + base64 PNG widget.PNG(w, wg, width, height, theme) // raw PNG bytes
Both allocate a fresh width×height RGBA buffer, invoke wg.Draw against it, then serialise. Rendering + serialisation are one function call for the caller — no manual `make([]byte, 4*w*h)` + `wg.Draw()` dance for the common "I want a snapshot" case.
Splitting the toolkit-aware convenience into a subpackage keeps the root svg package dep-free — a consumer that only needs `svg.Snapshot([]byte)` for a home-grown pixel producer does not pull go-widgets/toolkit into its module graph.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PNG ¶
PNG renders wg into a fresh width×height RGBA surface, then writes the surface as a raw PNG (no SVG envelope). Useful when the caller wants the bit-exact pixels + none of the vector wrapper — typical use is a docs-site preprocessor that saves one PNG per widget or a CI regression harness that hashes the byte stream.
func Snapshot ¶
func Snapshot(w io.Writer, wg toolkit.Widget, width, height int, theme *toolkit.Theme, label string) (int, error)
Snapshot renders wg into a fresh width×height RGBA surface via a painter.PixelPainter that wg.Draw writes through, then wraps the result in an SVG envelope via svg.Snapshot. The label lands in the SVG's <title> (pass "" to omit).
Returns the number of bytes written + the first error, mirroring the io.Writer convention.
Types ¶
This section is empty.