pulse

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package pulse provides pulse animation rendering for clog.

Index

Constants

View Source
const (
	// Speed is the number of full oscillation cycles per second.
	Speed = 0.5

	// TickRate is the repaint interval when pulse is active (~30fps).
	TickRate = 33 * time.Millisecond
)

Variables

This section is empty.

Functions

func DefaultGradient

func DefaultGradient() []gradient.ColorStop

DefaultGradient returns a three-stop gradient for pulse effects: pastel light blue fading through light green to white.

func Text

func Text(text string, phase float64, stops []gradient.ColorStop) string

Text renders all characters of text with a single gradient-interpolated foreground color, creating an animated pulse when called with advancing phase values. Spaces are passed through unstyled.

func TextCached

func TextCached(
	text string,
	phase float64,
	stops []gradient.ColorStop,
	cache *Cache,
) string

TextCached is like Text but reuses the cached style when the interpolated hex color matches the previous call. Pass a persistent *Cache across frames to avoid style allocations when the color is stable between ticks.

Types

type Cache

type Cache struct {
	Hex   string
	Style lipgloss.Style
}

Cache holds the last-used hex color and its corresponding lipgloss style, allowing TextCached to skip style creation when the color hasn't changed between frames.

type Option

type Option func(*Style)

Option configures a Style.

func WithGradient

func WithGradient(stops ...gradient.ColorStop) Option

WithGradient sets custom gradient color stops.

func WithSpeed

func WithSpeed(speed float64) Option

WithSpeed sets the number of full oscillation cycles per second. Values <= 0 are a no-op (keep default).

type Style

type Style struct {
	Gradient []gradient.ColorStop
	Speed    float64
}

Style holds resolved pulse configuration.

func ApplyOptions

func ApplyOptions(opts []Option) Style

ApplyOptions applies options over DefaultStyle and returns the resolved config.

func DefaultStyle

func DefaultStyle() Style

DefaultStyle returns the default pulse configuration.

Jump to

Keyboard shortcuts

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