Skip to main content

preset_gradient

Function preset_gradient 

Source
pub fn preset_gradient(name: &str) -> Option<Gradient>
Expand description

A named colour map, baked into a Gradient (see PRESET_GRADIENTS).

Names are matched case-insensitively, and - or spaces may stand in for _, so "RdYlBu"-style names work as "rd-yl-bu".

use proof_engine::math::color::preset_gradient;
let turbo = preset_gradient("turbo").unwrap();
let lut = turbo.bake_lut(256); // ready to upload as a 1D texture
assert_eq!(lut.len(), 256);
assert!(preset_gradient("no such map").is_none());