mini

package
v0.0.0-...-e6657e5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mini provides utilities for parsing and manipulating Minecraft text colors and styles. It includes functions for parsing strings with embedded style information, modifying styles, and creating gradient effects. It also provides functions for parsing color names and hex codes, and for linear interpolation of colors.

Credits to the partial Go port of MiniMessage (https://docs.advntr.dev/minimessage/index.html) by https://github.com/emortalmc/GateProxy/blob/main/minimessage/minimessage.go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromName

func FromName(name string) (color.Color, error)

FromName takes a string as input and returns a `color.Color` object. It iterates over the named colors and returns the one that matches the input string.

func Gradient

func Gradient(content string, style c.Style, colors ...color.RGB) *c.Text

Gradient takes a string, a style, and a variable number of colors as input and returns a `c.Text` object. It creates a gradient effect by interpolating between the input colors based on their position in the input string.

func LerpColor

func LerpColor(t float64, colors ...color.RGB) color.Color

LerpColor takes a float and a variable number of colors as input and returns a `color.Color` object. It interpolates between the input colors based on the input float.

func Parse

func Parse(mini string) *c.Text

Parse takes a string as input and returns a `c.Text` object. It splits the input string by "<", then further splits each substring by ">". It modifies the style based on the key (the part before ">") and appends a new text component with the modified style and content (the part after ">").

func ParseColor

func ParseColor(name string) (color.Color, error)

ParseColor takes a string as input and returns a `color.Color` object. It checks if the input string starts with "#". If it does, it tries to parse it as a hex color. If it doesn't, it tries to find a named color that matches the input string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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