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.
 
 
 
hexmap/server/state/color.pbconv.go

31 lines
948 B

package state
// ColorFromRGBA8888 decodes a packed uint32 (RGBA8888) into a hex color.
func ColorFromRGBA8888(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),
}
}
// ColorFromRGBA4444 decodes a packed uint16 (RGBA4444) into a hex color.
func ColorFromRGBA4444(value uint16) Color {
return Color{
R: uint8((value>>12)&0xF) * 0x11,
G: uint8((value>>8)&0xF) * 0x11,
B: uint8((value>>4)&0xF) * 0x11,
A: uint8((value>>0)&0xF) * 0x11,
}
}
// ToRGBA8888 packs a hex color into a uint32 as RGBA8888.
func (c Color) ToRGBA8888() uint32 {
return uint32(c.R)<<24 | uint32(c.G)<<16 | uint32(c.B)<<8 | uint32(c.A)
}
// ToRGBA4444 packs a hex color into a uint16 as RGBA4444.
func (c Color) ToRGBA4444() uint16 {
return uint16((c.R>>4)&0xF)<<12 | uint16((c.G>>4)&0xF)<<8 | uint16((c.B>>4)&0xF)<<4 | uint16((c.A>>4)&0xF)
}