Merge main into feat/ai-editing-data

This commit is contained in:
dotCooCoo
2026-11-01 21:29:58 -08:00
32 changed files with 1049 additions and 318 deletions
@@ -111,6 +111,28 @@ fn redefining_the_symbol_keeps_the_changes_whose_objects_remain() {
assert_eq!(overrides(&s, inst), 0);
}
#[test]
fn replace_symbol_drops_the_changes_made_for_the_old_symbol() {
let mut s = session();
// "Other": two blue squares in the same places, the instance taken off the canvas.
let (a, b) = (square(&mut s, 10.0), square(&mut s, 60.0));
let first = id(&s.execute("symbol.new", &json!({"name": "Other", "ids": [a.0, b.0], "type": "dynamic"})).unwrap());
s.execute("edit.clear", &json!({"ids": [first.0]})).unwrap();
let inst = pair(&mut s, "dynamic");
s.execute("symbol.instance.setAppearance", &json!({"id": inst.0, "path": [1], "fill": "#ff0000"})).unwrap();
// The same symbol: nothing changes.
s.execute("symbol.replace", &json!({"name": "Pair", "ids": [inst.0]})).unwrap();
assert_eq!(overrides(&s, inst), 1);
assert_eq!(pixel(&s, 80, 30), RED);
s.execute("symbol.replace", &json!({"name": "Other", "ids": [inst.0]})).unwrap();
assert_eq!(overrides(&s, inst), 0, "the change named an object of Pair's art");
assert_eq!(pixel(&s, 80, 30), BLUE, "Other's art draws as the symbol has it");
s.execute("edit.undo", &json!({})).unwrap();
assert!(matches!(&node(&s, inst).kind, NodeKind::SymbolInstance { symbol, .. } if symbol == "Pair"));
assert_eq!(overrides(&s, inst), 1);
assert_eq!(pixel(&s, 80, 30), RED);
}
#[test]
fn reset_and_static_drop_the_changes_and_undo_brings_them_back() {
let mut s = session();
+29
View File
@@ -140,6 +140,35 @@ fn spot_gradients_export_as_separation_shadings() {
assert!(warnings.iter().any(|w| w.contains("spot")), "{warnings:?}");
}
#[test]
fn white_stops_linked_to_process_swatches_are_paper_in_spot_gradients() {
let (mut s, _) = setup();
run(&mut s, "swatch.new", json!({"name": "Paper", "color": "#ffffff", "global": true}));
let ink_to_paper = json!({"stops": [{"offset": 0, "swatch": "Ink", "tint": 80}, {"offset": 1, "swatch": "Paper"}]});
// As Ink → unlinked white: a Separation shading from 80 % to 0 %.
run(&mut s, "paint.editGradient", ink_to_paper.clone());
let (pdf, warnings) = pdf_of(&s);
assert!(pdf.contains("/ShadingType 2") && pdf.contains("/Separation/Ink/DeviceCMYK"), "a Separation shading");
assert!(!pdf.contains("/DeviceN") && pdf.contains("/C0[0.8]/C1[0]"), "the shading's tints");
assert!(!warnings.iter().any(|w| w.contains("spot")), "{warnings:?}");
// A Perceptual one too.
run(&mut s, "paint.editGradient", with(ink_to_paper, json!({"method": "perceptual"})));
let (pdf, _) = pdf_of(&s);
assert!(!pdf.contains("/Subtype/Image") && !pdf.contains("/DeviceN") && pdf.contains("/Separation/Ink/DeviceCMYK"), "Perceptual");
// With process yellow, the linked white stop adds no ink: Yellow and Ink only.
let yellow = json!({"c": 0, "m": 0, "y": 0.6, "k": 0});
let three =
json!({"stops": [{"offset": 0, "swatch": "Ink"}, {"offset": 0.5, "swatch": "Paper"}, {"offset": 1, "color": yellow}], "method": "classic"});
run(&mut s, "paint.editGradient", three);
let (pdf, _) = pdf_of(&s);
assert!(pdf.contains("/DeviceN[/Yellow/Ink]/DeviceCMYK") && pdf.contains("/C0[0 1]/C1[0 0]"), "Yellow and Ink");
// A white spot ink is an ink, not paper: a DeviceN shading of both spot inks.
run(&mut s, "swatch.new", json!({"name": "Opaque", "color": "#ffffff", "spot": true}));
run(&mut s, "paint.editGradient", json!({"stops": [{"offset": 0, "swatch": "Ink"}, {"offset": 1, "swatch": "Opaque"}]}));
let (pdf, _) = pdf_of(&s);
assert!(pdf.contains("/DeviceN[/Ink/Opaque]/DeviceCMYK"), "a white spot ink keeps its plate");
}
#[test]
fn spot_gradients_mixed_with_other_inks_export_as_device_n_shadings() {
let (mut s, _) = setup();