color

package
v0.0.0-...-0158116 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorRegxs = map[ColorFormat]string{
	ColorFormatHEX:  "#[a-fA-F\\d]{6}",
	ColorFormatAHEX: "#[a-fA-F\\d]{8}",
	ColorFormatHEXA: "#[a-fA-F\\d]{8}",
	ColorFormatRGB:  "[Rr][Gg][Bb][\\(](([0-9]{1,3}),\\s*([0-9]{1,3}),\\s*([0-9]{1,3}))[\\)]",
	ColorFormatRGBA: "[Rr][Gg][Bb][Aa][\\(](([0-9]{1,3}),\\s*([0-9]{1,3}),\\s*([0-9]{1,3}),\\s*([0-9.]{1,4}))[\\)]",
}

Functions

func ConvertColorFormat

func ConvertColorFormat(before string, from ColorFormat, to ColorFormat) (after string, err error)

func NewCommand

func NewCommand() *cobra.Command

func ValidateColorFormat

func ValidateColorFormat(color string, format ColorFormat) (flag bool, err error)

Types

type AHEXColorHandler

type AHEXColorHandler struct{}

func (*AHEXColorHandler) Decode

func (h *AHEXColorHandler) Decode(c string) color.RGBA

func (*AHEXColorHandler) Encode

func (h *AHEXColorHandler) Encode(c color.RGBA) string

type ColorFormat

type ColorFormat string
const ColorFormatAHEX ColorFormat = "AHEX" // #FFC7A68D
const ColorFormatHEX ColorFormat = "HEX" // #C7A68D
const ColorFormatHEXA ColorFormat = "HEXA" // #C7A68DFF
const ColorFormatRGB ColorFormat = "RGB" // rgb(199, 166, 141)
const ColorFormatRGBA ColorFormat = "RGBA" // rgba(199, 166, 141, 1)

type ColorHandler

type ColorHandler interface {
	Decode(c string) color.RGBA
	Encode(c color.RGBA) string
}

type HEXAColorHandler

type HEXAColorHandler struct{}

func (*HEXAColorHandler) Decode

func (h *HEXAColorHandler) Decode(c string) color.RGBA

func (*HEXAColorHandler) Encode

func (h *HEXAColorHandler) Encode(c color.RGBA) string

type HEXColorHandler

type HEXColorHandler struct{}

func (*HEXColorHandler) Decode

func (h *HEXColorHandler) Decode(c string) color.RGBA

func (*HEXColorHandler) Encode

func (h *HEXColorHandler) Encode(c color.RGBA) string

type RGBAColorHandler

type RGBAColorHandler struct{}

func (*RGBAColorHandler) Decode

func (h *RGBAColorHandler) Decode(c string) color.RGBA

func (*RGBAColorHandler) Encode

func (h *RGBAColorHandler) Encode(c color.RGBA) string

type RGBColorHandler

type RGBColorHandler struct{}

func (*RGBColorHandler) Decode

func (h *RGBColorHandler) Decode(c string) color.RGBA

func (*RGBColorHandler) Encode

func (h *RGBColorHandler) Encode(c color.RGBA) string

Jump to

Keyboard shortcuts

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