How to make different types of colors


In this topic


Making different types of colors

This document explores some of the different types of color models supported in ArcObjects. A brief explanation of each color model is given along with sample code for using each model.
RGB color model
RGB is based on the primary colors of light—red, green, and blue.
  • When red, green, and blue rays of light coincide, white light is created. The RGB color model is therefore termed "additive" as adding the components together creates light.
  • An equal triad of fully saturated colors (255,255,255) illuminate white and conversely, 0 values illuminate nothing or black.
  • Equal triads between 0 and 100 produce pure gray shades.
An example of a function that creates an RGB-based color in ArcObjects is shown in the following code:
[Java]
static IRgbColor makeRGBColor(byte R, byte G, byte B)throws Exception{
    RgbColor rgbColor = new RgbColor();
    rgbColor.setRed(R);
    rgbColor.setGreen(G);
    rgbColor.setBlue(B);
    return rgbColor;
}
CMYK color model
CMYK is a color model based on the four color components of cyan, magenta, yellow, and black. The CMYK model, unlike RGB, is termed "subtractive" as adding all the components together creates an absence of light (black).
  • CMYK is the industry-standard color model for electronic publishing processes including offset-printing with color plates.
  • During the printing process, the ink coverage is controlled by the size of the dot or halftone screen percentage that is specified for each of the four process colors.
An example of a function that creates a CMYK-based color in ArcObjects is shown in the following code:
[Java]
static ICmykColor makeCmykColor(byte C, byte M, byte Y, byte k)throws Exception{
    CmykColor cmykColor = new CmykColor();
    cmykColor.setCyan(C);
    cmykColor.setMagenta(M);
    cmykColor.setYellow(Y);
    cmykColor.setBlack(k);
    return cmykColor;
}
HSV color model
HSV is a model calculated by the hue, saturation, and value color coordinate system in which the color space is represented by a single cone.
  • When the saturation is 100, the color is fully saturated.
  • When the saturation is 0, the color is a pure gray shade of the value specified.
  • When the value is 100 and any saturation is specified, a color tint is produced.
  • When the value is less than 100 and a saturation is specified, a shade is produced.
  • When the value is 0, the color is black.
An example of a function that creates an HSV-based color in ArcObjects is shown in the following code:
[Java]
static IHsvColor makeHSVColor(byte H, byte S, byte V)throws Exception{
    HsvColor hsvColor = new HsvColor();
    hsvColor.setHue(H);
    hsvColor.setSaturation(S);
    hsvColor.setValue(V);
    return hsvColor;
}
HLS color model
HLS is a model calculated by the hue, lightness, and saturation color coordinate system in which the color space is represented by a double-ended cone.
  • When lightness is 0, the color is black.
  • When lightness is 100, the color is white.
  • When lightness is greater than 50, a color tint is produced.
  • When lightness is less than 50, a color shade is produced.
  • When saturation is 100, the color is fully saturated. 
  • When saturation is 0, the color is a pure gray shade of the specified lightness.
An example of a function that creates an HLS-based color in ArcObjects is shown in the following code:
[Java]
static IHlsColor makeHLSColor(byte H, byte L, byte S)throws Exception{
    HlsColor hlsColor = new HlsColor();
    hlsColor.setHue(H);
    hlsColor.setLightness(L);
    hlsColor.setSaturation(S);
    return hlsColor;
}


See Also:

How to make a character marker symbol
How to make a gradient fill symbol
How to make a line callout
How to make a line fill symbol
How to make a picture marker symbol
How to make a cartographic line symbol




Development licensing Deployment licensing
ArcView ArcView
ArcEditor ArcEditor
ArcInfo ArcInfo
Engine Developer Kit Engine Runtime