Last active
December 18, 2023 12:20
-
-
Save yangyang5214/aba02718a3957246de6437aff58843d4 to your computer and use it in GitHub Desktop.
color.RGBA to hex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "image/color" | |
func ColorToHex(c color.Color) string { | |
r, g, b, _ := c.RGBA() | |
return fmt.Sprintf("#%02X%02X%02X", r>>8, g>>8, b>>8) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment