How to make a gradient fill symbol


Summary This topic show how to create a gradient fill symbol that is based on an algorithmic color ramp.

Creating a gradient fill symbol

A gradient fill symbol is used for drawing a color ramp within the limits of the filled area. The GradientAngle controls the orientation of the gradient in the fill. The GradientPercentage controls the saturation and IntervalCount of the number of displayed colors.
Do the following steps to create a gradient fill symbol:
  1. Create the "from" color.
  2. Create the "to" color.
  3. Create the ramp for the gradient fill.
  4. Create the gradient fill.
The following code example shows the steps for creating a gradient fill using IAlgorithmicColorRamp:
[VB.NET]
Public Sub GradientFillSymbol()
    ' Create the from color for IAlgorithmicColorRamp.
    Dim startRgbColorCls As ESRI.ArcGIS.Display.IRgbColor = New ESRI.ArcGIS.Display.RgbColorClass
    With startRgbColorCls
        .Red = 255
        .Green = 255
        .Blue = 0
    End With
    
    ' Create the to color for IAlgorithmicColorRamp.
    Dim endRgbColorCls As ESRI.ArcGIS.Display.IRgbColor = New ESRI.ArcGIS.Display.RgbColorClass
    With endRgbColorCls
        .Red = 255
        .Green = 0
        .Blue = 0
    End With
    
    ' Create the ramp for the gradient fill.
    Dim algorithmicColorRampCls As ESRI.ArcGIS.Display.IAlgorithmicColorRamp = New ESRI.ArcGIS.Display.AlgorithmicColorRampClass
    With algorithmicColorRampCls
        .FromColor = startRgbColorCls
        .ToColor = endRgbColorCls
        .Algorithm = ESRI.ArcGIS.Display.esriColorRampAlgorithm.esriHSVAlgorithm
    End With
    
    ' Create the gradient fill.
    Dim gradientFillSymbolCls As ESRI.ArcGIS.Display.IGradientFillSymbol = New ESRI.ArcGIS.Display.GradientFillSymbolClass
    With gradientFillSymbolCls
        .ColorRamp = algorithmicColorRampCls
        .GradientAngle = 45
        .GradientPercentage = 0.9
        .IntervalCount = 15
        .Style = ESRI.ArcGIS.Display.esriGradientFillStyle.esriGFSLinear
    End With
    
End Sub
[C#]
public void GradientFillSymbol()
{
    // Create the from color for IAlgorithmicColorRamp.
    ESRI.ArcGIS.Display.IRgbColor startRgbColorCls = new
        ESRI.ArcGIS.Display.RgbColorClass();
    startRgbColorCls.Red = 255;
    startRgbColorCls.Green = 255;
    startRgbColorCls.Blue = 0;

    // Create the to color for IAlgorithmicColorRamp.
    ESRI.ArcGIS.Display.IRgbColor endRgbColorCls = new
        ESRI.ArcGIS.Display.RgbColorClass();
    endRgbColorCls.Red = 255;
    endRgbColorCls.Green = 0;
    endRgbColorCls.Blue = 0;

    // Create the ramp for the gradient fill.
    ESRI.ArcGIS.Display.IAlgorithmicColorRamp algorithmicColorRampCls = new
        ESRI.ArcGIS.Display.AlgorithmicColorRampClass();
    algorithmicColorRampCls.FromColor = startRgbColorCls;
    algorithmicColorRampCls.ToColor = endRgbColorCls;
    algorithmicColorRampCls.Algorithm =
        ESRI.ArcGIS.Display.esriColorRampAlgorithm.esriHSVAlgorithm;

    // Create the gradient fill.
    ESRI.ArcGIS.Display.IGradientFillSymbol gradientFillSymbolCls = new
        ESRI.ArcGIS.Display.GradientFillSymbolClass();
    gradientFillSymbolCls.ColorRamp = algorithmicColorRampCls;
    gradientFillSymbolCls.GradientAngle = 45;
    gradientFillSymbolCls.GradientPercentage = 0.9;
    gradientFillSymbolCls.IntervalCount = 15;
    gradientFillSymbolCls.Style =
        ESRI.ArcGIS.Display.esriGradientFillStyle.esriGFSLinear;
}


See Also:

How to make a cartographic line symbol
How to make a character marker symbol
How to make a line callout
How to make a line fill symbol
How to make a picture marker symbol
Creating custom symbols
Creating other kinds of custom symbols
How to make different types of colors and color ramps




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