1package main
2
3import (
4 "fmt"
5 "math/rand/v2"
6
7 "charm.land/lipgloss/v2"
8 "github.com/charmbracelet/crush/internal/ui/logo"
9 "github.com/charmbracelet/x/exp/slice"
10)
11
12func renderLetterforms(stretch bool) string {
13 letterFuncs := []func(bool) string{
14 logo.LetterH,
15 logo.LetterY,
16 logo.LetterYAlt,
17 logo.LetterP,
18 logo.LetterE,
19 logo.LetterEAlt,
20 logo.LetterR,
21 logo.LetterC,
22 logo.LetterR,
23 logo.LetterU,
24 logo.LetterSAlt,
25 logo.LetterH,
26 }
27
28 // Which letter to stretch, if we're stretching.
29 stretchIndex := -1
30 if stretch {
31 stretchIndex = rand.IntN(len(letterFuncs))
32 }
33
34 // Build letterforms.
35 letterforms := make([]string, len(letterFuncs))
36 for i, f := range letterFuncs {
37 letterforms[i] = f(stretch && i == stretchIndex)
38 }
39 letterforms = slice.Intersperse(letterforms, " ")
40
41 return lipgloss.JoinHorizontal(lipgloss.Top, letterforms...)
42}
43
44func main() {
45 fmt.Println(renderLetterforms(false))
46 for range 10 {
47 fmt.Println(renderLetterforms(true))
48 }
49}