@@ -17,9 +17,9 @@ import (
20− charCyclingFPS = time.Second / 8 // 8 FPS for better CPU efficiency
20+ charCyclingFPS = time.Second / 22
21− colorCycleFPS = time.Second / 3 // 3 FPS
21+ colorCycleFPS = time.Second / 5
22− maxCyclingChars = 60 // 60 characters
22+ maxCyclingChars = 60
@@ -29,7 +29,7 @@ var (
31func init() {
31func init() {
32− // Pre-populate the character pool to avoid runtime random generation
32+ // Pre-populate the character pool to avoid runtime random generation.
33 for i := range charRunePool {
33 for i := range charRunePool {
34 charRunePool[i] = charRunes[rand.IntN(len(charRunes))]
34 charRunePool[i] = charRunes[rand.IntN(len(charRunes))]
@@ -52,7 +52,7 @@ type cyclingChar struct {
54func (c cyclingChar) randomRune() rune {
54func (c cyclingChar) randomRune() rune {
55− // Use pre-generated pool instead of runtime random generation
55+ // Use pre-generated pool instead of runtime random generation.
56 poolIndex = (poolIndex + 1) % len(charRunePool)
56 poolIndex = (poolIndex + 1) % len(charRunePool)
57 return charRunePool[poolIndex]
57 return charRunePool[poolIndex]
@@ -139,13 +139,13 @@ func New(cyclingCharsSize uint, label string, opts ...animOption) Animation {
139 // color the cycling characters with a gradient ramp.
139 // color the cycling characters with a gradient ramp.
140 const minRampSize = 3
140 const minRampSize = 3
141 if n >= minRampSize {
141 if n >= minRampSize {
142− // Optimized: single capacity allocation for color cycling
142+ // Optimized: single capacity allocation for color cycling.
143 c.ramp = make([]lipgloss.Style, 0, n*2)
143 c.ramp = make([]lipgloss.Style, 0, n*2)
144 ramp := makeGradientRamp(n)
144 ramp := makeGradientRamp(n)
145 for _, color := range ramp {
145 for _, color := range ramp {
146 c.ramp = append(c.ramp, lipgloss.NewStyle().Foreground(color))
146 c.ramp = append(c.ramp, lipgloss.NewStyle().Foreground(color))
148− // Create reversed copy for seamless color cycling
148+ // Create reversed copy for seamless color cycling.
149 reversed := make([]lipgloss.Style, len(c.ramp))
149 reversed := make([]lipgloss.Style, len(c.ramp))
150 for i, style := range c.ramp {
150 for i, style := range c.ramp {
151 reversed[len(c.ramp)-1-i] = style
151 reversed[len(c.ramp)-1-i] = style
@@ -263,7 +263,7 @@ func (a anim) View() tea.View {
263 b strings.Builder
263 b strings.Builder
266− // Optimized capacity calculation to reduce allocations
266+ // Optimized capacity calculation to reduce allocations.
268 bytesPerChar = 15 // Reduced estimate for ANSI styling
268 bytesPerChar = 15 // Reduced estimate for ANSI styling
269 bufferSize = 30 // Reduced safety margin
269 bufferSize = 30 // Reduced safety margin
@@ -271,7 +271,7 @@ func (a anim) View() tea.View {
271 estimatedCap := len(a.cyclingChars)*bytesPerChar + len(a.labelChars)*bytesPerChar + bufferSize
271 estimatedCap := len(a.cyclingChars)*bytesPerChar + len(a.labelChars)*bytesPerChar + bufferSize
272 b.Grow(estimatedCap)
272 b.Grow(estimatedCap)
274− // Render cycling characters with gradient (if available)
274+ // Render cycling characters with gradient (if available).
275 for i, c := range a.cyclingChars {
275 for i, c := range a.cyclingChars {
276 if len(a.ramp) > i {
276 if len(a.ramp) > i {
277 b.WriteString(a.ramp[i].Render(string(c.currentValue)))
277 b.WriteString(a.ramp[i].Render(string(c.currentValue)))
@@ -280,7 +280,7 @@ func (a anim) View() tea.View {
283− // Render label characters and ellipsis
283+ // Render label characters and ellipsis.
284 if len(a.labelChars) > 1 {
284 if len(a.labelChars) > 1 {
285 textStyle := t.S().Text
285 textStyle := t.S().Text
286 for _, c := range a.labelChars {
286 for _, c := range a.labelChars {