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: 
Romans_I_XVI
Roku Guru

Re: HSVA to RGBA function

Ok finally tested your version of the function dev42 and it works perfect! Thank you for your magic!

I think I will replace the one in the original function with yours.
0 Kudos
squirreltown
Roku Guru

Re: HSVA to RGBA function

"dev42" wrote:

I did make mention of the "baby blue" :roll: ... and again, my changes to the HSV...() fixed it. No more "pale cyan". Could some kind soul test it out?

Yep it works, thank you.
Kinetics Screensavers
0 Kudos
Romans_I_XVI
Roku Guru

Re: HSVA to RGBA function

It's throwing a type mismatch if I give it a saturation of 0 though. I've tried 0 with everything else and it works.


Type Mismatch. (runtime error &h18) in pkg:/source/generalUtils.brs(77)
077: for c = 0 to rgb.count()-1 : rgb[c] = int(rgb[c] * 255) : end for
0 Kudos
Romans_I_XVI
Roku Guru

Re: HSVA to RGBA function

I think I found the problem.

This


if s% = 0 then
rgb = [v, v, v]
else


Needed to change to this

   if s% = 0 then
rgb = [v%/100, v%/100, v%/100]
else
0 Kudos
dev42
Visitor

Re: HSVA to RGBA function

Good catch. Glad to be helpful.
0 Kudos
TheEndless
Channel Surfer

Re: HSVA to RGBA function

Out of curiosity, why are you using HSV instead of RGB in the first place?
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)
0 Kudos
squirreltown
Roku Guru

Re: HSVA to RGBA function

"TheEndless" wrote:
Out of curiosity, why are you using HSV instead of RGB in the first place?

I know you weren't asking me but I'm using HSL (not HSV) because i built a color picker and although I'm doing the actual manipulation of the color in RGB, its a lot easier to determine how the sliders will move. Hue is 180 in either direction, and saturation and lightness are 0 -100 etc.
Kinetics Screensavers
0 Kudos
Romans_I_XVI
Roku Guru

Re: HSVA to RGBA function

It's much more user friendly for something like this.



You can colorize each of the 3 sections on the ship, as well as the shield.
0 Kudos
dev42
Visitor

Re: HSVA to RGBA function

"TheEndless" wrote:
Out of curiosity, why are you using HSV instead of RGB in the first place?

Again, not your target audience, but curious if I'm way off in this... but to be able to have random colors that aren't too dark. I couldn't figure out how to do that in RGB.... easily. errr with pretty code! Yeah, that's it.

But also to have RAINBOWS! 😛
0 Kudos
EnTerr
Roku Guru

Re: HSVA to RGBA function

"dev42" wrote:
... but to be able to have random colors that aren't too dark. I couldn't figure out how to do that in RGB.... easily. errr with pretty code! Yeah, that's it.

  1. Define
    lightness = 0.3*R + 0.6*G + 0.1*B

  2. Make sure `lightness` is above some threshold (say 0.5)

  3. Rejoyce!

Actually there are 101 ways to do that, for example you can use max(R, G, B), R+G+B, R^2+G^2+B^2, min(R,G,B) + max(R,G,B) etc

Credit goes to @SquirrelTown, who draw my attention to the concept of "lightness", which made me read little on it.
0 Kudos