百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

tinycolormap

> 数据库
开源

一个仅包含头文件的单文件库,用 C++11 编写的色彩映射

377 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

一个仅包含头文件的单文件库,用 C++11 编写的色彩映射

tinycolormap

A header-only, single-file library for colormaps written in C++11.

Available Colormaps

Matlab

Name Sample
Parula
Heat
Hot
Jet
Gray
HSV

Reference:

The HSV colormap is cyclic and is particularly useful for plotting angles or phases because the color transition from 1 to 0 is smooth. A phase wrap would thus not appear as a sharp edge.

Matplotlib

Name Sample
Magma
Inferno
Plasma
Viridis
Cividis

These colormaps are designed to be perceptually uniform (even in black-and-white printing) and friendly to colorblindness. Cividis is specially designed such that it enables as identical interpretation to both those without a CVD and those with red-green colorblindness as possible.

Magma, Inferno, Plasma, Viridis are released under CC0 by Nathaniel J. Smith, Stefan van der Walt, and (in the case of Viridis) Eric Firing: . Their python code is adapted for the use in C++11.

Cividis is released under CC0 by the authors of PLOS ONE paper (Jamie R. Nuñez, Christopher R. Anderton, Ryan S. Renslow): . We incorporated the LUT into C++11.

GitHub

Name Sample
Github

This colormap is designed to mimic the color scheme used in GitHub contributions visualization.

Other

Name Sample
Turbo

Turbo is developed as an alternative to the Jet colormap by Anton Mikhailov (Google LLC). See the blog post for the details. The original lookup table is released under the Apache 2.0 license. We merged it and re-licensed the part under the MIT license for consistency.

Name Sample
Cubehelix

Cubehelix is developed by Dr. Dave Green and is designed for astronomical intensity images. It shows a continuous increase in perceived intensity when shown in color or greyscale. This implementation uses Green's "default" scheme (start: 0.5, rotations: -1.5, hue: 1.0, gamma: 1.0). See the original publication for details.

Dependency

tinycolormap does not have any dependencies except for C++11 standard library.

Installation

tinycolormap is a header-only library, so you do not need to compile it. You can use it by

  • Adding the path to the include directory in the cloned tinycolormap repository to your project's include paths, or
  • Copying the file tinycolormap.hpp to your project (note that tinycolormap consists of only that single file).

If your project is managed by Cmake , add_subdirectory or ExternalProject_Add commands are useful as tinycolormap provides CMakeLists.txt for this purpose.

Usage

The core function of this library is

cpp
inline Color GetColor(double x, ColormapType type);

where x should be between 0.0 and 1.0 (otherwise, it will be cropped), and type is the target colormap type like Viridis (default) and Heat.

Here is a working code:

cpp
#include 
#include 

int main()
{
  // Define a target value. This value should be in [0, 1]; otherwise, it will be cropped to 0 or 1.
  const double value = 0.5;

  // Get the mapped color. Here, Viridis is specified as the colormap.
  const tinycolormap::Color color = tinycolormap::GetColor(value, tinycolormap::ColormapType::Viridis);

  // Print the RGB values. Each value is in [0, 1].
  std::cout 

(or TINYCOLORMAP_WITH_QT5 CMake option is ON), this library offers an additional utility function:

cpp
const QColor color = tinycolormap::GetColor(x).ConvertToQColor();

Eigen Support

When TINYCOLORMAP_WITH_EIGEN is defined before including tinycolormap.hpp, for example,

cpp
#define TINYCOLORMAP_WITH_EIGEN
#include 

(or TINYCOLORMAP_WITH_EIGEN CMake option is ON), this library offers an additional utility function:

cpp
const Eigen::Vector3d color = tinycolormap::GetColor(x).ConvertToEigen();

Qt5 and Eigen Support

When both Qt5 and Eigen are available, this library offers additional utility functions:

cpp
inline QImage CreateMatrixVisualization(const Eigen::MatrixXd& matrix);
inline void ExportMatrixVisualization(const Eigen::MatrixXd& matrix, const std::string& path);

GLM Support

When TINYCOLORMAP_WITH_GLM is defined before including tinycolormap.hpp, for example,

cpp
#define TINYCOLORMAP_WITH_GLM
#include 

(or TINYCOLORMAP_WITH_GLM CMake option is ON), this library offers an additional utility function:

cpp
const glm::vec3 color = tinycolormap::GetColor(x).ConvertToGLM();

Tools (Optional)

This repository includes the following optional tools:

  • PNG Exporter: This tool exports all the available colormaps as PNG images.

Tools Build Instruction

The optional tools are managed by CMake . They can be built by, for example,

bash
mkdir build
cd build
cmake [PATH_TO_TINYCOLORMAP] -DTINYCOLORMAP_BUILD_TOOLS=ON
make

Projects using tinycolormap

  • riCOM
  • OpenSiv3D
  • SLiM
  • Neper: Polycrystal Generation and Meshing
  • Unblending (Pacific Graphics 2018)
  • OptiMo (CHI 2018)
  • Sequential Line Search (SIGGRAPH 2017)
  • SelPh (CHI 2016)
  • VisOpt Slider (UIST 2014)

License

The MIT License (except for tools/png-exporter/stb_image_write.h, which is released under public domain).

Contribute

Pull requests are welcome.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++colorcolormapheader-onlymap

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库