I was generating some colors with a formula and they didn't seem to match up with what I was expecting when I tested them on an image that was produced using them.
Here's some sample code demonstrating what I found:
Code: Select all
Debug RSet(Hex(RGB($999, $2, $3)), 6, "0")
Debug RSet(Hex(RGB($1, $999, $3)), 6, "0")
Debug RSet(Hex(RGB($1, $2, $999)), 6, "0")
Debug "==============================="
Debug RSet(Hex(RGBA($999, $2, $3, $4)), 8, "0")
Debug RSet(Hex(RGBA($1, $999, $3, $4)), 8, "0")
Debug RSet(Hex(RGBA($1, $2, $999, $4)), 8, "0")
Debug RSet(Hex(RGBA($1, $2, $3, $999)), 8, "0")Code: Select all
030B99
0B9901
999020
===============================
04030B99
040B9901
0D990201
FFFFFFFFIt can be shown that the parameters are simply combined, possibly by using shifting and addition. This means if you have a parameter that is too large it will overflow into a neighboring parameter. If the parameter is negative it will max out the values (make them all 255).
In either case looking at the output showed some inconsistent results that aren't produced by simply shifting and addition.
Hopefully you learn from my silly misstep. In my case a just substituted the parameter with a modded value (i.e. RGB(x % 256, y% 256, z%256)).

