Forum Discussion

Rek's avatar
Rek
Visitor
12 years ago

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!

3 Replies


  • 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
  • "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)