Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


Harris Geospatial / Docs Center / Using IDL / Specifying Object Color

IDL

Specifying Object Color

Specifying Object Color

The color of most graphic objects are specified by the COLOR property of that object. (The IDLgrImage object has a PALETTE property, not a COLOR property. See IDLgrPalette::Init for examples.) In IDL Object Graphics, colors used for drawing visualization objects (such as an IDLgrText object) are typically represented in one of two ways:

  • Indexed - a color is an index into a palette
  • RGB - a color is a three-element vector, [red, green, blue].

You can set the color of an object either when the object is created or afterwards. For example, the following statement creates a view object and sets its color value to the RGB triple [60, 60, 60] (a dark gray).

myView = OBJ_NEW('IDLgrView', COLOR = [60, 60, 60])

The following statement changes the color value of an existing axis object to the color value specified for entry 100 in the color palette associated with the axis object.

myAxis->SetProperty, COLOR=100

The interpretation of this color depends upon the color model associated with the destination object, described in Color and Destination Objects.

Note: Remember that color palettes associated with individual graphic visualization objects are only used when the destination object uses an RGB color model. If the destination object uses an Indexed color model, the destination object’s palette is always used.

Example Specifying RGB Values


RGB values are specified with RGB triples. An RGB triple is a three-element vector of integer values, [r, g, b], generally ranging between 0 and 255. A value of zero is the darkest possible value for each of the three channels—thus an RGB triple of [0, 0, 0] represents black, [0, 255, 0] represents bright green, and [255, 255, 255] represents white.

For example, suppose we create a plot line with the following statements:

myWindow = OBJ_NEW('IDLgrWindow')
myView = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[0, 0, 10, 10])
myModel = OBJ_NEW('IDLgrModel')
myPlot = OBJ_NEW('IDLgrPlot', FINDGEN(10), THICK = 5)
myModel->Add, myPlot
myView->Add, myModel
myWindow->Draw, myView

Notice the following aspects of the above example:

  1. The newly-created window (destination) object uses an RGB color mode (the default).
  2. The default color of the view object—the background against which the plot line is drawn—is white ([255, 255, 255]).
  3. The default color of the plot object (and all objects, for that matter) is black.

Try changing the colors with the following statements:

myPlot->SetProperty, COLOR = [150, 0, 150]
myView->SetProperty, COLOR = [75, 250, 75]
myWindow->Draw, myView

To destroy the window and remove the objects created from memory, use:

OBJ_DESTROY, [myWindow, myView]



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us