Documentation ¶
Overview ¶
Package colorconv provide conversion of color to HSL, HSV and hex value. All the conversion methods is based on the website: https://www.rapidtables.com/convert/color/index.html
Index ¶
- Variables
- func ColorToHSL(c color.Color) (h, s, l float64)
- func ColorToHSV(c color.Color) (h, s, v float64)
- func ColorToHex(c color.Color) string
- func HSLToColor(h, s, l float64) (color.Color, error)
- func HSLToRGB(h, s, l float64) (r, g, b uint8, err error)
- func HSVToColor(h, s, v float64) (color.Color, error)
- func HSVToRGB(h, s, v float64) (r, g, b uint8, err error)
- func HexToColor(hex string) (color.Color, error)
- func HexToRGB(hex string) (r, g, b uint8, err error)
- func RGBToGrayAverage(r, g, b uint8) color.Gray
- func RGBToGrayWithWeight(r, g, b uint8, rWeight, gWeight, bWeight uint) color.Gray
- func RGBToHSL(r, g, b uint8) (h, s, l float64)
- func RGBToHSV(r, g, b uint8) (h, s, v float64)
- func RGBToHex(r, g, b uint8) string
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHexValue = errors.New("colorconv: invalid input")
var ErrOutOfRange = errors.New("colorconv: inputs out of range")
Functions ¶
func ColorToHSL ¶
ColorToHSL convert color.Color into HSL triple, ignoring the alpha channel.
func ColorToHSV ¶
ColorToHSV convert color.Color into HSV triple, ignoring the alpha channel.
func ColorToHex ¶
ColorToHex convert color.Color into Hex string, ignoring the alpha channel.
func HSLToColor ¶ added in v1.1.0
HSLToColor convert HSL triple into color.Color.
func HSVToColor ¶ added in v1.1.0
HSVToColor convert HSV triple into color.Color.
func HexToColor ¶ added in v1.1.0
HexToColor convert Hex string into color.Color.
func RGBToGrayAverage ¶ added in v1.2.0
RGBToGrayAverage calculates the grayscale value of RGB with the average method, ignoring the alpha channel.
func RGBToGrayWithWeight ¶ added in v1.2.0
RGBToGrayWithWeight calculates the grayscale value of RGB wih provided weight, ignoring the alpha channel. In the standard library image/color, the conversion used the coefficient given by the JFIF specification. It is equivalent to using the weight 299, 587, 114 for rgb.
Types ¶
This section is empty.