1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-27 01:25:35 +00:00
OpenDiablo2/d2common/rgba_color.go
lord 8b2b991b12
D2mapengine remove entity, minor edits (#694)
* implement entity removal

* add rgba color func, fix some lint errors in d2map

* bugfix for map entity tests
2020-08-05 21:27:45 -04:00

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
}