Documentation ¶
Index ¶
- Variables
- func ContrastColor(c color.Color) color.RGBA
- func Darken(c color.Color, amount float32) color.RGBA
- func Desaturate(c color.Color, amount float32) color.RGBA
- func HSLtoRGBF32(h, s, l float32) (r, g, b float32)
- func Highlight(c color.Color, amount float32) color.RGBA
- func HueToRGBF32(p, q, t float32) float32
- func IsDark(c color.Color) bool
- func IsLight(c color.Color) bool
- func Lighten(c color.Color, amount float32) color.RGBA
- func RGBtoHSLF32(r, g, b float32) (h, s, l float32)
- func Samelight(c color.Color, amount float32) color.RGBA
- func Saturate(c color.Color, amount float32) color.RGBA
- func Spin(c color.Color, amount float32) color.RGBA
- type HSL
Constants ¶
This section is empty.
Variables ¶
var Model = color.ModelFunc(model)
Model is the standard color.Model that converts colors to HSL.
Functions ¶
func ContrastColor ¶
ContrastColor returns the color that should be used to contrast this color (white or black), based on the result of IsLight.
func Darken ¶
Darken returns a color that is darker by the given absolute HSL lightness amount (0-100, ranges enforced)
func Desaturate ¶
Desaturate returns a color that is less saturated by the given absolute HSL saturation amount (0-100, ranges enforced)
func HSLtoRGBF32 ¶ added in v0.0.7
HSLtoRGBF32 converts HSL values to RGB float32 0..1 values (non alpha-premultiplied) -- based on https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion, https://www.w3.org/TR/css-color-3/ and github.com/lucasb-eyer/go-colorful
func Highlight ¶
Highlight returns a color that is lighter or darker by the given absolute HSL lightness amount (0-100, ranges enforced), making the color darker if it is light (tone >= 0.5) and lighter otherwise. It is the opposite of Samelight.
func HueToRGBF32 ¶ added in v0.0.7
func IsLight ¶
IsLight returns whether the given color is light (has an HSL lightness greater than or equal to 0.6)
func Lighten ¶
Lighten returns a color that is lighter by the given absolute HSL lightness amount (0-100, ranges enforced)
func RGBtoHSLF32 ¶ added in v0.0.7
RGBtoHSLF32 converts RGB 0..1 values (non alpha-premultiplied) to HSL -- based on https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion, https://www.w3.org/TR/css-color-3/ and github.com/lucasb-eyer/go-colorful
func Samelight ¶
Samelight returns a color that is lighter or darker by the given absolute HSL lightness amount (0-100, ranges enforced), making the color lighter if it is light (tone >= 0.5) and darker otherwise. It is the opposite of Highlight.
Types ¶
type HSL ¶
type HSL struct { // the hue of the color H float32 `min:"0" max:"360" step:"5"` // the saturation of the color S float32 `min:"0" max:"1" step:"0.05"` // the luminance (lightness) of the color L float32 `min:"0" max:"1" step:"0.05"` // the transparency of the color A float32 `min:"0" max:"1" step:"0.05"` }
HSL represents the Hue [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color using float32 values In general the Alpha channel is not used for HSL but is maintained so it can be used to fully represent an RGBA color value. When converting to RGBA, alpha multiplies the RGB components.
func FromColor ¶
FromColor constructs a new HSL color from a standard color.Color
func New ¶
New returns a new HSL representation for given parameters: hue = 0..360 saturation = 0..1 lightness = 0..1 A is automatically set to 1
func (HSL) RGBA ¶
Implements the color.Color interface Performs the premultiplication of the RGB components by alpha at this point.