render

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package render produces SVG button faces for Stream Deck keys.

Index

Constants

View Source
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 ContentFitTransform

func ContentFitTransform(d string, tx, ty, tw, th float64) string

ContentFitTransform returns an SVG transform string that scales and centers a path's actual content into a target rectangle.

func FormatCountdown

func FormatCountdown(seconds float64) string

FormatCountdown formats seconds into a human-readable countdown.

func IsValidHexColor

func IsValidHexColor(s string) bool

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

func PathBBox(d string) BBox

PathBBox computes the approximate bounding box of an SVG path's d attribute. Includes bezier control points (conservative estimate).

func (BBox) Height

func (b BBox) Height() float64

Height returns the bounding box height.

func (BBox) Width

func (b BBox) Width() float64

Width returns the bounding box width.

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 ProviderGlyph

type ProviderGlyph struct {
	// ViewBox is the SVG viewBox attribute for the glyph path.
	ViewBox string
	// D is the SVG path `d` attribute for the glyph geometry.
	D string
	// 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL