Documentation
¶
Overview ¶
Package render produces SVG button faces for Stream Deck keys.
Index ¶
- Constants
- func ContentFitBBoxTransform(bb BBox, tx, ty, tw, th float64) string
- func ContentFitGlyphTransform(g *ProviderGlyph, tx, ty, tw, th float64) string
- func ContentFitTransform(d string, tx, ty, tw, th float64) string
- func FormatCountdown(seconds float64) string
- func IsValidHexColor(s string) bool
- func RenderButton(in ButtonInput) string
- func RenderLoading(glyph *ProviderGlyph, fillColor, bgColor, fgColor string, showBorder *bool) string
- type BBox
- type ButtonInput
- type GlyphPath
- type ProviderGlyph
Constants ¶
const Canvas = 144
Canvas is the edge length (in SVG user units) of a Stream Deck button face.
Variables ¶
This section is empty.
Functions ¶
func ContentFitBBoxTransform ¶ added in v0.7.1
ContentFitBBoxTransform returns an SVG transform string that scales and centers a bounding box into a target rectangle.
func ContentFitGlyphTransform ¶ added in v0.7.1
func ContentFitGlyphTransform(g *ProviderGlyph, tx, ty, tw, th float64) string
ContentFitGlyphTransform returns an SVG transform string that scales and centers a provider glyph into a target rectangle. Multi-path glyphs prefer their declared viewBox so source stroke widths and arrowheads keep the same visual framing as the original SVG.
func ContentFitTransform ¶
ContentFitTransform returns an SVG transform string that scales and centers a path's actual content into a target rectangle.
func FormatCountdown ¶
FormatCountdown formats seconds into a human-readable countdown.
func IsValidHexColor ¶
IsValidHexColor checks if a string is a valid hex color.
func RenderButton ¶
func RenderButton(in ButtonInput) string
RenderButton produces an SVG string for a Stream Deck key face.
func RenderLoading ¶
func RenderLoading(glyph *ProviderGlyph, fillColor, bgColor, fgColor string, showBorder *bool) string
RenderLoading produces a loading face with just the provider glyph.
Types ¶
type BBox ¶
type BBox struct {
MinX, MinY, MaxX, MaxY float64
}
BBox is an axis-aligned bounding box.
func PathBBox ¶
PathBBox computes the approximate bounding box of an SVG path's d attribute. Includes bezier control points (conservative estimate).
func ViewBoxBBox ¶ added in v0.7.1
ViewBoxBBox parses an SVG viewBox into a BBox.
type ButtonInput ¶
type ButtonInput struct {
Label string
Value string
Subvalue string
Ratio *float64 // nil = reference card
Direction string // "up"|"down"|"right"|"left"
Fill string // hex — meter fill
Bg string // hex
Fg string // hex
Border *bool // nil = true
ValueSize string // "small"|"medium"|"large"
SubvalueSize string
Stale *bool
Glyph *ProviderGlyph
GlyphMode string // "watermark"|"centered"|"corner"|"none"
ShowGlyph *bool // nil = true
// SmartContrast enables the dual-layer contrast auto-flip for text
// and the watermark glyph's back layer. The zero value (false)
// renders fg exactly as provided — callers opt in per-render.
// Application-level defaults live in GlobalSettings.SmartContrast
// (default on), and main.go threads that runtime decision into
// this field at each render site.
SmartContrast bool
}
ButtonInput configures a button face render.
type GlyphPath ¶ added in v0.7.1
type GlyphPath struct {
// D is the SVG path data for this glyph element.
D string
// Stroke renders this path as a stroked outline instead of a fill.
Stroke bool
// StrokeWidth preserves source SVG stroke widths for stroked paths.
StrokeWidth float64
}
GlyphPath is one path in a provider glyph.
type ProviderGlyph ¶
type ProviderGlyph struct {
// ViewBox is the SVG viewBox attribute for the glyph path.
ViewBox string
// Markup holds raw inner SVG elements for glyphs that are not plain
// path-only marks. Elements should use currentColor for brand-colored
// fills/strokes so each render layer can recolor them safely.
Markup string
// D is the SVG path `d` attribute for the glyph geometry.
D string
// Paths holds multi-path glyph geometry. When set, Paths is rendered
// instead of D so mixed fill/stroke logos can keep their source shape.
Paths []GlyphPath
// Stroke renders the glyph as an outline (stroke + fill:none +
// vector-effect:non-scaling-stroke) instead of the default filled
// silhouette — lets outline marks (Tabler, Lucide, etc.) sit
// alongside solid brand glyphs without reshaping each path to a
// closed fill region.
Stroke bool
}
ProviderGlyph holds an SVG path for a provider logo.