ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / ColorFactory Class
Members Example

In This Topic
    ColorFactory Class
    In This Topic
    Provides methods for creating color.
    Object Model
    ColorFactory ClassCIMColor ClassCIMColor ClassCIMColorRamp ClassCIMColor ClassCIMHSVColor ClassCIMRGBColor ClassCIMColor ClassCIMColor ClassCIMColorRamp ClassCIMColor ClassCIMColor ClassIColorFactory InterfaceCIMColor ClassCIMColorRamp ClassCIMColor Class
    Syntax
    public class ColorFactory : IColorFactory  
    Public Class ColorFactory 
       Implements IColorFactory 
    Example
    Create Ellipse Graphic Element
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    Coordinate2D center = new Coordinate2D(2, 2.75);
    var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, 
                                           ArcOrientation.ArcClockwise);
    var ellipse = eabElp.ToSegment();
    
    //Set symbolology, create and add element to layout
    CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
                                    ColorFactory.Instance.GreenRGB, 2.0,
                            SimpleLineStyle.Dot);
    CIMPolygonSymbol ellipseSym = SymbolFactory.Instance.ConstructPolygonSymbol(
                             ColorFactory.Instance.GreyRGB, SimpleFillStyle.Vertical, 
                                                      outline);
    
    var poly = PolygonBuilderEx.CreatePolygon(
      PolylineBuilderEx.CreatePolyline(ellipse, AttributeFlags.AllAttributes));
    
    var elpElm = ElementFactory.Instance.CreateGraphicElement(
      container, poly, ellipseSym, "New Ellipse");
    Snippet Mesh material fill symbol
    /// <summary>
    /// Create a mesh symbol that can be applied to a multi-patch feature layer.
    /// </summary>
    /// <remarks>
    /// A mesh symbol is a CIMMeshSymbol object.  Define an array of CIMSymbolLayers which contains a CIMMaterialSymbol layer with the specified properties such as Color, etc.
    /// Assign this array of CIMSymbolLayers to the CIMMeshSymbol.
    /// ![MeshSymbolOrange](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/mesh-material-orange.png)
    /// </remarks>
    /// <returns></returns>
    public static Task<CIMMeshSymbol> CreateMeshSymbolAsync()
    {
        return QueuedTask.Run<CIMMeshSymbol>(() =>
       {
           CIMSymbolLayer[] materialSymbolLayer =
          {
                new CIMMaterialSymbolLayer()
                {
                    Color = ColorFactory.Instance.CreateRGBColor(230,152,0),
                    MaterialMode = MaterialMode.Multiply
                }
           };
           var myMeshSymbol = new CIMMeshSymbol()
           {
               SymbolLayers = materialSymbolLayer
           };
           return myMeshSymbol;
       });
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.ColorFactory

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also