Skip to content

Commit 3d4dcd0

Browse files
committed
app/UI: make the gradient move in the opposite way
Make the gradient move to the right, instead of to the left - it looks more pleasing. Unfortunately, it required a few more computations related to modular arithmetic on negative numbers.
1 parent ac27f96 commit 3d4dcd0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/ui.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,9 @@ func hsvToRGB(h, s, v float64) (uint8, uint8, uint8) {
461461
func renderGradientHeader(text string, t float64) string {
462462
var b strings.Builder
463463
for i, ch := range text {
464-
progress := math.Mod(float64(i)/100+t*0.07, 1.0)
464+
progress := float64(i)/100 + t*-0.07
465+
progress += math.Ceil(math.Abs(progress))
466+
progress = math.Mod(progress, 1.0)
465467
hue := progress * 360.0
466468
// lower brightness for less intense colors
467469
r, g, c := hsvToRGB(hue, 0.8, 0.5)
@@ -479,7 +481,9 @@ func generateBanner(t float64) string {
479481
var b strings.Builder
480482
for _, line := range bannerLines {
481483
for i, ch := range line {
482-
progress := math.Mod(float64(i)/float64(len(line))+t*0.07+0.5, 1.0)
484+
progress := float64(i)/float64(len(line)) + t*-0.07 + 0.5
485+
progress += math.Ceil(math.Abs(progress))
486+
progress = math.Mod(progress, 1.0)
483487
hue := progress * 360.0
484488
r, g, cc := hsvToRGB(hue, 1.0, 1.0)
485489
colorStr := fmt.Sprintf("#%02X%02X%02X", r, g, cc)

0 commit comments

Comments
 (0)