Perspective shows the fault as a correct color in the property preview but the wrong fill on the running component. With color(44,55,66), the preview can read java.awt.Color[r=44,g=55,b=66] while Preview or run mode falls back to white or the component's default background. Start here: the preview swatch is displaying the object, but the Perspective property cannot use that object as its runtime color value.
Stop applying the wrong fixes
-
Do not keep refreshing the expression binding. Refreshing evaluates the same expression and returns the same incompatible
java.awt.Colorobject. - Do not select a temporary color in the property editor. Picking red can make the component look correct at design time, but the expression replaces that selection when the binding evaluates.
-
Do not replace the component. The behavior was reproduced on any component with a suitable color property; the slider and its
backgroundColorproperty merely expose the mismatch. - Do not rely on simple integer-to-hex conversion. A conversion that omits leading zeroes produces malformed strings whenever a color channel needs two hexadecimal digits but starts with zero.
That is not a rendering fault, a stale Designer display, or a bad RGB calculation. The binding is delivering the wrong data type.
Identify the object-to-string mismatch
The color() expression function returns a java.awt.Color object. Vision components typically accept that object. Perspective represents colors as hexadecimal strings, so a Perspective style property needs a value such as #2C3742, not the Java object shown in the preview.
| Observed symptom | Cause |
|---|---|
| The preview square shows the intended RGB color. | The property editor can display the returned java.awt.Color object. |
| The component becomes white or returns to its default background in Preview or run mode. | The Perspective runtime does not receive a usable hexadecimal color string. |
| A manually selected color works until the binding evaluates. | The manual value is valid, but the binding overwrites it with the incompatible object. |
| Some calculated colors work while colors with no red or green component fail. | The conversion dropped required leading zeroes from one or more channels. |
The issue was reproduced on build b2018112110 and tracked as IGN-1566. Later reports said the requested Perspective adaptation had not been implemented, but they did not identify additional build numbers. Check your installed build and test the return type rather than inferring behavior from an unversioned report.
Confirm the failure before changing logic
- Open the affected Perspective component and locate its bound
backgroundColorproperty. - Record the three input channel values. For the reported example, they are red
44, green55, and blue66. - Evaluate the existing expression. If its displayed result has the form
java.awt.Color[r=44,g=55,b=66], the binding is returning an object rather than a Perspective hex string. - Temporarily replace the result with the literal
#2C3742. Enter Preview or run mode and observe the actual component, not only the property swatch. - If the literal renders correctly, keep the component and repair the conversion. If the literal also fails, inspect property precedence, style-class values, and other bindings that can overwrite the same property.
The literal test comes first because it separates a value-format problem from style precedence. Repeated expression refreshes do not make that distinction.
Return a padded hexadecimal string
For fixed RGB values, bind or assign the finished string directly:
#2C3742
For changing inputs that must continue through color(), add a script transform to the binding. Treat the incoming expression result as value, read its channels, and format every channel as exactly two hexadecimal digits:
colorIn = value
return '#%02x%02x%02x%02x' % (
colorIn.getRed(),
colorIn.getGreen(),
colorIn.getBlue(),
colorIn.getAlpha()
)
The %02x field width is the operative correction. It adds a leading zero when a channel converts to a single hexadecimal digit. The output order is red, green, blue, alpha, producing #RRGGBBAA. Use the alpha value read from getAlpha(); do not substitute an assumed opacity when the source color can vary.
If the target property only needs RGB, format the first three channels:
colorIn = value
return '#%02x%02x%02x' % (
colorIn.getRed(),
colorIn.getGreen(),
colorIn.getBlue()
)
A previously suggested arithmetic conversion concatenated '#' with an unpadded hex() result. That can appear correct for values whose combined representation already occupies six digits, but it fails when high-order channel digits are zero. Format channels individually instead.
Verify the binding in the runtime path
- Apply the transform and confirm that the transformed property value begins with
#. - Check that RGB output contains six hexadecimal digits after
#, or that RGBA output contains eight. - Test the known input
44, 55, 66. The RGB result must be#2c3742or the equivalent uppercase#2C3742. - Test values where red or green is zero. Confirm that each zero-valued channel still occupies two characters, such as
00. - Move each source slider through its range and watch the component in Preview or a running session. The background must update without reverting to white or the default.
- Change away from the view and return to it. This confirms that the correct result comes from binding evaluation rather than a temporary Designer selection.
Validate the final transformed value as well as the visual result. A convincing swatch beside java.awt.Color does not prove that Perspective received the required string.
Avoid recurring color-conversion failures
- Keep the presentation contract explicit: return a Perspective hex string from the final binding stage.
- Pad every channel independently. Concatenating variable-width hexadecimal fragments shifts channel boundaries.
- Preserve channel order. The supplied workaround uses
RRGGBBAA, not an integer whose byte order is left implicit. - Test zero-heavy colors. Pure blue, dark colors, and any value with a low red or green channel expose missing padding quickly.
- Do not diagnose from the Designer preview square alone. Verify Preview or session behavior after the binding evaluates.
- Record the installed build when checking whether native
color()handling has changed. Onlyb2018112110is identified in the reported reproduction.
FAQ
How do I use color() with a Perspective backgroundColor binding?
Add a script transform that reads the returned java.awt.Color channels and returns #RRGGBB or #RRGGBBAA. Use %02x for every channel.
How do I convert RGB 44, 55, 66 for Perspective?
Return the literal #2C3742. If the inputs change, generate the same six-digit structure in a transform.
How do I fix hex colors that fail when red or green is zero?
Pad each channel to two digits with %02x. An unpadded conversion can omit zeroes and produce a string with the wrong length.
How do I verify that the color binding is fixed?
Check that the final property value is a six- or eight-digit hex string, then test it in Preview or a running session. Include inputs with zero-valued red or green channels.
How do I know when to escalate a Perspective color problem?
Stop when a literal such as #2C3742 also fails after you have checked competing bindings and style precedence, or when a correctly padded transform still returns the default color. Record the component property, transformed value, installed build, and minimal reproduction, then escalate through Ignition's official support channel and reference IGN-1566.