cancel
Showing results for 
Search instead for 
Did you mean: 

Functions for decoding RGBA colors

Hi,

It would be nice if we could have some way to decode RGBA colors. It would be usefull for example when creating components and we want to separate an input color specified with RGBA function into its red, green, blue and alpha values.

Functions like these would be much appreciated:

  • GetRedValue(<some RGBA color>)
  • GetGreenValue(<some RGBA color>)
  • GetBlueValue(<some RGBA color>)
  • GetAlphaValue(<some RGBA color>)

Or maybe just one function that grabs them all:

  • DecodeRGBA(<some RGBA color>, <variable for red value>, <variable for green value>, <variable for blue value>, <variable for alpha value>)

Emmanuel

Status: New
Comments
Advocate III

I really like the idea of accessing the R, G, B, A codes of a Color Datatype.

And maybe it could even be possible without extra functions?

 

Say we collect a record like this

Collect(colTest,{col1: Screen1, col2: RGBA(255,0,0,1)})

 

col1 is a Control Datatype (where we can access col1.Name, col1.Fill, etc. of Screen1)

col2 is a Color Datatype. It would be nice if we could access col2.Red, col2.Green, col2.Blue, col2.Alpha.

 

Super User

Hi @Gabrz,

Yeah, sure, that could do the trick as well. It's a good idea... 👍

Frequent Visitor

Hey Folks,

 

A partial solution though a bit clunky 😉

Set(varColorSample,RGBA(134,2,21,221));
Set(varColorSampleJSON,JSON(varColorSample));

The varColorSampleJSON variable will be #860215ff that you can easily parse.

 

Imperfections 😎:

  • JSON does not support the Alpha value, so that is always FF (255) by my quick tests
  • JSON is a behaviour function so you cannot use it in line, you need "convert" your color variable by and action, OnSelect e.g.

Even if imperfect, might help a bit in certain cases 😉 e.g. when you store the alpha value in separately used config cariables.

 

Have fun

Imi

Super User

Hi @Imi,

I mus admit I never even thought of using the JSON function on a color. But it seems interesting. I'll try that very soon. Thanks for the workaround tip.

@PowerApps team: I'd still love to have a real OOTB solution, whether it is a function or using color "properties" like @Gabrz proposed.