resolveLinearGradientColorAsCssValue
[ Function ]
public static resolveLinearGradientColorAsCssValue(
colorObject: TcHmi.LinearGradientColor
): string;
Converts a TcHmi.linearGradientColor value to a CSS value. Please note that the value must be a valid LinearGradientColor. To check this, you can use TcHmi.isLinearGradientColor.
Parameter
Name | Type | Description |
---|---|---|
colorObject | Color value to be translated. |
Return value
Type | Description |
---|---|
CSS color |
Available from version 1.10 |
Sample - JavaScript
var myColor = {
"angle": 90.0,
"stopPoints": [
{
"color": "rgba(0, 0, 0, 1)",
"stop": "0%"
},
{
"color": "rgba(215, 61, 61, 1)",
"stop": "100%"
}
]
};
var newElem = $('<div class="testdiv"></div>');
if (TcHmi.isLinearGradientColor (myColor)) {
var cssColor = TcHmi.StyleProvider.resolveLinearGradientColorAsCssValue(myColor);
TcHmi.StyleProvider.setSimpleElementStyle(newElem, 'background-image', cssColor);
} else {
TcHmi.StyleProvider.setSimpleElementStyle(newElem, 'background-image', null);
}
Most applications can use high-level APIs such as TcHmi.StyleProvider.processBackgroundColor or similar.