Setting color (background or button) by HEX value?

Hi all,
I like to create a color table with RAL colors for visualization.
What value formats can I use to set a color (Button f.e.)?
The different color formats I got are
RAL 9005 – Tiefschwarz | Tiefschwarz | R010 G010 B013 | C100 M40 Y50 K90 | #0A0A0A

When selecting a color I can input HEX/RGB or via color picker, but I only found the expression function RGBA().
So I can’t set a color by its HEX value, right?

Regards Chris

Hi @ChrisF,

there is actually a bulky workaround with the expression editor.
You need to split your HEX Value in groups of two, to represent the separate channels… if the las group does not exist, the alpha channel is 1 (FF in HEX). To translate RAL and you usually use no Alpha channel, you can use RGB() to not make it more complicated then needed…

rgba(ceil(hex_to_int('0A')), ceil(hex_to_int('0A')), ceil(hex_to_int('0A')), ceil(hex_to_int('FF')))

or with no alpha:

rgb(ceil(hex_to_int('0A')), ceil(hex_to_int('0A')), ceil(hex_to_int('0A'))))

If you would use it a bit more, a connector function or a custom widget would be the better choice.

However, what do you think about making a product suggestion to calculate HEX values into colors…?


edit:
E.g. with a postgres connector you could so something like this:

1 Like

Hi @thorsten.langner

I first wanted to clarify whether I missed a solution before making a product suggestion :wink:

It’s for a quality check (visible comparison) of the delivered coating color, so I often need this function.

So I think I’ll try to create a cw too, to improve my javascript knowledge.

Thanks
Chris

1 Like