component

package
v0.0.0-...-6fbc30b Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Default       = CharType("Default")
	Obfuscated    = CharType("Obfuscated")
	Bold          = CharType("Bold")
	StrikeThrough = CharType("StrikeThrough")
	Underline     = CharType("Underline")
	Italic        = CharType("Italic")
	Reset         = CharType("Reset")
)
View Source
const TextTag = '§'

Variables

View Source
var (
	DefaultColor = White
	Black        = &color.RGBA{R: 0, G: 0, B: 0, A: 255}
	Gray         = &color.RGBA{R: 170, G: 170, B: 170, A: 255}
	DarkGray     = &color.RGBA{R: 85, G: 85, B: 85, A: 255}
	White        = &color.RGBA{R: 255, G: 255, B: 255, A: 255}
)
View Source
var ColorMapping = map[rune]*color.RGBA{
	'0': Black,
	'1': {R: 0, G: 0, B: 170, A: 255},
	'2': {R: 0, G: 170, B: 0, A: 255},
	'3': {R: 0, G: 170, B: 170, A: 255},
	'4': {R: 170, G: 0, B: 0, A: 255},
	'5': {R: 170, G: 0, B: 170, A: 255},
	'6': {R: 255, G: 170, B: 0, A: 255},
	'7': Gray,
	'8': DarkGray,
	'9': {R: 85, G: 85, B: 255, A: 255},
	'a': {R: 85, G: 255, B: 85, A: 255},
	'b': {R: 85, G: 255, B: 255, A: 255},
	'c': {R: 255, G: 85, B: 85, A: 255},
	'd': {R: 255, G: 85, B: 255, A: 255},
	'e': {R: 255, G: 255, B: 85, A: 255},
	'f': White,
}

ColorMapping Bukkit/Minecraft color codes mapped to Go's color.RGBA

View Source
var FormatMapping = map[rune]CharType{
	'k': Obfuscated,
	'l': Bold,
	'm': StrikeThrough,
	'n': Underline,
	'o': Italic,
	'r': Reset,
}

Functions

This section is empty.

Types

type Char

type Char struct {
	// 字符类型
	Type CharType
	// 字符颜色
	Color *color.RGBA
	// 字符
	Content rune
}

type CharType

type CharType string

type Component

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

func NewComponent

func NewComponent(s string) *Component

func (*Component) Compute

func (c *Component) Compute(suggestCtx *gg.Context, boldOffset float64) (nameWidth float64, maxHeight float64)

Compute char list width with suggestCtx, returns (nameWidth, startY)

func (*Component) Parse

func (c *Component) Parse() []*Char

Jump to

Keyboard shortcuts

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