Debian Codegraph @

imagex/colorx/colorx_test.go

raw
1 package colorx
2
3 import (
4 "fmt"
5 )
6
7 // ExampleParseHexColor shows how to use the ParseHexColor() function.
8 func ExampleParseHexColor() {
9 hexCols := []string{
10 "#112233",
11 "#123",
12 "#000233",
13 "#023",
14 "#bAC",
15 "invalid",
16 "#abcd",
17 "#-12",
18 }
19 for _, hc := range hexCols {
20 c, err := ParseHexColor(hc)
21 fmt.Printf("%-7s = %3v, %v\n", hc, c, err)
22 }
23
24 // Output:
25 // #112233 = { 17 34 51 255}, <nil>
26 // #123 = { 17 34 51 255}, <nil>
27 // #000233 = { 0 2 51 255}, <nil>
28 // #023 = { 0 34 51 255}, <nil>
29 // #bAC = {187 170 204 255}, <nil>
30 // invalid = { 0 0 0 255}, invalid format
31 // #abcd = { 0 0 0 255}, invalid format
32 // #-12 = { 0 17 34 255}, invalid format
33 }