You’re using SINGLE type variables and falling outside their range of precision, losing information.
CONST White~&& = ...
Just my guess, without actually running the code.
.....
Either that, or else you need a _DELAY after the SCREEN call so you can switch screen modes to a 32-bit screen, before the RGBA value is set. It may be a race condition where you’re getting values before SCREEN has finished swapping screen modes.
Print the values and compare what the results are, to what you think they should be.
Actually, I was wrong with both my guesses at what the problem was, without first running the code...
The issue here is simply the fact that CONST has no idea what screen mode you're going to be using, and you never told it with the _RGBA command.
SCREEN 12
CONST Red = _RGB(255,0,0)
SCREEN _NEWIMAGE(640,480,32)
CONST Red = _RGB(255,0,0)
Now, since CONST are set in the precompile stage -- even before the translation of your code to C -- there's no way for any of them to know what SCREEN you're going to be using in your program since you can change it at any point in run time. (See my latest post in the topic here for a brief demo, if needed, of swapping SCREENs inside a program:
https://www.qb64.org/forum/index.php?topic=1741.msg109892#msg109892 )
So, since you're not telling the CONST command what screen mode you want the value for,
it assumes you're working with a default screen -- SCREEN 0.
When using CONST to set values with _RGB and _RGBA,
always use the extra parameter for the screen mode.
Give this little code a test run and see the difference in your color values:
CONST White2
= _RGBA(255, 255, 255, 255, 32) 'See the ,32 at the end? That's to set a 32-bit color value
No real point to use _RGB or _RGBA for 32-bit color screens (unless you just want to for format's sake, or such), but you can also use the same syntax to designate CONST values for our other screen modes:
Notice that we're getting the color value for red for:
SCREEN 0 -- 4
SCREEN 2 -- 0
SCREEN 12 -- 40
SCREEN 32 -- 4294901760
You need to set that last parameter to the screen mode which you want to use _RGB and _RGBA with, when using it inside a CONST.