Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

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

aionggaf086dc145e8
diff --git a/crates/ui-egui/src/dialogs/options.rs b/crates/ui-egui/src/dialogs/options.rs
index abec47b45..d8aba2bea 100644
--- a/crates/ui-egui/src/dialogs/options.rs
+++ b/crates/ui-egui/src/dialogs/options.rs
@@ -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}),
}
diff --git a/crates/ui-egui/src/panels/swatches.rs b/crates/ui-egui/src/panels/swatches.rs
index fd0086ead..35c264657 100644
--- a/crates/ui-egui/src/panels/swatches.rs
+++ b/crates/ui-egui/src/panels/swatches.rs
@@ -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()),
}