mirror of
https://github.com/KevinMidboe/motdGO.git
synced 2025-10-29 17:50:24 +00:00
add truecolor support
This commit is contained in:
15
char.go
15
char.go
@@ -2,7 +2,6 @@ package figlet4go
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
// Represents a single ascii character
|
||||
@@ -10,7 +9,7 @@ type asciiChar struct {
|
||||
// Slice with the lines of the Char
|
||||
Lines []string
|
||||
// Color of the char
|
||||
Color color.Attribute
|
||||
Color Color
|
||||
}
|
||||
|
||||
// Creates a new ascii character
|
||||
@@ -28,9 +27,13 @@ func newAsciiChar(font *font, char rune) (*asciiChar, error) {
|
||||
|
||||
// Return a line of the char as string with color if set
|
||||
func (char *asciiChar) GetLine(index int) string {
|
||||
if char.Color != 0 {
|
||||
colorFunc := color.New(char.Color).SprintFunc()
|
||||
return colorFunc(char.Lines[index])
|
||||
prefix := ""
|
||||
suffix := ""
|
||||
|
||||
if char.Color != nil {
|
||||
prefix = char.Color.getPrefix()
|
||||
suffix = char.Color.getSuffix()
|
||||
}
|
||||
return char.Lines[index]
|
||||
|
||||
return prefix + char.Lines[index] + suffix
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user