diff --git a/color-module/src/lib.rs b/color-module/src/lib.rs index bb9c464..cf658bd 100644 --- a/color-module/src/lib.rs +++ b/color-module/src/lib.rs @@ -343,15 +343,16 @@ pub fn tonal_lighten_series( let mut color_series = Vec::new(); let mut lightness = hct.lightness; for _ in 1..=expand_amount { - lightness += (1.0 - lightness) * step; + lightness += (100.0 - lightness) * step; let lightened_color = Cam16Jch::new(lightness, hct.chroma, hct.hue); let srgb = Srgb::from_color(lightened_color.into_xyz(Parameters::default_static_wp(40.0))); color_series.push(format!("{:x}", srgb.into_format::())); } - Ok(color_series.into_iter().rev().collect()) + Ok(color_series) } +#[wasm_bindgen] pub fn tonal_darken_series( color: &str, expand_amount: i16, @@ -368,11 +369,11 @@ pub fn tonal_darken_series( let mut color_series = Vec::new(); let mut lightness = hct.lightness; for _ in 1..=expand_amount { - lightness *= step; + lightness *= 1.0 - step; let darkened_color = Cam16Jch::new(lightness, hct.chroma, hct.hue); let srgb = Srgb::from_color(darkened_color.into_xyz(Parameters::default_static_wp(40.0))); color_series.push(format!("{:x}", srgb.into_format::())); } - Ok(color_series) + Ok(color_series.into_iter().rev().collect()) }