# Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for
Show  only  | Search instead for
Did you mean:
Level 8

So I'm just having a hard time with this and hoping others on the forums can help. If I currently hold a variable that is the decimal equivalent of &hffffffff (which is white) and that decimal is 4294967295 , how wold I go about using that value in an argument that would normally accept a color represented by a hex value? Also I am declaring doubles with # so that the math goes through properly, and I even tried using the decimal directly, such as ...

`    screen.DrawObject(x, y, bm, 4294967295#)`

Am I missing something simple? How would I go about doing this?

Thank you.
8 REPLIES 8\
Level 9

I'm sure I'm missing something here, but why do you need the decimal value? Are you converting it from something else?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Level 8

I'm getting the decimal value from hue,saturation,value. viewtopic.php?f=34&t=85620
Level 8

I actually just figured out a slightly ridiculous way to get the result I want lol, but if it works it works. Just tried using the decTohex function found here -> viewtopic.php?t=51127

`function decToHex (dec as integer) as string   hexTab = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]   hex = ""   while dec > 0      hex = hexTab [dec mod 16] + hex      dec = dec / 16   end while   if hex = "" return "0" else return hexend function`

Then I took that string and put it in a

`    screen.DrawObject(x,y,bm,val(str,16))`

It worked, lol. If there is a better way I will certainly use it, but otherwise I guess this will work.

Edit: I can now change the hue and saturation of each of the 3 sections of my ship while in game... muahahaha

Level 9

"Romans_I_XVI" wrote:
I'm getting the decimal value from hue,saturation,value. viewtopic.php?f=34&t=85620

Sounds like you're not getting a valid value back from that function. That function returns a double, not an integer, so it won't work with DrawObject (assuming you actually mean to be passing it to DrawObject... are you trying to add a tint to the bitmap?). Have you tried casting it to an integer before returning the value?
`    color% =  rgb[0] + rgb[1] + rgb[2] + a    return color%`
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Level 8

I tried what you said TheEndless, the result is the same. Plus doesn't it need to be a double? If I used integers the math didn't work right. Either way, the doubles do in fact work in the DrawObject(), but at a certain point they go out of range, I believe it is 7FFFFFFF or 2147483647 that the color stops changing.

But again, it is working now, although I have to jump through a few hoops, I will jump through those hoops before the gameplay is actually going, so it's no problem.
Level 9

"Romans_I_XVI" wrote:
Plus doesn't it need to be a double?

Nope...
`BrightScript Debugger> ?type(&hffffffff)Integer`

You might need the doubles for precision during your math operations, but it should be an integer when passed to the 2D API functions. I suppose it's possible they work with either, but note that the version of Val() you used also returns an integer.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Level 8