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.
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).
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.
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.
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 licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine