Skip to main content
Version: 8.1

gradient

This function is used by Ignition's Expression language.

Description​

Calculates a percentage given the three numeric arguments number, low, and high. Uses this percentage to create a color that is a mix between the two colors.

Syntax​

gradient(value, low, high, lowColor, highColor)

Parameters​

TypeParameterDescription
IntegervalueThe value used to determine the percentage between the low and high values.
IntegerlowThe low value to use to calculate the percentage.
IntegerhighThe high value to use to calculate the percentage.
ColorlowColowThe color that will match 0%.
ColorhighColorThe color that will match 100%.

Results​

Color - A color that is a mix of the two given colors based on the percentage.

Examples​

Code Snippet
gradient(0, 0, 100, toColor("red"), toColor("blue")) //returns red.
Code Snippet
gradient(100, 0, 100, toColor("red"), toColor("blue")) //returns blue.
Code Snippet
gradient(60, 0, 100, toColor("red"), toColor("blue")) //returns a shade of purple.
Code Snippet
gradient({Root Container.Tank.value}, 0, 100, color(255,0,0), color(0,0,255)) //will return a gradient from red to blue based on the level of a tank.