color

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

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

Go to latest
Published: Jun 28, 2020 License: AGPL-3.0 Imports: 2 Imported by: 0

README

Why

This packages is implemented here and not depended on elsewhere because of the computation constraints of rasbperry pi, where this library is expected to run. (float64 vs float32 on 32bit machine)

Valuable Resources

I Want Hue Creative Color Schemes

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Black = HSL{Min, Min, Min}
	Grey  = HSL{Min, Min, Half}
	White = HSL{Min, Min, Max}

	Red         = HSL{Min, Max, Half}
	WarmRed     = HSL{1.0 / 24, Max, Half}
	Orange      = HSL{2.0 / 24, Max, Half}
	WarmYellow  = HSL{3.0 / 24, Max, Half}
	Yellow      = HSL{4.0 / 24, Max, Half}
	CoolYellow  = HSL{5.0 / 24, Max, Half}
	YellowGreen = HSL{6.0 / 24, Max, Half}
	WarmGreen   = HSL{7.0 / 24, Max, Half}
	Green       = HSL{8.0 / 24, Max, Half}
	CoolGreen   = HSL{9.0 / 24, Max, Half}
	GreenCyan   = HSL{10.0 / 24, Max, Half}
	WarmCyan    = HSL{11.0 / 24, Max, Half}
	Cyan        = HSL{12.0 / 24, Max, Half}
	CoolCyan    = HSL{13.0 / 24, Max, Half}
	BlueCyan    = HSL{14.0 / 24, Max, Half}
	CoolBlue    = HSL{15.0 / 24, Max, Half}
	Blue        = HSL{16.0 / 24, Max, Half}
	WarmBlue    = HSL{17.0 / 24, Max, Half}
	Violet      = HSL{18.0 / 24, Max, Half}
	CoolMagenta = HSL{19.0 / 24, Max, Half}
	Magenta     = HSL{20.0 / 24, Max, Half}
	WarmMagenta = HSL{21.0 / 24, Max, Half}
	RedMagenta  = HSL{22.0 / 24, Max, Half}
	CoolRed     = HSL{23.0 / 24, Max, Half}
)
View Source
var (
	Colors = map[string]HSL{
		"Black": Black,
		"White": White,

		"Red":  Red,
		"Cyan": Cyan,
	}

	Schemes = map[string][]HSL{}
)
View Source
var (
	Min  = float32(0.0000001)
	Max  = float32(0.9999999)
	Half = float32(.5)
)

Functions

func Average

func Average(a, b float32) float32

Average does what it says it does.

func AverageWeighted

func AverageWeighted(a, b, weight float32) float32

AverageWeighted is like average but with weighting weight should range from 0 to 1. 0 will favor the first number and 1 will favor the second number.

func BlendHue

func BlendHue(h1, h2 float32) float32

BlendHue will accuratly blend Hues, by finding their midpoint, and accounting for wraping.

func BlendHueWeighted

func BlendHueWeighted(h1, h2, weight float32) float32

BlendHueWeighted will accuratly blend Hues, by finding their midpoint, and accounting for wraping. weight should range from 0 to 1 and is used to favor a hue. 0 will favor the first hue and 1 will favor the hue.

func BlendL

func BlendL(l1, l2 float32) float32

BlendL

Types

type HSL

type HSL struct {
	H, S, L float32
}

func BlendHSL

func BlendHSL(a, b HSL) HSL

func BlendHSLIgnoreBlack

func BlendHSLIgnoreBlack(a, b HSL) HSL

func BlendHSLWeighted

func BlendHSLWeighted(a, b HSL, weight float32) HSL

func (*HSL) SetHue

func (c *HSL) SetHue(h float32)

SetHue will change hue to h (with wrapping).

func (*HSL) SetLightness

func (c *HSL) SetLightness(l float32)

SetLightness will change lightness to l (with bounding).

func (*HSL) SetSaturation

func (c *HSL) SetSaturation(s float32)

SetSaturation will change saturation to s (with bounding).

func (*HSL) ShiftHue

func (c *HSL) ShiftHue(h float32)

ShiftHue will shift hue by h (with wrapping).

func (HSL) ToRGB

func (c HSL) ToRGB() RGB

type HSLA

type HSLA struct {
	HSL
	A float32
}

type RGB

type RGB struct {
	R, G, B float32
}

func RandRGB

func RandRGB(colors []RGB) RGB

func (RGB) ToHSL

func (c RGB) ToHSL() HSL

func (RGB) ToUInt32WGRB

func (c RGB) ToUInt32WGRB() uint32

func (RGB) ToUInt8s

func (c RGB) ToUInt8s() (uint8, uint8, uint8, uint8)

Jump to

Keyboard shortcuts

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