figletlib

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SMEqual     = 1
	SMLowLine   = 2
	SMHierarchy = 4
	SMPair      = 8
	SMBigX      = 16
	SMHardBlank = 32
	SMKern      = 64
	SMSmush     = 128
)

smush modes.

View Source
const (
	Reset = "\033[0m"
)

ANSI escape codes for colors.

Variables

View Source
var (
	EmbeddedFonts, _ = fs.Sub(embeddedFonts, "fonts")
)

Functions

func ApplyColor

func ApplyColor(char rune, position float64, totalWidth int, config ColorConfig) string

ApplyColor applies color to a character based on its position and configuration.

func FPrintColoredLines

func FPrintColoredLines(w io.Writer, lines []FigText, hardblank rune, maxwidth int, align string, colorConfig ColorConfig)

FPrintColoredLines prints lines with color support.

func FPrintColoredLinesWithOptions added in v1.3.0

func FPrintColoredLinesWithOptions(w io.Writer, lines []FigText, hardblank rune, maxwidth int, options PrintOptions, colorConfig ColorConfig)

func FPrintColoredMsg

func FPrintColoredMsg(w io.Writer, msg string, f *Font, maxwidth int, s Settings, align string, colorConfig ColorConfig)

FPrintColoredMsg prints a message with color support.

func FPrintColoredMsgWithOptions added in v1.3.0

func FPrintColoredMsgWithOptions(w io.Writer, msg string, f *Font, maxwidth int, s Settings, options PrintOptions, colorConfig ColorConfig)

func FPrintLines

func FPrintLines(w io.Writer, lines []FigText, hardblank rune, maxwidth int, align string)

func FPrintLinesWithOptions added in v1.3.0

func FPrintLinesWithOptions(w io.Writer, lines []FigText, hardblank rune, maxwidth int, options PrintOptions)

func FPrintMsg

func FPrintMsg(w io.Writer, msg string, f *Font, maxwidth int, s Settings, align string)

func FPrintMsgWithOptions added in v1.3.0

func FPrintMsgWithOptions(w io.Writer, msg string, f *Font, maxwidth int, s Settings, options PrintOptions)

func GuessFontsDirectory

func GuessFontsDirectory() string

func PrintColoredLines

func PrintColoredLines(lines []FigText, hardblank rune, maxwidth int, align string, colorConfig ColorConfig)

PrintColoredLines prints lines with color support to stdout.

func PrintColoredLinesWithOptions added in v1.3.0

func PrintColoredLinesWithOptions(lines []FigText, hardblank rune, maxwidth int, options PrintOptions, colorConfig ColorConfig)

func PrintColoredMsg

func PrintColoredMsg(msg string, f *Font, maxwidth int, s Settings, align string, colorConfig ColorConfig)

PrintColoredMsg prints a message with color support to stdout.

func PrintColoredMsgWithOptions added in v1.3.0

func PrintColoredMsgWithOptions(msg string, f *Font, maxwidth int, s Settings, options PrintOptions, colorConfig ColorConfig)

func PrintLines

func PrintLines(lines []FigText, hardblank rune, maxwidth int, align string)

func PrintLinesWithOptions added in v1.3.0

func PrintLinesWithOptions(lines []FigText, hardblank rune, maxwidth int, options PrintOptions)

func PrintMsg

func PrintMsg(msg string, f *Font, maxwidth int, s Settings, align string)

func PrintMsgWithOptions added in v1.3.0

func PrintMsgWithOptions(msg string, f *Font, maxwidth int, s Settings, options PrintOptions)

func SprintMsg

func SprintMsg(msg string, f *Font, maxwidth int, s Settings, align string) string

func SprintMsgWithOptions added in v1.3.0

func SprintMsgWithOptions(msg string, f *Font, maxwidth int, s Settings, options PrintOptions) string

Types

type ColorConfig

type ColorConfig struct {
	Mode       ColorMode
	StartColor RGB
	EndColor   RGB
}

ColorConfig holds color configuration.

type ColorMode

type ColorMode int

ColorMode represents different coloring modes.

const (
	ColorModeNone ColorMode = iota
	ColorModeGradient
	ColorModeRainbow
)

type CombinedLoader

type CombinedLoader struct {
	// contains filtered or unexported fields
}

CombinedLoader can access fonts from multiple sources.

func NewCombinedLoader

func NewCombinedLoader(loaders ...*Loader) *CombinedLoader

func NewCombinedLoaderWithDir

func NewCombinedLoaderWithDir(dir string) *CombinedLoader

NewCombinedLoaderWithDir creates a combined loader with external directory and embedded fonts.

func (*CombinedLoader) FontNamesInDir

func (cl *CombinedLoader) FontNamesInDir() ([]string, error)

func (*CombinedLoader) GetFontByName

func (cl *CombinedLoader) GetFontByName(name string) (*Font, error)

type FigText

type FigText struct {
	// contains filtered or unexported fields
}

func GetLines

func GetLines(msg string, f *Font, maxwidth int, s Settings) []FigText

func (*FigText) Art

func (ft *FigText) Art() [][]rune

func (*FigText) String

func (ft *FigText) String() string

type Font

type Font struct {
	// contains filtered or unexported fields
}

func ReadFontFromBytes

func ReadFontFromBytes(bytes []byte) (*Font, error)

func (*Font) Settings

func (f *Font) Settings() Settings

type FontLoader

type FontLoader interface {
	FontNamesInDir() ([]string, error)
	GetFontByName(name string) (*Font, error)
}

FontLoader interface for loading fonts.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

func NewDirLoader

func NewDirLoader(dir string) *Loader

func NewEmbededLoader

func NewEmbededLoader() *Loader

func NewLoader

func NewLoader(fsys fs.FS) *Loader

func (*Loader) FontNamesInDir

func (t *Loader) FontNamesInDir() ([]string, error)

func (*Loader) GetFontByName

func (t *Loader) GetFontByName(name string) (*Font, error)

func (*Loader) ReadFont

func (t *Loader) ReadFont(filename string) (*Font, error)

type PrintOptions added in v1.3.0

type PrintOptions struct {
	Align      string
	LeftMargin int
}

type RGB

type RGB struct {
	R, G, B uint8
}

RGB represents a color with red, green, blue components (0-255).

func GetRainbowColor

func GetRainbowColor(position float64) RGB

GetRainbowColor returns a rainbow color based on position (0.0 to 1.0).

func HSVtoRGB

func HSVtoRGB(h, s, v float64) RGB

HSVtoRGB converts HSV to RGB.

func ParseColor

func ParseColor(colorStr string) (RGB, error)

ParseColor parses a color string in various formats: - hex: #FF0000, #ff0000, FF0000, ff0000 - rgb: rgb(255,0,0), RGB(255,0,0) - named colors: red, green, blue, etc.

func (RGB) Interpolate

func (start RGB) Interpolate(end RGB, factor float64) RGB

Interpolate creates a color between two colors based on factor (0.0 to 1.0).

func (RGB) ToANSI

func (rgb RGB) ToANSI() string

ToANSI converts RGB to ANSI escape sequence for 24-bit color.

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

func (*Settings) HardBlank

func (s *Settings) HardBlank() rune

func (*Settings) SetRtoL

func (s *Settings) SetRtoL(rtol bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL