Example Code

Color to Gradient

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

Takes an input color and outputs all possible light to dark shades as a color array.

Description

Calculates and outputs a contrast gradient of an input color from its brightest to its darkest. The output is an array of colors. This is useful if you want a darker or lighter version of an input color - that is the same color, but lighter or darker shade. As the total gradients is limited to 0 - 255 for R, G or B, the total possible gradients output for a particular color differ on how close or far any of the starting RGB values are from 0 to 255.

Hardware and Software Requirements

LabVIEW 2016 or compatible

Steps to Implement or Execute Code

1. Specify a color value in the Color Box.
2. Run the VI. The Color Gradient array will display the full gradient generated for the specified color, and the Animation image will display each color in the array from light to dark.

Additional Information or References

HSV, RGB, color

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.