mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-26 11:16:50 -06:00
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:
@@ -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}),
|
||||
}
|
||||
|
||||
@@ -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()),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user