Color


For all GKS output primitives, color is assigned by an indexing scheme. The indices typically run from 0 to N, where 0 is the background color index and 1 is the foreground color index. Indices are assigned by calls to the GKS routine GSCR. In GSCR, an index is assigned a color value based upon the setting of a red, green, blue ( RGB) triplet according to the RGB color model. The indices, not RGB settings, are thereafter used to assign color to the output primitives.

For more details on the use of color in GKS, refer to Color tables and color mapping systems. in the NCAR Graphics Fundamentals documentation module.

Color Setting Functions


Set Color Representation

-------------------------------------------------
           Argument | Type    | Mode  | Dimension
-------------------------------------------------
CALL GSCR  (WKID,   | Integer | Input |
            CI,     | Integer | Input |
            CR,     | Real    | Input |
            CG,     | Real    | Input |
            CB)     | Real    | Input |
-------------------------------------------------
WKID
A workstation identifier.
CI
A color index to be assigned a color of CR, CG, and CB.
CR
An intensity of red between a minimum of 0. and a maximum of 1. inclusive.
CG
A green intensity between 0. and 1.
CB
A blue intensity between 0. and 1.
Defaults:
The default color values are specific to the output device.
Errors:
7, 20, 25, 33, 35, 36, 92, 96
------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void gset_colr_rep(
             Gint             ws_id,     /*  workstation identifier  */
             Gint             colr_ind,  /*  color index             */
             const Gcolr_rep  *colr_rep  /*  color representation    */
);
------------------------------------------------------------------------
The color index is an identification tag for an RGB (red, green, blue) color setting. When generating an output primitive, you may specify the color for that primitive by referring to the color index. We recommend that you define all color indices required in a given picture before issuing any output primitives in that picture. If you will be using a fixed set of colors throughout an application, then those color indices are best defined after you activate the workstation. It is important to stress that color index 0 defines the background color. If any color indices are defined, then you should define the background color index 0 -- otherwise you run the risk of having a user-defined color match the default background color.

Set Polyline Color Index

---------------------------------------------------
             Argument | Type    | Mode  | Dimension
---------------------------------------------------
CALL GSPLCI  (COLI)   | Integer | Input |
---------------------------------------------------
COLI
An index assigned an RGB (red, green, blue) color in a previous call to the GSCR routine or a workstation dependent default. Allowed indices are non-negative integers. Index 0 is the background color. Index 1 is the foreground color.
All lines drawn with calls to the GPL output primitive will be drawn with the color described by index COLI until GSPLCI is called again and a new index is assigned.
Default:
The default polyline color index is 1 (foreground color).
Errors:
8, 92
--------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void gset_line_colr_ind(
                        Gint  line_colr_ind  /*  polyline color index  */
);
--------------------------------------------------------------------------

Set Polymarker Color Index

----------------------------------------------------
             Argument | Type    | Mode  |  Dimension
----------------------------------------------------
CALL GSPMCI  (COLI)   | Integer | Input |
----------------------------------------------------
COLI
An index assigned an RGB (red, green, blue) color in a previous call to the GSCR routine, or a workstation-dependent default. Allowed indices are non-negative integers. Index 0 is the background color. Index 1 is the foreground color.
All markers drawn with calls to the GPM output primitive will be drawn with the color described by index COLI until GSPMCI is called again and a new index is assigned.
Default:
The default polymarker color index is 1 (foreground color).
Errors:
8, 92
-------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void gset_marker_colr_ind(
                   Gint  marker_colr_ind  /*  polymarker color index  */
);
-------------------------------------------------------------------------

Set Text Color Index

---------------------------------------------------
             Argument | Type    | Mode  | Dimension
---------------------------------------------------
CALL GSTXCI  (COLI)   | Integer | Input |
---------------------------------------------------
COLI
An index assigned an RGB (red, green, blue) color in a previous call to the GSCR routine, or a workstation-dependent default. Allowed indices are non-negative integers. Index 0 is the background color. Index 1 is the foreground color.
All text drawn with calls to the GTX output primitive will be drawn with the color described by index COLI until GSTXCI is called again and a new index is assigned.
Default:
The default text color index is 1 (foreground color).
Errors:
8, 92
---------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void gset_text_colr_ind(
                        Gint  text_colr_ind  /*  text color index  */
);
---------------------------------------------------------------------------

Set Fill Area Color Index

---------------------------------------------------
             Argument | Type    | Mode  | Dimension
