Show / Hide Table of Contents

    Class ColorScale

    A range of colors interpolated between a number of key values.

    Examples
    // Construct a color scale specifying only
    // a few colors. The rest will be interpolated.
    var colorScale = new ColorScale(new List<Color>() { Colors.Cyan, Colors.Purple, Colors.Orange });
    
    var i = 0;
    foreach (var c in colorScale.Colors)
    {
        var panel = new Panel(Polygon.Rectangle(1, 1), new Material($"Material{i}", c));
        panel.Transform.Move(new Vector3(i * 1.1, 0, 0));
        this.Model.AddElement(panel);
        i++;
    }
    
    Inheritance
    System.Object
    ColorScale
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Elements.Analysis
    Assembly: Hypar.Elements.dll
    Syntax
    public class ColorScale

    Constructors

    ColorScale(List<Color>)

    Create a ColorScale from a list of colors. The scale will automatically have a domain from 0 to 1.

    Declaration
    public ColorScale(List<Color> colors)
    Parameters
    Type Name Description
    System.Collections.Generic.List<Color> colors

    ColorScale(List<Color>, List<Double>)

    Construct a ColorScale from a list of colors and corresponding values

    Declaration
    public ColorScale(List<Color> colors, List<double> values)
    Parameters
    Type Name Description
    System.Collections.Generic.List<Color> colors

    The color scale's key values.

    System.Collections.Generic.List<System.Double> values

    List of values each color corresponds to on your scale. It expects one value per color, in ascending numerical order.

    ColorScale(List<Color>, Int32)

    Construct a color scale with a discrete number of color bands

    Declaration
    public ColorScale(List<Color> colors, int colorCount)
    Parameters
    Type Name Description
    System.Collections.Generic.List<Color> colors

    The color scale's key values.

    System.Int32 colorCount

    The number of colors in the final color scale These values will be interpolated between the provided colors.

    Properties

    Colors

    The colors of the scale.

    Declaration
    [JsonProperty]
    public List<Color> Colors { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<Color>

    Methods

    GetColor(Double)

    Get the color from the color scale most closely approximating the provided value.

    Declaration
    public Color GetColor(double t)
    Parameters
    Type Name Description
    System.Double t

    A number within the numerical parameters from when you constructed your color scale. If this was initiated with colorCount, must be between 0 and 1.

    Returns
    Type Description
    Color

    A color.

    GetColorForValue(Double)

    Get the color calculated for a value.

    Declaration
    [Obsolete("Use GetColor instead.")]
    public Color GetColorForValue(double t)
    Parameters
    Type Name Description
    System.Double t

    Value to return color for.

    Returns
    Type Description
    Color