for hue = 0 to 360
scr.DrawLine( 450,100+hue, 550,100+hue, int(2147483647)+hue)
scr.DrawLine( 650,100+hue, 750,100+hue, int(2147483647)+(hue<<8))
end for
BrightScript Debugger> toInt = function(x as Integer) as Integer: return x: end function
BrightScript Debugger> y = toInt(4294967295): ? y, type(y)
2147483647 Integer
BrightScript Debugger> for x= 2#^31-3 to 2#^31+2: ? x, toInt(x): next
2147483645 2147483645
2147483646 2147483646
2147483647 2147483647
2147483648 2147483647
2147483649 2147483647
2147483650 2147483647
"Romans_I_XVI" wrote:Hmm, the way you describe doing it is broken in principle. Not sure why/if you are getting the right results.
Glad you like it dev42 . How were you planning on implementing it though? I'm currently jumping through about 3 hoops. But it doesn't matter too much because I'm not running these functions often.
I start with that original HSVAtoRGBA function, which gives me a decimal. Then I have to pass it through this function.It actually gives you a Double. There is no Decimal as such in B/S (Decimal is fairly rare type, i mostly know it in some DBs, also Java has BigDecimal).
Here lies the problem. This function is declared to take Integer. So when you call it with a Double (from above) and that number is >2147483647#, it will get chopped to 2147483647 (MAXINT, 2^31-1). Which means when you call with R>=128, for any G, B, A you will be getting "7FFFFFFF" from that fn.function decToHex (dec as integer) as string
In my Brightscript I'm doing it like this.Maybe calling it always with V=100, A=255 has saved your bacon so far, IDK. But check for colors with strong R, they should all be washing to cyan (?).some_hex_color = val(decTohex(HSVAtoRGBA(hue,sat,100,255)),16)
"EnTerr" wrote:
Maybe calling it always with V=100, A=255 has saved your bacon so far, IDK. But check for colors with strong R, they should all be washing to cyan (?).
"squirreltown" wrote:
Thats what I found, passing it pure red returned a really pale cyan. I already had another solution so i didn't pursue it though.