Documentation
¶
Index ¶
- func CMYKToRGB(c float64, m float64, y float64, k float64) (r float64, g float64, b float64)
- func HSLToRGB(h float64, s float64, l float64) (r float64, g float64, b float64)
- func HSVToRGB(h float64, s float64, v float64) (r float64, g float64, b float64)
- func HTMLToRGB(h string) (r float64, g float64, b float64)
- func HexToRGB(h string) (r float64, g float64, b float64)
- func HueToRGB(p float64, q float64, t float64) float64
- func RGBToCMYK(r float64, g float64, b float64) (c float64, m float64, y float64, k float64)
- func RGBToHSL(r float64, g float64, b float64) (h float64, s float64, l float64)
- func RGBToHSV(r float64, g float64, b float64) (h float64, s float64, v float64)
- func RGBToHTML(r float64, g float64, b float64) (h string)
- func RGBToHex(r float64, g float64, b float64) string
- type Color
- func NewCMYK(c float64, m float64, y float64, k float64) Color
- func NewCMYKA(c float64, m float64, y float64, k float64, a float64) Color
- func NewHSL(h float64, s float64, l float64) Color
- func NewHSLA(h float64, s float64, l float64, a float64) Color
- func NewHSV(h float64, s float64, v float64) Color
- func NewHSVA(h float64, s float64, v float64, a float64) Color
- func NewHTML(color string) Color
- func NewHTMLA(color string, a float64) Color
- func NewHex(color string) Color
- func NewHexA(color string, a float64) Color
- func NewRGB(r float64, g float64, b float64) Color
- func NewRGBA(r float64, g float64, b float64, a float64) Color
- func (c Color) AdjustHue(degrees float64) Color
- func (c Color) Brighten(percent float64) Color
- func (c Color) CMYK() (float64, float64, float64, float64)
- func (c Color) Complement() Color
- func (c Color) Contrast(color Color) float64
- func (c Color) Darken(percent float64) Color
- func (c Color) Desaturate(percent float64) Color
- func (c Color) Foreground() Color
- func (c Color) Grayscale() Color
- func (c Color) HSL() (float64, float64, float64)
- func (c Color) HSLA() (float64, float64, float64, float64)
- func (c Color) HSV() (float64, float64, float64)
- func (c Color) HSVA() (float64, float64, float64, float64)
- func (c Color) HTML() string
- func (c Color) Hex() string
- func (c Color) Hue() float64
- func (c Color) Invert() Color
- func (c Color) IsDark() bool
- func (c Color) IsLight() bool
- func (c Color) Lighten(percent float64) Color
- func (c Color) Lightness() float64
- func (c Color) Luminanace() float64
- func (c Color) LuminanaceWCAG() float64
- func (c Color) Mix(color Color, weight float64) Color
- func (c Color) RGB() (float64, float64, float64)
- func (c Color) RGBA() (float64, float64, float64, float64)
- func (c Color) Saturate(percent float64) Color
- func (c Color) Saturation() float64
- func (c Color) Shade(percent float64) Color
- func (c Color) Tint(percent float64) Color
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CMYKToRGB ¶
CMYKToRGB converts the color from CMYK to RGB with a lossy algorithm.
reference: https://www.ginifab.com.tw/tools/colors/js/colorconverter.js
func HSLToRGB ¶
HSLToRGB converts the color from HSL to RGB with a lossy algorithm.
reference: https://www.ginifab.com.tw/tools/colors/js/colorconverter.js
func HSVToRGB ¶
HSVToRGB converts the color from HSV to RGB with a lossy algorithm.
reference: https://www.rapidtables.com/convert/color/hsv-to-rgb.html
func HTMLToRGB ¶
HTMLToRGB converts the color from HTML color name or a Hex string (can be `#` prefixed or either a 3 characters shorthand) to RGB.
func HexToRGB ¶
HexToRGB converts the Hex string (can be `#` prefixed or either a 3 characters shorthand) to RGB.
func HueToRGB ¶
HueToRGB converts the color from Hue to RGB.
reference: https://www.ginifab.com.tw/tools/colors/js/colorconverter.js
func RGBToCMYK ¶
RGBToCMYK converts the color from RGB to CMYK with a lossy algorithm.
reference: https://www.ginifab.com.tw/tools/colors/js/colorconverter.js
func RGBToHSL ¶
RGBToHSL converts the color from RGB to HSL with a lossy algorithm.
reference: https://www.ginifab.com.tw/tools/colors/js/colorconverter.js
func RGBToHSV ¶
RGBToHSV converts the color from RGB to HSV with a lossy algorithm.
reference: https://www.ginifab.com.tw/tools/colors/js/colorconverter.js
Types ¶
type Color ¶
Color represents a manipulable color.
func (Color) AdjustHue ¶
AdjustHue rotates the Hue angle of the color based on HSL mode, it still goes clockwise if the value was set over than 360 degree.
func (Color) Brighten ¶
Brighten increases the brightness of the color. (`0.5` as `50%`)
reference: https://github.com/ozdemirburak/iris
func (Color) Complement ¶
Complement returns the complementary color of the current color, same as `AdjustHue(180)`.
func (Color) Contrast ¶
Contrast returns the Contrast of the current color based on the WCAG Luminance algorithm.
func (Color) Darken ¶
Darken decreases the brightness of the color based on HSL mode. (`0.5` as `50%`)
func (Color) Desaturate ¶
Desaturate decreases the saturation of the color based on HSL mode. (`0.5` as `50%`)
func (Color) Foreground ¶
Foreground returns suggested foreground color by calculating the color luminance, it returns a white color when the color is dark, vise versa.
func (Color) HTML ¶
HTML returns a `#` prefixed Hex string or the HTML color name (like: `red`, `yellow`) if it had one. It returns a format with `rgba()` if the color comes with a alpha channel.
func (Color) Invert ¶
Invert returns the opposite color that based on the RGB color map (it's not a complementary color).
func (Color) IsDark ¶
IsDark returns true if the color is a dark scheme, it might not be the same as what human eyes can see.
func (Color) IsLight ¶
IsLight returns true if the color is a light scheme, it might not be the same as what human eyes can see.
func (Color) Lighten ¶
Lighten increases the brightness of the color based on HSL mode. (`0.5` as `50%`)
func (Color) Lightness ¶
Lightness returns the Lightness of the current color based on the HSL algorithm.
func (Color) Luminanace ¶
Luminanace returns the Luminance of the current color.
reference: https://en.wikipedia.org/wiki/Relative_luminance
reference: https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
func (Color) LuminanaceWCAG ¶
LuminanaceWCAG returns the Luminance of the the current color based on the WCAG 2.0 algorithm.
reference: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
reference: https://medium.com/dev-channel/using-sass-to-automatically-pick-text-colors-4ba7645d2796
func (Color) Mix ¶
Mix mixs both color with the specified weight of the second color. (`0.5` as `50%`)
func (Color) Saturate ¶
Saturate increases the saturation of the color based on HSL mode. (`0.5` as `50%`)
func (Color) Saturation ¶
Saturation returns the percentage of the current color saturation based on the HSL algorithm.












