|
scimesh 0.3.2
Headless CPU-only 3D software renderer for scientific mesh visualization
|
Self-contained colormap — owns a colour lookup table and supports linearly interpolated sampling. More...
#include <colormap.h>
Public Member Functions | |
| Color | sample (float t) const |
| Sample the colormap at a normalized position using linear interpolation. | |
| size_t | size () const |
| Number of entries in the colormap. | |
| bool | empty () const |
| True if the colormap has no entries. | |
Static Public Member Functions | |
| template<typename T > | |
| static ColorMap | from_uint8_colors (const std::vector< T > &cmap) |
Build a ColorMap from a vector of scibar-style uint8_t RGBA colours. | |
| static ColorMap | from_interleaved (const std::vector< uint8_t > &data, int channels=3) |
Build a ColorMap from a flat interleaved RGB(A) byte array. | |
| static const ColorMap & | viridis () |
| The Viridis perceptually-uniform sequential colormap (256 entries). | |
Public Attributes | |
| std::vector< Color > | colors |
| The colour lookup table entries in [0, 1] float RGBA. | |
Self-contained colormap — owns a colour lookup table and supports linearly interpolated sampling.
A ColorMap is simply a vector of Color entries plus a sample() method that performs linear interpolation between adjacent entries. The first entry corresponds to t = 0.0, the last to t = 1.0.
t.Definition at line 79 of file colormap.h.
|
inline |
True if the colormap has no entries.
Definition at line 103 of file colormap.h.
|
inlinestatic |
Build a ColorMap from a flat interleaved RGB(A) byte array.
| data | Flat array of RGB bytes (3 × n entries) or RGBA bytes (4 × n entries). |
| channels | 3 for RGB data, 4 for RGBA data. |
ColorMap with data.size() / channels entries.Definition at line 151 of file colormap.h.
|
inlinestatic |
Build a ColorMap from a vector of scibar-style uint8_t RGBA colours.
This is a duck-typed template — it works with any type T that has .r, .g, .b, .a fields as uint8_t in the range [0, 255]. No #include of scibar headers is required; the user simply passes their std::vector<scibar::Color> and it compiles.
| T | Any struct with uint8_t r, g, b, a fields. |
| cmap | The source colormap (e.g., from scibar::util::viridis()). |
ColorMap with the same entries converted to float [0, 1] RGBA.Definition at line 128 of file colormap.h.
| Color scimesh::ColorMap::sample | ( | float | t | ) | const |
Sample the colormap at a normalized position using linear interpolation.
| t | Normalized position in [0, 1]. Values outside this range are clamped: t < 0 → first entry, t > 1 → last entry. |
t, or transparent black if the colormap is empty.Definition at line 15 of file colormap.cpp.
|
inline |
Number of entries in the colormap.
Definition at line 100 of file colormap.h.
|
static |
The Viridis perceptually-uniform sequential colormap (256 entries).
Returns a 256-entry RGBA LUT. Viridis is perceptually uniform, colourblind-friendly, and prints well in greyscale. Identical to the matplotlib reference implementation.
ColorMap (cached after first call). Definition at line 195 of file colormap.cpp.
| std::vector<Color> scimesh::ColorMap::colors |
The colour lookup table entries in [0, 1] float RGBA.
Definition at line 81 of file colormap.h.