>  Docs Center  >  Libraries  >  Coyote  >  CGCOLOR


  The purpose of this function is to obtain drawing colors
  by name and in a device/decomposition independent way.
  The color names and values may be read in as a file, or 192 color
  names and values are supplied with the program. These colors were
  obtained from the file rgb.txt, found on most X-Window distributions,
  and from colors in the `Brewer color tables <http://colorbrewer2.org/>`.
  Representative colors were chosen from across the color spectrum.
  If the color names '0', '1', '2', ..., '255' are used, they will
  correspond to the colors in the current color table in effect at
  the time the `cgColor` program is called.
  Please note that all Coyote Graphics routines use cgColor internally to specify
  their colors in a color-model independent way. It is not necessary to call
  cgColor yourself unless you are using it with a traditional IDL command (e.g., Plot).
  For example::
    Plot, data, Color=cgColor('dodger blue')
  But, it is not needed with Coyote Graphics commands::
    cgPlot, data, Color='dodger blue'




    To get drawing colors in a device-decomposed independent way::
        axisColor = cgColor("Green", !D.Table_Size-2)
        backColor = cgColor("Charcoal", !D.Table_Size-3)
        dataColor = cgColor("Yellow", !D.Table_Size-4)
        Plot, Findgen(11), Color=axisColor, Background=backColor, /NoData
        OPlot, Findgen(11), Color=dataColor
    To set the viewport color in object graphics::
        theView = Obj_New('IDLgrView', Color=cgColor('Charcoal', /Triple))
    To change the viewport color later::
        theView->SetProperty, Color=cgColor('Antique White', /Triple)
    To load the drawing colors "red", "green", and "yellow" at indices 100-102, type this::
        IDL> TVLCT, cgColor(["red", "green", "yellow"], /Triple), 100
    To interactively choose a color, set the SELECTCOLOR keyword::
        IDL> color = cgColor(/SelectColor)
    The cgPickColorName program is a good way to learn the names of the colors available::
        IDL> color = cgPickColorName()


      David W. Fanning
      1645 Sheely Drive
      Fort Collins, CO 80526 USA
      Phone: 970-221-0438
      E-mail: david@idlcoyote.com
      Coyote's Guide to IDL Programming: http://www.idlcoyote.com


    Change History::
        Written by: David W. Fanning
        Modified FSC_COLOR to create cgColor 9 February 2011. DWF.
        Modified to allow a three-element color triple to be used in place of the color
          name parameter. This allows one user-defined color to be used. 4 Dec 2011. DWF.
        Modified to allow byte and 16-bit integer values to be used to specify colors
          in the current color table. 5 Dec 2011. DWF.
        Modified to allow the "opposite" pixel to be determined in the Z-graphics buffer. 24 Dec 2011. DWF.
        Modified the code to handle long integers depending on the current color mode and the
            number of values passed in. 10 January 2012. DWF.
        Made sure the return values are BYTES not INTEGERS, in cases where this is expected. 10 Jan 2012. DWF.
        Added "Background" as a color name. The opposite of "Opposite". 1 Feb 2012. DWF.
        When returning a vector of color values, now making sure to return a byte array if
            in indexed color mode. 27 Feb 2012. DWF.
        Added Compile Opt id2 to all file modules. 22 July 2012. DWF.
        Added "opposite" and "background" colors to Brewer colors. 14 August 2012. DWF.
        Some versions of IDL report the size of widget windows incorrectly, so instead of
              sampling the very top-right pixel, I now back off a little. 1 Nov 2012. DWF.
        For numerical values less than 256, in indexed color state, I now return the values
              directly to the user. This should significantly speed up many Coyote Graphics
              processes. 14 December 2012. DWF.
        Removed cgColor_Color24 module in favor of using Coyote Library routine cgColor24. 5 Jan 2013. DWF.
        The keyword ROW was being ignored if multiple colors were specified with TRIPLE keyword. Fixed. 10 July 2013. DWF.
        Another fix to handle Windows 8 computers that report their window size incorrectly. 21 Oct 2013. DWF.
        Added 12 colors suggested by Paul Krummel for people with color blindness. See the last line in
              Figure 3 of `this reference <http://www.sron.nl/~pault/>`. 16 Jan 2015. DWF.
        Getting reports that Mac computers are now reporting inaccurate draw widget sizes (similar to Windows
              computers). So, I changed the algorithm for picking the "opposite" or "background" color.
              Previously, I read the color from the open graphics window. Now, I only do that if you ask for
              the "OPPOSITE" or "BACKGROUND" color. Otherwise, I assume the background color is "white". If you
              do ask for the color, I read the open graphics window at a location 5 pixels removed from what
              is "supposed" to be the upper-right corner of the window (often reported incorrectly). If I have
              any problems reading this pixel, I report the background color as "white". 27 Feb 2015. DWF.


    Copyright (c) 2009-2015, Fanning Software Consulting, Inc.

© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us