colorx

package
v0.0.0-...-c19cbcf Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package colorx contains color utilities. It means to be a complement to the standard image/color package.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHexColor

func ParseHexColor(s string) (c color.RGBA, err error)

ParseHexColor parses a web color given by its hex RGB format. See https://en.wikipedia.org/wiki/Web_colors for input format.

For details, see https://stackoverflow.com/a/54200713/1705598

Example

ExampleParseHexColor shows how to use the ParseHexColor() function.

hexCols := []string{
	"#112233",
	"#123",
	"#000233",
	"#023",
	"#bAC",
	"invalid",
	"#abcd",
	"#-12",
}
for _, hc := range hexCols {
	c, err := ParseHexColor(hc)
	fmt.Printf("%-7s = %3v, %v\n", hc, c, err)
}
Output:

#112233 = { 17  34  51 255}, <nil>
#123    = { 17  34  51 255}, <nil>
#000233 = {  0   2  51 255}, <nil>
#023    = {  0  34  51 255}, <nil>
#bAC    = {187 170 204 255}, <nil>
invalid = {  0   0   0 255}, invalid format
#abcd   = {  0   0   0 255}, invalid format
#-12    = {  0  17  34 255}, invalid format

Types

This section is empty.

Jump to

Keyboard shortcuts

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