Documentation ¶
Overview ¶
Utilities for parsing and manipulating colors.
Index ¶
- Constants
- func Equals(first interface{}, second interface{}) bool
- func HslToRgb(hue float64, saturation float64, lightness float64) (uint8, uint8, uint8)
- func HsvToRgb(hue float64, saturation float64, value float64) (uint8, uint8, uint8)
- func RgbToHsl(r float64, g float64, b float64) (float64, float64, float64)
- type Color
- func AdjustHue(in interface{}, degrees float64) (Color, error)
- func Darken(in interface{}, percent int) (Color, error)
- func Desaturate(in interface{}, percent int) (Color, error)
- func KelvinToColor(kelvin int) (color Color)
- func Lighten(in interface{}, percent int) (Color, error)
- func Mix(first interface{}, second interface{}) (Color, error)
- func MixN(first interface{}, second interface{}, weight float64) (Color, error)
- func MustParse(value interface{}) Color
- func Parse(value interface{}) (Color, error)
- func Saturate(in interface{}, percent int) (Color, error)
- func (self Color) Equals(other interface{}) bool
- func (self Color) HSI() (float64, float64, float64)
- func (self Color) HSL() (float64, float64, float64)
- func (self Color) HSV() (float64, float64, float64)
- func (self Color) MarshalJSON() ([]byte, error)
- func (self Color) NativeRGBA() (c color.RGBA)
- func (self Color) RGBA() (uint32, uint32, uint32, uint32)
- func (self Color) RGBA255() (uint8, uint8, uint8, uint8)
- func (self Color) String() string
- func (self Color) StringHSLA() string
- func (self Color) StringRGBA() string
Constants ¶
const ( Invalid lmodel = iota HSI HSL HSV )
Variables ¶
This section is empty.
Functions ¶
func Equals ¶
func Equals(first interface{}, second interface{}) bool
Return whether two colors are equivalent in the 24-bit RGB (RGB255) color space.
func HslToRgb ¶
Given HSL values (where hue is given in degrees (out of 360°), saturation and lightness are [0, 1]), return the corresponding RGB values (where each value is [0, 255]).
Types ¶
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
func Darken ¶
Darken the given color by a certain percent. Consistent with the results of the Sass darken() function.
func Desaturate ¶ added in v1.7.48
Desaturate the given color by a certain percent. Consistent with the results of the Sass desaturate() function.
func KelvinToColor ¶ added in v1.8.13
Takes a color temperature in degrees Kelvin and returns a valid Color for that temperature. This function works best between 1000K and 40000K.
func Lighten ¶
Lighten the given color by a certain percent. Consistent with the results of the Sass lighten() function.
func MixN ¶ added in v1.7.48
Mix two colors, producing a third. The weight value specifies how much of the first color should be included. Consistent with the results of the Sass mix() function.
func MustParse ¶
func MustParse(value interface{}) Color
Parse the given value into a Color or panic.
func Saturate ¶ added in v1.7.48
Saturate the given color by a certain percent. Consistent with the results of the Sass saturate() function.
func (Color) Equals ¶
Return whether the given color is equal to this one in the 24-bit RGB (RGB255) color space
func (Color) HSI ¶
Return the current color as hue (out of 360°), saturation [0, 1], and intensity [0, 1].
func (Color) HSL ¶
Return the current color as hue (out of 360°), saturation [0, 1], and lightness [0, 1].
func (Color) HSV ¶
Return the current color as hue (out of 360°), saturation [0, 1], and value [0, 1].
func (Color) MarshalJSON ¶ added in v1.8.74
func (Color) NativeRGBA ¶ added in v1.8.73
Return the color as a color.RGBA struct.
func (Color) RGBA ¶
Return the current color as a 32-bit uint quad, implementing the color.Color interface.