package csscolorparser

Import Path
	github.com/mazznoer/csscolorparser (on go.dev)

Dependency Relation
	imports 4 packages, and imported by 5 packages

Involved Source Files Package csscolorparser provides function for parsing CSS color string as defined in the W3C's CSS color module level 4. named_colors.go
Code Examples package main import ( "fmt" "github.com/mazznoer/csscolorparser" ) func main() { c, err := csscolorparser.Parse("rgb(100% 0% 0% / 50%)") if err != nil { panic(err) } fmt.Printf("R:%.3f, G:%.3f, B:%.3f, A:%.3f\n", c.R, c.G, c.B, c.A) fmt.Println(c.RGBA255()) fmt.Println(c.HexString()) fmt.Println(c.RGBString()) } package main import ( "fmt" "github.com/mazznoer/csscolorparser" ) func main() { c, err := csscolorparser.Parse("#ffd700") if err != nil { panic(err) } fmt.Println(c.RGBString()) name, _ := c.Name() fmt.Println(name) }
Package-Level Type Names (only one)
/* sort by: | */
R, G, B, A values in the range 0..1 A float64 B float64 G float64 R float64 Clamp restricts R, G, B, A values to the range 0..1. HexString returns CSS hexadecimal string. Implement the Go TextMarshaler interface Name returns name of this color if its available. Implement the Go color.Color interface. RGBA255 returns R, G, B, A values in the range 0..255 RGBString returns CSS RGB string. Implement the Go TextUnmarshaler interface Color : encoding.TextMarshaler *Color : encoding.TextUnmarshaler Color : image/color.Color func FromHsl(h, s, l, a float64) Color func FromHsv(h, s, v, a float64) Color func FromHwb(h, w, b, a float64) Color func FromLab(l, a, b, alpha float64) Color func FromLch(l, c, h, alpha float64) Color func FromLinearRGB(r, g, b, a float64) Color func FromOklab(l, a, b, alpha float64) Color func FromOklch(l, c, h, alpha float64) Color func Parse(s string) (Color, error) func Color.Clamp() Color
Package-Level Functions (total 9)
FromHsl creates a Color from HSL colors. Arguments: - h: Hue angle [0..360] - s: Saturation [0..1] - l: Lightness [0..1] - a: Alpha [0..1]
FromHsv creates a Color from HSV colors. Arguments: - h: Hue angle [0..360] - s: Saturation [0..1] - v: Value [0..1] - a: Alpha [0..1]
FromHwb creates a Color from HWB colors. Arguments: - h: Hue angle [0..360] - w: Whiteness [0..1] - b: Blackness [0..1] - a: Alpha [0..1]
func FromLab(l, a, b, alpha float64) Color
func FromLch(l, c, h, alpha float64) Color
FromLinearRGB creates a Color from linear-light RGB colors. Arguments: - r: Red value [0..1] - g: Green value [0..1] - b: Blue value [0..1] - a: Alpha value [0..1]
FromOklab creates a Color from Oklab colors. Arguments: - l: Perceived lightness - a: How green/red the color is - b: How blue/yellow the color is - alpha: Alpha [0..1]
FromOklch creates a Color from OKLCh colors. Arguments: - l: Perceived lightness - c: Chroma - h: Hue angle in radians - alpha: Alpha [0..1]
Parse parses CSS color string and returns, if successful, a Color.
Package-Level Variables (only one)