Skip to content

ChartColormaps

ClassChartGuruChartGuru
public static class ChartColormaps

Evaluates 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.

public const int ControlPointCount = 256

Number of published control points of every named map.

Returns

System.Int32

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

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

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[]
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[]
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