Integration: the Gradient panel and Swatch Options send CMYK in model form

Main reads bare CMYK as 0..100 (#910), so the fractions both UIs sent turned M 100 % into M 1 %. The {model: cmyk} form takes fractions.
This commit is contained in:
aiongg
2026-10-16 03:25:55 +00:00
parent f7e6ba8f1a
commit af086dc145
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ fn dialog_color(f: &Map<String, Value>) -> Option<Color> {
/// A colour as `swatch.options` takes it (fractions, so 1% isn't read as 100%).
fn color_json(c: Color) -> Value {
match c {
Color::Cmyk { c, m, y, k } => json!({"c": c, "m": m, "y": y, "k": k}),
Color::Cmyk { c, m, y, k } => json!({"model": "cmyk", "c": c, "m": m, "y": y, "k": k}),
Color::Rgb { r, g, b } => json!([r, g, b]),
Color::Gray { k } => json!({"gray": k}),
}
+2 -2
View File
@@ -575,8 +575,8 @@ pub struct SwatchDrag(pub String);
fn color_json(c: &designcraft_color::Color) -> serde_json::Value {
use designcraft_color::Color;
match *c {
// Fractions: every component is within 0–1, so they're read back as fractions.
Color::Cmyk { c, m, y, k } => json!({"c": c, "m": m, "y": y, "k": k}),
// The model form takes fractions; bare CMYK would be read as 0..100.
Color::Cmyk { c, m, y, k } => json!({"model": "cmyk", "c": c, "m": m, "y": y, "k": k}),
Color::Gray { k } => json!({"model": "gray", "k": k}),
Color::Rgb { .. } => json!(c.to_hex()),
}