colorx

package
v0.0.0-...-152b8de Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLength = errors.New("invalid length")

Functions

func FormatHex

func FormatHex(c color.Color) string

FormatHex formats the given color.Color as a hex code

func ParseHex

func ParseHex(text string) (color.Color, error)

ParseHex parses the given hex code as a color.NRGBA

Types

type Hex

type Hex struct {
	color.Color
}

Hex is a helper struct that wraps a color and satisfies encoding.TextMarshaler, encoding.TextUnmarshaler, and fmt.Stringer.

func (*Hex) MarshalText

func (h *Hex) MarshalText() ([]byte, error)

MarshalText encodes a color as hex.

func (*Hex) String

func (h *Hex) String() string

MarshalText encodes a color as hex.

func (*Hex) UnmarshalText

func (h *Hex) UnmarshalText(text []byte) error

UnmarshalText parses the given hex code.

Jump to

Keyboard shortcuts

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