Magnum::DebugTools::ColorMap namespace new in 2020.06

Color maps.

A collection of predefined color maps for visualization of gradient data.

This library is built if MAGNUM_WITH_DEBUGTOOLS is enabled when building Magnum. To use this library with CMake, request the DebugTools component of the Magnum package and link to the Magnum::DebugTools target:

find_package(Magnum REQUIRED DebugTools)

# ...
target_link_libraries(your-app PRIVATE Magnum::DebugTools)

See Downloading and building, Usage with CMake and Debugging helpers for more information.

For all color maps the returned data is the sRGB colorspace. Desired usage is by uploading to a texture with linear filtering, depending on the use case with either clamp or repeat wrapping. For a sRGB workflow don't forget to set the texture format to sRGB, to ensure the values are interpreted and interpolated done correctly.

const auto map = DebugTools::ColorMap::turbo();
const Vector2i size{Int(map.size()), 1};

GL::Texture2D colorMapTexture;
colorMapTexture
    .setMinificationFilter(SamplerFilter::Linear)
    .setMagnificationFilter(SamplerFilter::Linear)
    .setWrapping(SamplerWrapping::ClampToEdge) // or Repeat
    .setStorage(1, GL::TextureFormat::RGB8, size) // or SRGB8
    .setSubImage(0, {}, ImageView2D{PixelFormat::RGB8Srgb, size, map});

Functions

auto turbo() -> Containers::StaticArrayView<256, const Vector3ub> new in 2020.06
Turbo colormap.
auto magma() -> Containers::StaticArrayView<256, const Vector3ub> new in 2020.06
Magma colormap.
auto plasma() -> Containers::StaticArrayView<256, const Vector3ub> new in 2020.06
Plasma colormap.
auto inferno() -> Containers::StaticArrayView<256, const Vector3ub> new in 2020.06
Inferno colormap.
auto viridis() -> Containers::StaticArrayView<256, const Vector3ub> new in 2020.06
Viridis colormap.
auto coolWarmSmooth() -> Containers::StaticArrayView<256, const Vector3ub> new in Git master
Smooth Cool-Warm colormap.
auto coolWarmBent() -> Containers::StaticArrayView<256, const Vector3ub> new in Git master
Bent Cool-Warm colormap.

Function documentation

Containers::StaticArrayView<256, const Vector3ub> Magnum::DebugTools::ColorMap::turbo() new in 2020.06

Turbo colormap.

Image

Containers::StaticArrayView<256, const Vector3ub> Magnum::DebugTools::ColorMap::magma() new in 2020.06

Magma colormap.

Image

Containers::StaticArrayView<256, const Vector3ub> Magnum::DebugTools::ColorMap::plasma() new in 2020.06

Plasma colormap.

Image

Containers::StaticArrayView<256, const Vector3ub> Magnum::DebugTools::ColorMap::inferno() new in 2020.06

Inferno colormap.

Image

Containers::StaticArrayView<256, const Vector3ub> Magnum::DebugTools::ColorMap::viridis() new in 2020.06

Viridis colormap.

Image

Containers::StaticArrayView<256, const Vector3ub> Magnum::DebugTools::ColorMap::coolWarmSmooth() new in Git master

Smooth Cool-Warm colormap.

Image

It is a diverging (double-ended) color map with a smooth transition in the middle to prevent artifacts at the midpoint. Although not isoluminant, this color map avoids dark colors to allow shading cues throughout.

Containers::StaticArrayView<256, const Vector3ub> Magnum::DebugTools::ColorMap::coolWarmBent() new in Git master

Bent Cool-Warm colormap.

Image

This color map is similar coolWarmSmooth() except that the luminance is interpolated linearly with a sharp bend in the middle. This makes for less washed out colors in the middle, but also creates an artifact at the midpoint.