Skip to content

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

Effects: blend modes for Drop Shadow, Inner Shadow and Outer Glow

moppeeer75d72c69b59a
diff --git a/ROADMAP.md b/ROADMAP.md
index 0128924c0..2e579b927 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -348,6 +348,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.m
Newest first.
+- **2026-10-21** · Drop Shadow, Inner Shadow and Outer Glow have a blend mode, as InDesign's (Effects dialog › Blending › Mode; `mode` on `object.dropShadow`, `object.innerShadow`, `object.outerGlow`; IDML `BlendMode`). New shadows start Multiply and new outer glows Screen in white ([Paper]); effects saved before keep Normal, so documents look as they did. Found in the Learn Skills Daily course, chapter 14. No readiness percentage change.
- **2026-10-16** · Type › Reload Fonts (`font.reload`): fonts installed, edited or removed while DesignCraft runs are read again without a restart, and the open documents recompose with them (#328, #547). An edited font file is noticed by its length and modification time; bundled, added and document fonts stay as they are. InDesign does this by itself, so noticing changes automatically is still open (gap 6). No readiness percentage change.
- **2026-10-16** · Parents can be deleted from their Pages-panel context menu or `layout.parents.delete {id}`. Applied-page and based-on references are cleared, local override copies survive, and Undo restores the parent. Addresses the deletion portion of #956; no readiness percentage change.
- **2026-10-17** · File › Package writes the document's and the IDML's links relative to the package (`Links/logo.png`, `file:Links/logo.png`), so a package holds no path from the machine that made it; opening a document resolves them to the files beside it. Links › Copy Link(s) To still links by full path. (#340). No readiness percentage change.
diff --git a/crates/doc/src/item.rs b/crates/doc/src/item.rs
index cfb13dc53..6da69b9e2 100644
--- a/crates/doc/src/item.rs
+++ b/crates/doc/src/item.rs
@@ -973,12 +973,22 @@ pub struct DropShadow {
pub distance: f64,
pub size: f64,
pub spread: f64,
+ /// How the shadow blends with what's behind it (InDesign: Multiply). A document saved before
+ /// effects had modes reads Normal, as they were drawn then.
+ #[serde(default = "normal_blend")]
+ pub mode: BlendMode,
+}
+
+/// The blend of an effect saved before effects had one.
+fn normal_blend() -> BlendMode {
+ BlendMode::Normal
}
impl Default for DropShadow {
fn default() -> Self {
DropShadow {
on: false,
+ mode: BlendMode::Multiply,
color: designcraft_color::swatch::BLACK.into(),
opacity: 0.75,
angle: 120.0,
@@ -1005,12 +1015,16 @@ pub struct InnerShadow {
pub size: f64,
/// Percentage (0–100) of `size` that hardens the edge instead of blurring it.
pub choke: f64,
+ /// How the shadow blends with the object (InDesign: Multiply; Normal when saved before).
+ #[serde(default = "normal_blend")]
+ pub mode: BlendMode,
}
impl Default for InnerShadow {
fn default() -> Self {
InnerShadow {
on: false,
+ mode: BlendMode::Multiply,
color: designcraft_color::swatch::BLACK.into(),
opacity: 0.75,
angle: 120.0,
@@ -1032,11 +1046,15 @@ pub struct OuterGlow {
pub size: f64,
/// Percentage (0–100) of `size` that grows the silhouette instead of blurring it.
pub spread: f64,
+ /// How the glow blends with what's behind it (InDesign: Screen; Normal when saved before).
+ #[serde(default = "normal_blend")]
+ pub mode: BlendMode,
}
impl Default for OuterGlow {
fn default() -> Self {
- OuterGlow { on: false, color: designcraft_color::swatch::BLACK.into(), opacity: 0.75, size: 7.0, spread: 0.0 }
+ // InDesign starts a glow screened in white.
+ OuterGlow { on: false, color: designcraft_color::swatch::PAPER.into(), opacity: 0.75, size: 7.0, spread: 0.0, mode: BlendMode::Screen }
}
}
@@ -1639,6 +1657,23 @@ mod tests {
use super::*;
use designcraft_geom::shapes;
+ /// Shadows and glows saved before they had a blend mode read Normal, as they were drawn;
+ /// new ones start as InDesign's: Multiply for shadows, Screen for the outer glow.
+ #[test]
+ fn effect_blend_modes_default_as_indesign_and_keep_old_documents() {
+ let old: DropShadow =
+ serde_json::from_str(r#"{"on": true, "color": "[Black]", "opacity": 0.75, "angle": 120, "distance": 7, "size": 5, "spread": 0}"#)
+ .unwrap();
+ assert_eq!(old.mode, BlendMode::Normal);
+ let old: OuterGlow = serde_json::from_str(r#"{"on": true, "color": "[Black]", "opacity": 0.75, "size": 7, "spread": 0}"#).unwrap();
+ assert_eq!(old.mode, BlendMode::Normal);
+ assert_eq!(DropShadow::default().mode, BlendMode::Multiply);
+ assert_eq!(InnerShadow::default().mode, BlendMode::Multiply);
+ assert_eq!(OuterGlow::default().mode, BlendMode::Screen);
+ let saved = serde_json::to_value(DropShadow { mode: BlendMode::Screen, ..Default::default() }).unwrap();
+ assert_eq!(serde_json::from_value::<DropShadow>(saved).unwrap().mode, BlendMode::Screen, "round trip");
+ }
+
#[test]
fn graphics_without_a_clipping_path_load_and_save_as_before() {
let g = Graphic {
diff --git a/crates/engine/src/cmd/object.rs b/crates/engine/src/cmd/object.rs
index 82f33a6d8..29358fcac 100644
--- a/crates/engine/src/cmd/object.rs
+++ b/crates/engine/src/cmd/object.rs
@@ -382,7 +382,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Drop Shadow",
["Object", "Effects"],
Some("Cmd+Alt+M"),
- "{on?: bool, distance?, angle?, globalLight?: bool, opacity?, size?, spread? (%), color? (swatch), ids?}",
+ "{on?: bool, distance?, angle?, globalLight?: bool, opacity?, size?, spread? (%), color? (swatch), mode?: blend mode (multiply…), ids?}",
has_selection,
|s, p| {
let p2 = p.clone();
@@ -398,6 +398,9 @@ pub fn specs() -> Vec<CommandSpec> {
if let Some(c) = str_param(&p2, "color") {
ds.color = c.into();
}
+ if let Some(m) = blend_param(&p2) {
+ ds.mode = m;
+ }
})
}
),
@@ -406,7 +409,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Inner Shadow",
["Object", "Effects"],
None,
- "{on?: bool, distance?, angle?, globalLight?: bool, opacity?, size?, choke? (%), color?, ids?}",
+ "{on?: bool, distance?, angle?, globalLight?: bool, opacity?, size?, choke? (%), color?, mode?: blend mode, ids?}",
has_selection,
|s, p| {
let p2 = p.clone();
@@ -422,6 +425,9 @@ pub fn specs() -> Vec<CommandSpec> {
if let Some(c) = str_param(&p2, "color") {
e.color = c.into();
}
+ if let Some(m) = blend_param(&p2) {
+ e.mode = m;
+ }
})
}
),
@@ -430,7 +436,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Outer Glow",
["Object", "Effects"],
None,
- "{on?: bool, opacity?, size?, spread? (%), color?, ids?}",
+ "{on?: bool, opacity?, size?, spread? (%), color?, mode?: blend mode (screen…), ids?}",
has_selection,
|s, p| {
let p2 = p.clone();
@@ -443,6 +449,9 @@ pub fn specs() -> Vec<CommandSpec> {
if let Some(c) = str_param(&p2, "color") {
e.color = c.into();
}
+ if let Some(m) = blend_param(&p2) {
+ e.mode = m;
+ }
})
}
),
@@ -3101,6 +3110,12 @@ fn align(s: &mut Session, p: &Value) -> Result<Value> {
})
}
+/// An effect's `mode` parameter: a blend mode by name ("multiply", "screen", or as saved).
+fn blend_param(p: &Value) -> Option<BlendMode> {
+ let v = p.get("mode")?;
+ v.as_str().and_then(BlendMode::parse).or_else(|| serde_json::from_value(v.clone()).ok())
+}
+
fn distribute(s: &mut Session, p: &Value) -> Result<Value> {
let ids = targets(s, p)?;
if ids.len() < 3 && p.get("spacing").is_none() {
@@ -4055,6 +4070,21 @@ mod label_tests {
mod light_tests {
use super::*;
+ /// The shadow and glow commands take a blend mode by name.
+ #[test]
+ fn shadow_and_glow_commands_take_a_blend_mode() {
+ let mut s = Session::new();
+ s.execute("file.new", &json!({})).unwrap();
+ let id = s.execute("frame.create", &json!({"rect": [72, 72, 172, 172]})).unwrap()["id"].as_u64().unwrap();
+ s.execute("object.dropShadow", &json!({"on": true, "mode": "screen", "ids": [id]})).unwrap();
+ s.execute("object.innerShadow", &json!({"on": true, "mode": "overlay", "ids": [id]})).unwrap();
+ s.execute("object.outerGlow", &json!({"on": true, "mode": "normal", "ids": [id]})).unwrap();
+ let fx = s.doc().unwrap().doc.item(ItemId(id)).unwrap().effects.clone();
+ assert_eq!(fx.drop_shadow.mode, BlendMode::Screen);
+ assert_eq!(fx.inner_shadow.mode, BlendMode::Overlay);
+ assert_eq!(fx.outer_glow.mode, BlendMode::Normal);
+ }
+
#[test]
fn global_light_moves_shadows_that_use_it() {
let mut s = Session::new();
diff --git a/crates/idml/src/export.rs b/crates/idml/src/export.rs
index 86fef8e46..1a845a2ac 100644
--- a/crates/idml/src/export.rs
+++ b/crates/idml/src/export.rs
@@ -2067,6 +2067,7 @@ impl<'a> Ex<'a> {
.attr("Size", num(ds.size))
.attr("Spread", num(ds.spread))
.attr("Opacity", pct(ds.opacity as f64))
+ .attr("BlendMode", names::blend_out(ds.mode))
.attr("EffectColor", self.sw(&ds.color)),
);
}
diff --git a/crates/idml/src/import.rs b/crates/idml/src/import.rs
index d770aef79..30a5caa34 100644
--- a/crates/idml/src/import.rs
+++ b/crates/idml/src/import.rs
@@ -2699,6 +2699,7 @@ impl<'r> Importer<'r> {
size: ds.num("Size").unwrap_or(def.size),
spread: ds.num("Spread").unwrap_or(def.spread),
global_light: false,
+ mode: ds.get("BlendMode").map_or(def.mode, names::blend_in),
};
}
if let Some(f) = t.find("FeatherSetting")
diff --git a/crates/render/src/fx.rs b/crates/render/src/fx.rs
index 6147c9cf5..e7f54a3ea 100644
--- a/crates/render/src/fx.rs
+++ b/crates/render/src/fx.rs
@@ -102,19 +102,25 @@ impl Renderer {
let mut below = vec![];
if e.outer_glow.on {
let g = &e.outer_glow;
- below.push((Vec2::ZERO, g.size, g.spread, g.color.clone(), g.opacity));
+ below.push((Vec2::ZERO, g.size, g.spread, g.color.clone(), g.opacity, g.mode));
}
if e.drop_shadow.on {
let d = &e.drop_shadow;
- below.push((offset(doc.light_angle(d.angle, d.global_light), d.distance), d.size, d.spread, d.color.clone(), d.opacity));
+ below.push((offset(doc.light_angle(d.angle, d.global_light), d.distance), d.size, d.spread, d.color.clone(), d.opacity, d.mode));
}
- for (off, size, pct, color, opacity) in below {
+ for (off, size, pct, color, opacity, mode) in below {
let Some(c) = doc.resolve_color(&color, 1.0) else { continue };
let (sigma, grow) = split(size, pct);
let filter = shadow(sigma, color_of(&c, opacity.clamp(0.0, 1.0)));
// The offset moves the geometry, not the filter: vello drops layer content that lies
// entirely outside the viewport before filtering.
let r = (reach + off).inflate(grow, grow);
+ // The effect's blend sees what's behind the object: a layer around the filtered one.
+ let mix = crate::blend_mode(mode).mix;
+ if mix != Mix::Normal {
+ ctx.set_transform(Affine::IDENTITY);
+ ctx.push_layer(None, Some(BlendMode::new(mix, Compose::SrcOver)), None, None, None);
+ }
self.with_filters(ctx, f, r, sigma, None, |me, c, fr| {
let moved = Frame { view: fr.view * Affine::translate(off), ..*fr };
c.set_transform(moved.view);
@@ -128,6 +134,9 @@ impl Renderer {
}
c.pop_layer();
});
+ if mix != Mix::Normal {
+ ctx.pop_layer();
+ }
}
// Gradient feather: the object (feathered or not) drawn in its own layer, then kept as
// much as the opacity gradient says.
@@ -218,7 +227,7 @@ impl Renderer {
let s = &e.inner_shadow;
let (sigma, choke) = split(s.size, s.choke);
let off = offset(doc.light_angle(s.angle, s.global_light), s.distance);
- self.inner_edge(ctx, f, reach, bp, xf, off, sigma, choke, color_of(&c, s.opacity.clamp(0.0, 1.0)), Mix::Normal);
+ self.inner_edge(ctx, f, reach, bp, xf, off, sigma, choke, color_of(&c, s.opacity.clamp(0.0, 1.0)), crate::blend_mode(s.mode).mix);
}
// Inner glow: from the edges inwards (or out from the centre), screened over the object.
if e.inner_glow.on
diff --git a/crates/render/tests/effects.rs b/crates/render/tests/effects.rs
index a9420fbcb..a371a1470 100644
--- a/crates/render/tests/effects.rs
+++ b/crates/render/tests/effects.rs
@@ -141,6 +141,8 @@ fn outer_glow_surrounds_the_object() {
g.size = 12.0;
g.color = "C=0 M=100 Y=0 K=0".into();
g.opacity = 1.0;
+ // Normal, so the glow shows on the white page (screened, magenta on white is white).
+ g.mode = designcraft_color::BlendMode::Normal;
let img = render(&d);
golden("outer-glow", &img);
for (x, y) in [(46, 80), (114, 80), (80, 46), (80, 114)] {
@@ -150,6 +152,32 @@ fn outer_glow_surrounds_the_object() {
assert_eq!(lum(img.pixel(10, 10)), WHITE);
}
+/// An effect's blend mode works on what's behind it: a glow screened onto a dark backdrop
+/// lightens it in the glow's colour, where Normal paints the glow's colour over it.
+#[test]
+fn outer_glow_blends_with_its_mode() {
+ let glow = |mode| {
+ let mut d = doc();
+ rect_item(&mut d, Rect::new(0.0, 0.0, 160.0, 160.0), "C=100 M=90 Y=10 K=0");
+ 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 = mode;
+ render(&d)
+ };
+ let screen = glow(designcraft_color::BlendMode::Screen);
+ let normal = glow(designcraft_color::BlendMode::Normal);
+ let backdrop = screen.pixel(10, 10);
+ let (s, n) = (screen.pixel(46, 80), normal.pixel(46, 80));
+ // Screen only lightens: every channel at least the backdrop's, and the navy shows through
+ // (blue stays high), where Normal paints yellow (blue drops).
+ assert!(s.iter().zip(backdrop).take(3).all(|(a, b)| *a + 2 >= b), "screen lightens: {s:?} over {backdrop:?}");
+ assert!(s[2] > n[2] + 25, "screen keeps the backdrop's blue: {s:?} vs normal {n:?}");
+}
+
#[test]
fn inner_shadow_darkens_inside_the_lit_edge() {
let mut d = doc();
diff --git a/crates/render/tests/golden/inner-shadow.png b/crates/render/tests/golden/inner-shadow.png
index c267aa386..5cba47641 100644
Binary files a/crates/render/tests/golden/inner-shadow.png and b/crates/render/tests/golden/inner-shadow.png differ
diff --git a/crates/ui-egui/src/effects_dialog.rs b/crates/ui-egui/src/effects_dialog.rs
index 456ca4a58..dfc345346 100644
--- a/crates/ui-egui/src/effects_dialog.rs
+++ b/crates/ui-egui/src/effects_dialog.rs
@@ -302,6 +302,7 @@ fn page_ui(app: &DesignApp, ui: &mut egui::Ui, d: &mut Dialog, page: &str) {
let key = page;
heading(ui, &tr("Blending"));
grid("b").show(ui, |ui| {
+ mode_row(ui, d, key, &tr);
row(ui, "Color:");
swatch(app, ui, d, &[key, "color"]);
row(ui, "Opacity:");
@@ -343,23 +344,7 @@ fn page_ui(app: &DesignApp, ui: &mut egui::Ui, d: &mut Dialog, page: &str) {
let key = page;
heading(ui, &tr("Blending"));
grid("b").show(ui, |ui| {
- // Inner Glow: its blend mode (Screen, as InDesign starts it).
- if key == "innerGlow" {
- row(ui, "Mode:");
- let cur = d.fields.get("fx").and_then(|f| f["innerGlow"]["mode"].as_str()).unwrap_or("Screen").to_string();
- let label = |m: &designcraft_color::BlendMode| {
- serde_json::to_value(m).ok().and_then(|v| v.as_str().map(str::to_string)).unwrap_or_default()
- };
- let shown = designcraft_color::BlendMode::ALL.iter().find(|m| label(m) == cur).map_or("Screen", |m| m.label());
- egui::ComboBox::from_id_salt("fx_glow_mode").selected_text(tr(shown)).width(150.0).show_ui(ui, |ui| {
- for m in designcraft_color::BlendMode::ALL {
- if ui.selectable_label(label(&m) == cur, tr(m.label())).clicked() {
- set(d, &["innerGlow", "mode"], json!(label(&m)));
- }
- }
- });
- ui.end_row();
- }
+ mode_row(ui, d, key, &tr);
row(ui, "Color:");
swatch(app, ui, d, &[key, "color"]);
row(ui, "Opacity:");
@@ -550,6 +535,28 @@ fn summary(lang: &str, d: &Dialog) -> String {
}
/// The dialog's body.
+/// The Mode row of a shadow's or glow's Blending: its blend mode, as InDesign's (shadows start
+/// Multiply, glows Screen).
+fn mode_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, tr: &dyn Fn(&str) -> String) {
+ crate::rtl::label(ui, tr("Mode:"));
+ let fallback = if key.ends_with("Glow") { "Screen" } else { "Multiply" };
+ let cur = d.fields.get("fx").and_then(|f| f[key]["mode"].as_str()).unwrap_or(fallback).to_string();
+ let name = |m: &designcraft_color::BlendMode| serde_json::to_value(m).ok().and_then(|v| v.as_str().map(str::to_string)).unwrap_or_default();
+ let shown = designcraft_color::BlendMode::ALL.iter().find(|m| name(m) == cur).map_or(fallback, |m| m.label());
+ let mut picked = None;
+ egui::ComboBox::from_id_salt(("fx_mode", key.to_string())).selected_text(tr(shown)).width(150.0).show_ui(ui, |ui| {
+ for m in designcraft_color::BlendMode::ALL {
+ if ui.selectable_label(name(&m) == cur, tr(m.label())).clicked() {
+ picked = Some(name(&m));
+ }
+ }
+ });
+ if let Some(m) = picked {
+ set(d, &[key, "mode"], json!(m));
+ }
+ ui.end_row();
+}
+
pub fn show(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {
let lang = app.ui.language.clone();
let tr = |s: &str| crate::i18n::tr(&lang, s).to_string();
@@ -725,6 +732,30 @@ mod tests {
assert!(!fx(&app).inner_shadow.on);
}
+ /// Drop Shadow and Outer Glow have InDesign's Mode under Blending (Multiply and Screen to
+ /// start); a mode picked there is what OK applies.
+ #[test]
+ fn shadows_and_glows_have_a_blend_mode() {
+ let (mut app, id) = app_with_frame();
+ let ctx = egui::Context::default();
+ crate::theme::install_fonts(&ctx, "en");
+ open(&mut app, "dropShadow");
+ let texts = frame(&mut app, &ctx);
+ assert!(texts.iter().any(|x| x.trim() == "Mode:") && texts.iter().any(|x| x.trim() == "Multiply"), "{texts:?}");
+ crate::dialogs::cancel(&mut app);
+ open(&mut app, "outerGlow");
+ let texts = frame(&mut app, &ctx);
+ assert!(texts.iter().any(|x| x.trim() == "Screen"), "{texts:?}");
+ if let Some(d) = app.ui.dialog.as_mut() {
+ set(d, &["outerGlow", "mode"], json!("Normal"));
+ }
+ frame(&mut app, &ctx);
+ crate::dialogs::confirm(&mut app).unwrap();
+ let fx = app.session.doc().unwrap().doc.item(designcraft_doc::ItemId(id)).unwrap().effects.clone();
+ assert!(fx.outer_glow.on);
+ assert_eq!(fx.outer_glow.mode, designcraft_color::BlendMode::Normal);
+ }
+
#[test]
fn offsets_follow_distance_and_angle_as_in_indesign() {
let (mut app, _) = app_with_frame();