str2col

Function str2col 

Source
pub fn str2col<T: DType, const N: usize>(s: &str) -> Option<(Space, [T; N])>
Expand description

Convert a string into a space/array combo. Separated with spaces, ‘;’, ‘:’, or ‘,’

Can additionally be set as a % of SDR range.

Alpha will be NaN if only 3 values are provided.

§Examples

use colcon::{str2col, Space};

assert_eq!(str2col("0.2, 0.5, 0.6"), Some((Space::SRGB, [0.2f32, 0.5, 0.6])));
assert_eq!(str2col("lch:50;20;120"), Some((Space::CIELCH, [50.0f32, 20.0, 120.0])));
assert_eq!(str2col("oklab(0.2, 0.6, -0.5)"), Some((Space::OKLAB, [0.2f32, 0.6, -0.5])));
assert_eq!(str2col("srgb 100% 50% 25%"), Some((Space::SRGB, [1.0f32, 0.5, 0.25])));