ChartColormaps
public static class ChartColormapsEvaluates ChartColormap maps from their published 256-entry tables, samples them into lookup tables
and converts them to Unity gradients. Colors are sRGB, like the colors of a Gradient.
Fields
Section titled “Fields”
ControlPointCount
Section titled “ControlPointCount”public const int ControlPointCount = 256Number of published control points of every named map.
Returns
System.Int32
Methods
Section titled “Methods”
IsNamed(ChartColormap)
Section titled “IsNamed(ChartColormap)”public static bool IsNamed(ChartColormap colormap)Whether colormap names a published map, rather than being ChartColormap.Custom or undefined.
Parameters
| Name | Type |
|---|---|
colormap |
ChartGuru.ChartColormap |
Returns
System.Boolean
Evaluate(ChartColormap, float)
Section titled “Evaluate(ChartColormap, float)”public static Color Evaluate(ChartColormap colormap, float t)The color of colormap at t, from 0 at the low end to 1 at the high end,
interpolated linearly between the published control points. Values outside 0 to 1 are clamped and NaN reads as 0.
Parameters
| Name | Type |
|---|---|
colormap |
ChartGuru.ChartColormap |
t |
System.Single |
Returns
UnityEngine.Color
Sample(ChartColormap, Color[])
Section titled “Sample(ChartColormap, Color[])”public static void Sample(ChartColormap colormap, Color[] destination)Fills destination with evenly spaced colors of colormap, from the low end
in the first element to the high end in the last; a single element takes the middle color. Use it for lookup
textures and swatches.
Parameters
| Name | Type |
|---|---|
colormap |
ChartGuru.ChartColormap |
destination |
UnityEngine.Color[] |
Sample(ChartColormap, Color32[])
Section titled “Sample(ChartColormap, Color32[])”public static void Sample(ChartColormap colormap, Color32[] destination)Fills the Color32 array with evenly spaced colors from the colormap, low to high; one element receives the midpoint color.
Parameters
| Name | Type |
|---|---|
colormap |
ChartGuru.ChartColormap |
destination |
UnityEngine.Color32[] |
CreateGradient(ChartColormap)
Section titled “CreateGradient(ChartColormap)”public static Gradient CreateGradient(ChartColormap colormap)A new opaque gradient for code that needs a Unity Gradient, which holds at most eight keys. Its keys
are the eight published control points that keep it closest to the full table: within 5/255 per channel for
viridis, magma, plasma and cividis, 8/255 for inferno and 12/255 for turbo. Color scales and theme colormaps
evaluate the full table instead.
Parameters
| Name | Type |
|---|---|
colormap |
ChartGuru.ChartColormap |
Returns
UnityEngine.Gradient