dkforest

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

commit d80fbc8f14c5fd611d842d0ba74302568a2fe250
parent be1bd10e22da7dec0f33d75407386f07f91f4cae
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 16 Nov 2022 03:36:45 -0500

cleanup

Diffstat:
Mcmd/art/main.go | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/cmd/art/main.go b/cmd/art/main.go @@ -136,7 +136,11 @@ func HexFromRgbColor(color color.NRGBA) string { func getClassName(idx int) string { out := []rune{'a'} for idx > 0 { - if out[0] == 'z' { + 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' { found := false for i := range out { if out[i] < 'z' { @@ -146,15 +150,14 @@ func getClassName(idx int) string { } } if !found { + // Add a new letter and reset all to "a" out = append(out, 'a') for i := range out { out[i] = 'a' } } - out[0] = 'a' - 1 + out[0] = 'a' } - out[0]++ - idx-- } // Reverse slice for i, j := 0, len(out)-1; i < j; i, j = i+1, j-1 {