MCPcopy Create free account
hub / github.com/openclaw/gogcli / parseHexColor

Function parseHexColor

internal/docsformat/format.go:550–566  ·  view source on GitHub ↗
(hex string)

Source from the content-addressed store, hash-verified

548}
549
550func parseHexColor(hex string) (r, g, b float64, ok bool) {
551 hex = strings.TrimPrefix(hex, "#")
552 if len(hex) == 3 {
553 hex = string([]byte{hex[0], hex[0], hex[1], hex[1], hex[2], hex[2]})
554 }
555
556 if len(hex) != 6 {
557 return 0, 0, 0, false
558 }
559
560 rgb, err := strconv.ParseUint(hex, 16, 24)
561 if err != nil {
562 return 0, 0, 0, false
563 }
564
565 return float64((rgb>>16)&0xFF) / 255.0, float64((rgb>>8)&0xFF) / 255.0, float64(rgb&0xFF) / 255.0, true
566}
567
568func invalidf(format string, args ...any) error {
569 return ValidationError(fmt.Sprintf(format, args...))

Callers 1

ColorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected