gopxl / pixel

A hand-crafted 2D game library in Go.
MIT License
242 stars 10 forks source link

Replace pixel.RGBA with color.RGBA #71

Closed dusk125 closed 2 months ago

dusk125 commented 1 year ago

It looks like most of the time pixel.RGBA is used, it's converted back to color.RGBA anyway... and it uses 8x as much memory: 4 float64 vs 4 uint8.

and/or type alias pixel.RGBA to color.RGBA if we need/want some of the methods for pixel.RGBA

duysqubix commented 1 year ago

@dusk125

Surely there was a reason the original implementation converted them to floats, wouldn't logic like this cause unattended effects?

https://github.com/gopxl/pixel/blob/12fc9f5b840d7216d6714a71203b4a4e94d4d25c/color.go#L59-L66

dusk125 commented 1 year ago

So from my investigation, it looks like glhf (and glfw) expect colors to be floats between 0 and 1. There will, therefore, still need to be conversions from the uint8's to floats. So right now, this is a further investigation to see if the usage of float colors can be minimized in Pixel.