colorconv

package
v0.0.0-...-94f88f4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var ErrInvalidHexValue = errors.New("colorconv: invalid input")
View Source
var ErrOutOfRange = errors.New("colorconv: inputs out of range")

Functions

func ColorToHSL

func ColorToHSL(c color.Color) (h, s, l float64)

ColorToHSL convert color.Color into HSL triple, ignoring the alpha channel.

func ColorToHSV

func ColorToHSV(c color.Color) (h, s, v float64)

ColorToHSV convert color.Color into HSV triple, ignoring the alpha channel.

func ColorToHex

func ColorToHex(c color.Color) string

ColorToHex convert color.Color into Hex string, ignoring the alpha channel.

func HSLToColor

func HSLToColor(h, s, l float64) (color.Color, error)

HSLToColor convert HSL triple into color.Color.

func HSLToRGB

func HSLToRGB(h, s, l float64) (r, g, b uint8, err error)

HSLToRGB converts an HSL triple to an RGB triple.

func HSVToColor

func HSVToColor(h, s, v float64) (color.Color, error)

HSVToColor convert HSV triple into color.Color.

func HSVToRGB

func HSVToRGB(h, s, v float64) (r, g, b uint8, err error)

HSVToRGB converts an HSV triple to an RGB triple.

func HexToColor

func HexToColor(hex string) (color.Color, error)

HexToColor convert Hex string into color.Color.

func HexToRGB

func HexToRGB(hex string) (r, g, b uint8, err error)

HexToRGB converts a Hex string to an RGB triple.

func RGBToGrayAverage

func RGBToGrayAverage(r, g, b uint8) color.Gray

RGBToGrayAverage calculates the grayscale value of RGB with the average method, ignoring the alpha channel.

func RGBToGrayWithWeight

func RGBToGrayWithWeight(r, g, b uint8, rWeight, gWeight, bWeight uint) color.Gray

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.

func RGBToHSL

func RGBToHSL(r, g, b uint8) (h, s, l float64)

RGBToHSL converts an RGB triple to an HSL triple.

func RGBToHSV

func RGBToHSV(r, g, b uint8) (h, s, v float64)

RGBToHSV converts an RGB triple to an HSV triple.

func RGBToHex

func RGBToHex(r, g, b uint8) string

RGBToHex converts an RGB triple to a Hex string in the format of 0xffff.

Types

This section is empty.

Jump to

Keyboard shortcuts

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