Changing the transparency (alpha) of a color using bindings

Hey folks,

Brand new to Ignition and this forum.

I'm trying to make an indicator light template. I would like the user to supply the color ("red", "yellow", or "green") at instantiation. If the light is on I want the color to be the user supplied value. If it's off I want it to be the supplied value with an alpha of 10. I have two internal properties. One named color of type color and one named On of type Boolean.

I've tried

if({IndicatorLight.On},IndicatorLight.Color,IndicatorLight.Color+"33")

in the Fill Paint binding, but no luck.
This works for green

if({IndicatorLight.On},"00ff00","#00ff00"+"33")

so I know I'm on the right track, just not sure how to make color a string and append the "33". Any thoughts?

Color is a color object, and I don't believe there is any way to cast it as usable string in an expression. Using toString gives you color( ##,##,##,###).

However, if you bind a string custom property to a color custom property, it turns it into a hex string. You might be able to (ab)use that to your advantage.

Your second expression is using a hex string, hence your ability to concatenate the transparency.

If I make .Color a string and assign a value #00FF00 (no quotes) this works.

if({IndicatorLight.On},{IndicatorLight.Color},{IndicatorLight.Color}+"33")

Not sure if this is what you are looking for, but there are color expressions like darker and brighter
Colors | Ignition User Manual

Because you changed it from a color type to a string type. Strings allow concatenation, colors do not. The color picker may allow you to use Hex color strings but behind the scenes(in vision) its a java.awt.color, its just automatically converted for you.

That aside the only way to do named colors in vision is to use toColor, which gives you a color object.