Example Code

Custom Color Gradient (Color Picker)

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

  • Vision Development Module
  • LabVIEW

Code and Documents

Attachment

Overview

This example demonstrates how to create a color selector with additional brightness selector. This example uses intensity graphs with overlapped sliders in the foreground.

 

Description

This VI is meant to be a dialog box (a subVI) to choose a color for a top level VI. While the color box is nice, this is a little quicker to access. The VI uses a gradient created in an intensity graph so that the user can see all of the available colors. They are selected by placing an invisible slider on top of the graph and indexing the array to that specific color.
With the Vision Development Module (VDM) you can also change the intensity of the selected color. So, not only the color, but how bright it is ranging from white to black. There is a boolean on the front panel that allows you to enable / disable the brightness slider.

Depending on whether you have the Vision Development Module or not, you can remove a lot of the VIs and property nodes on the block diagram (refer to description in Block Diagram).

As this is meant to be a dialog, you can use the SubVI setup when placing this VI in a calling VIs Block Diagram to show and hide this VIs Front Panel when calling it.


Requirements

 Software

  • LabVIEW Base Development System 2012 (or compatible)
  • NI Vision Development Module 2012 (or compatible)
  • If running in a Real-Time context, you will need the LabVIEW Real-Time Module 2012 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

Steps to Implement or Execute Code

  1. Download and extract the attached file "Color Gradient Dialog Box LV2012 NIVerified.zip"
  2. Follow the instructions in Front Panel and Block Diagram and run the program

 

Additional Information or References

Main Frontpanel.png

 

 

Main VI Block Diagram:

 

[Main] Color Gradient Dialog Box LV2012 NIVerified.vi - Block Diagram.png

 

Initialization VI Block Diagram:

Init Intensity Graphs.vi - Block Diagram.png

 

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**

Chris Van Horn
Applications Engineer

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