dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 285221a9d8e005939c56adaaadd257002fd23a51
parent d80fbc8f14c5fd611d842d0ba74302568a2fe250
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 16 Nov 2022 03:39:37 -0500

cleanup

Diffstat:
Mcmd/art/main.go | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/cmd/art/main.go b/cmd/art/main.go @@ -134,16 +134,18 @@ func HexFromRgbColor(color color.NRGBA) string { } func getClassName(idx int) string { - out := []rune{'a'} + const firstRune = 'a' + const lastRune = 'z' + out := []rune{firstRune} for idx > 0 { idx-- out[0]++ // If first letter reached "z", increment the next one which is not yet at "z" // If we did not find a suitable letter to increment, let's add a new one in the array, and reset all to "a". - if out[0] > 'z' { + if out[0] > lastRune { found := false for i := range out { - if out[i] < 'z' { + if out[i] < lastRune { found = true out[i]++ break @@ -151,12 +153,12 @@ func getClassName(idx int) string { } if !found { // Add a new letter and reset all to "a" - out = append(out, 'a') + out = append(out, firstRune) for i := range out { - out[i] = 'a' + out[i] = firstRune } } - out[0] = 'a' + out[0] = firstRune } } // Reverse slice