Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Rek
Visitor

RGBA function?

Hey all, I would like a function that allows me to pass in rgba values and will return a single int that I can use as my colour. I can't seem to find such a function in the docs (maybe I just missed it though). If brightscript doesn't provide such a function, does anyone have a nice implementation? I started on my own, and quickly realised brightscript doesn't support bit-wise shifting very well, so my initial approach won't work.

This isn't a show-stopper by any means, but I find it keeps code a lot cleaner to have calls like this:
screen.clear(RGBA(10, 10, 50, 80))

than this:
screen.clear(&h0A0A3250)

Cheers!
0 Kudos
3 REPLIES 3
RokuMarkn
Visitor

Re: RGBA function?


function RGBA(r as Integer, g as Integer, b as Integer, a as Integer) as Integer
return r*256*256*256 + g*256*256 + b*256 + a
end function
0 Kudos
EnTerr
Roku Guru

Re: RGBA function?

Trivial implementation provided here viewtopic.php?f=34&t=66785&p=429040#p428921
0 Kudos
EnTerr
Roku Guru

Re: RGBA function?

"RokuMarkn" wrote:
function RGBA(r as Integer, g as Integer, b as Integer, a as Integer) as Integer

On a side note, RokuMarkn -
does pinning parameter/return types make any difference performance-wise?
(for this question, putting aside the improved error detection)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.