You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
417 B
17 lines
417 B
3 years ago
|
package state
|
||
|
|
||
|
// ColorFromInt decodes a packed uint32 into a hex color.
|
||
|
func ColorFromInt(value uint32) Color {
|
||
|
return Color{
|
||
|
R: uint8((value >> 24) & 0xFF),
|
||
|
G: uint8((value >> 16) & 0xFF),
|
||
|
B: uint8((value >> 8) & 0xFF),
|
||
|
A: uint8((value >> 0) & 0xFF),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ToInt packs a hex color into a uint32.
|
||
|
func (c Color) ToInt() uint32 {
|
||
|
return uint32(c.R)<<24 | uint32(c.G)<<16 | uint32(c.B)<<8 | uint32(c.A)
|
||
|
}
|