mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-06 03:24:15 -04:00
* implement entity removal * add rgba color func, fix some lint errors in d2map * bugfix for map entity tests
29 lines
450 B
Go
29 lines
450 B
Go
package d2common
|
|
|
|
import "image/color"
|
|
|
|
func Color(rgba uint32) color.RGBA {
|
|
result := color.RGBA{}
|
|
a, b, g, r := 0, 1, 2, 3
|
|
byteWidth := 8
|
|
byteMask := 0xff
|
|
|
|
for idx := 0; idx < 4; idx++ {
|
|
shift := idx * byteWidth
|
|
component := uint8(rgba>>shift) & uint8(byteMask)
|
|
|
|
switch idx {
|
|
case a:
|
|
result.A = component
|
|
case b:
|
|
result.B = component
|
|
case g:
|
|
result.G = component
|
|
case r:
|
|
result.R = component
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|