color

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 2 Imported by: 2

README

color

Fluent color manipulations for Go

Documentation

Index

Constants

View Source
const ColorModeAuto = "auto"
View Source
const ColorModeDark = "dark"
View Source
const ColorModeExtDark = "dark"
View Source
const ColorModeExtLight = "light"
View Source
const ColorModeExtMediumDark = "medium-dark"
View Source
const ColorModeExtMediumLight = "medium-light"
View Source
const ColorModeLight = "light"
View Source
const HexBlack = "#000000"
View Source
const HexWhite = "#FFFFFF"

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color struct {
	Red     int
	Green   int
	Blue    int
	Opacity float64
}
var Black Color = Color{
	Red:     0,
	Green:   0,
	Blue:    0,
	Opacity: 1.0,
}
var White Color = Color{
	Red:     255,
	Green:   255,
	Blue:    255,
	Opacity: 1.0,
}

func NewColor

func NewColor() Color

func Parse

func Parse(value any) Color

func ParseHex

func ParseHex(value string) Color

func ParseRGB

func ParseRGB(value string) Color

func (Color) ColorMode

func (c Color) ColorMode() string

ColorMode returns "light" if this is a light color, or "dark" if this is a dark color.

func (Color) Contrast

func (c Color) Contrast(percent int) Color

Contrast mixes this color with either black or white. Light colors become darker, and dark colors become lighter. The percentage determines how much to mix the colors.

func (Color) Darken

func (c Color) Darken(percent int) Color

Darken mixes this color with black, moving towards black by the specified percentage.

func (Color) Hex

func (c Color) Hex() string

func (Color) IsDark

func (c Color) IsDark() bool

func (Color) IsEmpty

func (c Color) IsEmpty() bool

IsEmpty returns TRUE if this color is empty. This represents a Nil color

func (Color) IsLight

func (c Color) IsLight() bool

func (Color) Lighten

func (c Color) Lighten(percent int) Color

Lighten mixes this color with white, moving towards white by the specified percentage.

func (Color) Mean

func (c Color) Mean() int

Mean returns the average of the red, green, and blue values.

func (Color) Mix

func (c Color) Mix(other any, percent int) Color

Mix combines this color with another one, moving towards the 'other' color by a specified percentage. 0% will return this color, 100% will return the 'other' color.

func (Color) NotEmpty

func (color Color) NotEmpty() bool

NotEmpty returns TRUE if this color is NOT empty

func (Color) RGBA

func (c Color) RGBA() string

func (Color) String

func (c Color) String() string

func (Color) Text

func (c Color) Text() Color

Text returns either black or white to use as text on top of the current color.

func (Color) TextExt

func (c Color) TextExt() Color

TextExt uses the extended color tools to return a color that is suitable for text on top of the current color. It returns black or white for medium-range colors, and a blended value for very light and very dark colors.

Jump to

Keyboard shortcuts

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