DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Integration: #1451 screened outer glows and blended shadows isolate the spread from the paper
aiongg7d16fffb3932
diff --git a/crates/render/src/color.rs b/crates/render/src/color.rsindex c4406b73c..84d648128 100644--- a/crates/render/src/color.rs+++ b/crates/render/src/color.rs@@ -202,7 +202,11 @@ pub(crate) fn overprints(f: &Frame, swatch: &str, tint: f32, flag: bool) -> boolpub(crate) fn spread_blends(doc: &Document, sp: &designcraft_doc::Spread) -> bool {let blends = |it: &Item| {let mut any = false;- it.walk(&mut |i| any |= i.blend != Default::default());+ // A screened glow or a shadow with a blend mode blends with the objects below too, not the paper.+ let fx_blends = |e: &designcraft_doc::Effects| {+ (e.outer_glow.on && e.outer_glow.mode != Default::default()) || (e.drop_shadow.on && e.drop_shadow.mode != Default::default())+ };+ it.walk(&mut |i| any |= i.blend != Default::default() || fx_blends(&i.effects));any};sp.items.iter().any(|i| blends(i)) || doc.parents.iter().any(|p| p.items.iter().any(|i| blends(i)))diff --git a/crates/render/tests/it/effects.rs b/crates/render/tests/it/effects.rsindex 967856d24..267d538f9 100644--- a/crates/render/tests/it/effects.rs+++ b/crates/render/tests/it/effects.rs@@ -178,6 +178,23 @@ fn outer_glow_blends_with_its_mode() {assert!(s[2] > n[2] + 25, "screen keeps the backdrop's blue: {s:?} vs normal {n:?}");}+/// A screened glow over blank paper shows in its colour: it blends with the objects below, and+/// the paper is not one of them.+#[test]+fn screened_outer_glow_shows_on_blank_paper() {+ let mut d = doc();+ let id = rect_item(&mut d, Rect::new(50.0, 50.0, 110.0, 110.0), "[Black]");+ let g = &mut d.item_mut(id).unwrap().effects.outer_glow;+ g.on = true;+ g.size = 12.0;+ g.color = "C=0 M=0 Y=100 K=0".into();+ g.opacity = 1.0;+ g.mode = designcraft_color::BlendMode::Screen;+ let img = render(&d);+ let p = img.pixel(46, 80);+ assert!(p[2] < 200 && p[0] > p[2] + 40, "yellow glow beside the item: {p:?}");+}+#[test]fn inner_shadow_darkens_inside_the_lit_edge() {let mut d = doc();