utils.go 301 B

123456789101112131415
  1. package main
  2. import "fmt"
  3. func uintToHex(v uint32) string {
  4. r := fmt.Sprintf("%X", v)
  5. if len(r) >= 2 {
  6. return r[0:2]
  7. }
  8. return r
  9. }
  10. func rgbToHex(r, g, b uint32) string {
  11. return fmt.Sprintf("%s%s%s", uintToHex(r), uintToHex(g), uintToHex(b))
  12. }