Skip to main content
Version: 7.9

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

    • int value - The value used to determine the percentage between the low and high values.

    • int low - The low value to use to calculate the percentage.

    • int high - The high value to use to calculate the percentage.

    • Color lowColor - The color that will match 0%.

      Color highColor - The 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.