Closed mokiat closed 7 months ago
This PR should be ready for a more general public verification. The more people that have color scenarios in their apps to verify the better.
Thank you very much @mokiat! I will merge this into the v0.4.x
branch and create a new patch release as well so more people can test it.
Thanks! Using v0.4.36
, colors work well for me now.
On a side note, asking for future reference: should I have opened the PR against v0.4.x
or was master
ok, since there seem to be other API changes in master (e.g. non-ptr events) that have not gone into v0.4.x
?
Yes, master
is preferred in most cases. I usually cherry-pick the commit into v.4.x
branch afterwards. (Speaking of, I really should get v0.5.x
out already 😓, just stuck on the static libraries currently).
Closes https://github.com/veandco/go-sdl2/issues/580
This PR does the following changes:
Surface.Set
does not panic by handling colors correctly.Surface.At
to returncolor.NRGBA
instead ofcolor.RGBA
which is the correct type for what is being returned (non-alpha-premultiplied color). This can be a breaking change if anyone ever expected a specific color from the method, despite the interface abstraction.sdl.Color
type tocolor.NRGBA
which is the correct representation of what is held insdl.Color
(non-alpha-premultiplied color). This is a breaking change. Preserving thecolor.RGBA
type mapping would require more code rework.sdl
packageThings to note:
color.RGBA
type in Go represents an alpha-premultiplied color and SDL2 appears to use standard non-alpha premultiplied colors everywhere. This is whycolor.NRGBA
is the correct pick.Color.RGBA
method is expected to return 16bit (i.e. from 0x0000 to 0xFFFF) alpha-premultiplied color components.color.NRGBA
andcolor.NRGBAModel
, since these are the official ones and they have stable and optimized implementations for color conversions between alpha-premultiplied and non-alpha-premultiplied variants and from 8bit-component to 16bit-component colors.Side notes: