Skip to content

Commit

Permalink
feat: image/colors: add MustParseHex(), ANSI colors
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Jan 18, 2025
1 parent 0d35bab commit 229630f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions image/colors/colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ var (
Blue = color.RGBA{R: 0, G: 0, B: 255, A: 255}
Orange = color.RGBA{R: 255, G: 165, B: 0, A: 255}

ANSIBlackHex = "000000"
ANSIRedHex = "800000"
ANSIGreenHEx = "008000"
ANSIYellowHex = "808000"
ANSIBlueHex = "000080"
ANSIMagentaHex = "800080"
ANSICyanHex = "008080"
ANSIWhiteHex = "c0c0c0"

// colors from: https://github.com/badges/shields/blob/18e17233c49cf94f9a32115c3fcdc439cb495086/badge-maker/lib/color.js#L7
ShieldBlueHex = "007ec6"
ShieldBrightGreenHex = "44cc11"
Expand Down
8 changes: 8 additions & 0 deletions image/colors/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ func ParseHex(hexRGB string) (color.RGBA, error) {
A: 0xff}, nil
}

func MustParseHex(hexRGB string) color.RGBA {
if c, err := ParseHex(hexRGB); err != nil {
panic(err)
} else {
return c
}
}

func ParseGoogle(googString string) (color.RGBA, error) {
m := rxGoogleCol.FindStringSubmatch(googString)
if len(m) == 0 {
Expand Down

0 comments on commit 229630f

Please sign in to comment.