---------------------------------------------------
CALL GSFACI  (COLI)   | Integer | Input |
---------------------------------------------------
COLI
An index assigned an RGB (red, green, blue) color in a previous call to the GSCR routine, or a workstation dependent default. Allowed indices are non-negative integers. Index 0 is the background color. Index 1 is the foreground color.
All filled areas drawn with calls to the GFA output primitive will be drawn with the color described by index COLI until GSFACI is called again and a new index is assigned.
Default:
The default fill area color index is 1 (foreground color).
Errors:
8, 92
-------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void gset_fill_colr_ind(
                        Gint  fill_colr_ind  /*  fill  color index  */
);
-------------------------------------------------------------------------

Color Inquiry Functions


Get the Color Representation

--------------------------------------------------
           Argument | Type    | Mode   | Dimension
--------------------------------------------------
CALL GQCR  (WKID,   | Integer | Input  |
            CI,     | Integer | Input  |
            TYPE,   | Integer | Input  |
            ERRIND, | Integer | Output |
            CR,     | Real    | Output |
            CG,     | Real    | Output |
            CB)     | Real    | Output |
--------------------------------------------------
WKID
Gives the workstation identifier.
CI
A color index.
TYPE
A flag to indicate whether the returned color values are those that have been requested or those actually used on the workstation.
0 - Returns the colors set for index CI in a GSCR call, or the default case.
1 - Returns the colors actually used by the workstation to represent the requested color.
ERRIND
Error flag. Gives an integer error number from the errors list in in Appendix D, or a 0 if no error occurred.
CR
Gives an intensity of red between a minimum of 0. and a maximum of 1. inclusive.
CG
Gives a green intensity between 0. and 1.
CB
Gives a blue intensity between 0. and 1.
Errors:
7, 20, 25, 93, 2000
--------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void ginq_colr_rep(
                   Gint       ws_id,     /*  workstation identifier   */
                   Gint       colr_ind,  /*  color index              */
                   Ginq_type  type,      /*  type of returned values  */
                   Gint       *err_ind,  /*  error indicator          */
                   Gcolr_rep  *colr_rep  /*  color representation     */
);
--------------------------------------------------------------------------

Get the Polyline Color Index

----------------------------------------------------
             Argument | Type    | Mode   | Dimension
---------------------------------------------------
CALL GQPLCI  (ERRIND, | Integer | Output |
              COLI)   | Integer | Output |
----------------------------------------------------
ERRIND
Error flag. Gives an integer error number from the errors list in in Appendix D, or a 0 if no error occurred.
COLI
Gives the polyline color index as set by GSPLCI.
Errors:
8
---------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void ginq_line_colr_ind(
                        Gint  *err_ind,       /*  error indicator       */
                        Gint  *line_colr_ind  /*  polyline color index  */
);
---------------------------------------------------------------------------

Get the Polymarker Color Index

----------------------------------------------------
             Argument | Type    | Mode   | Dimension
---------------------------------------------------
CALL GQPMCI  (ERRIND, | Integer | Output |
              COLI)   | Integer | Output |
----------------------------------------------------
ERRIND
Error flag. Gives an integer error number from the errors list in in Appendix D, or a 0 if no error occurred.
COLI
Gives the polymarker color index as set by GSPMCI.
Errors:
8
---------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void ginq_marker_colr_ind(
                   Gint  *err_ind,         /*  error indicator         */
                   Gint  *marker_colr_ind  /*  polymarker color index  */
);
---------------------------------------------------------------------------

Get the Text Color Index

----------------------------------------------------
             Argument | Type    | Mode   | Dimension
---------------------------------------------------
CALL GQTXCI  (ERRIND, | Integer | Output |
              COLI)   | Integer | Output |
----------------------------------------------------
ERRIND
Error flag. Gives an integer error number from the errors list in in Appendix D, or a 0 if no error occurred.
COLI
Gives the text color index as set by GSTXCI.
Errors:
8
-------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void ginq_text_colr_ind(
                        Gint  *err_ind,       /*  error indicator   */
                        Gint  *text_colr_ind  /*  text color index  */
);
-------------------------------------------------------------------------

Get the Fill Area Color Index

----------------------------------------------------
             Argument | Type    | Mode   | Dimension
---------------------------------------------------
CALL GQFACI  (ERRIND, | Integer | Output |
              COLI)   | Integer | Output |
----------------------------------------------------
ERRIND
Error flag. Gives an integer error number from the errors list in in Appendix D, or a 0 if no error occurred.
COLI
Gives the fill area color index as set by GSFACI.
Errors:
8
---------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void ginq_fill_colr_ind(
                      Gint  *err_ind,       /*  error indicator        */
                      Gint  *fill_colr_ind  /*  fill area color index  */
);
---------------------------------------------------------------------------

Links: GKS Index, GKS Home