From 3ba7d6cd6b747d8388733528ec0caee8d3bef547 Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Fri, 15 May 2026 22:52:28 +0800 Subject: [PATCH] fix(import): drop shadow on unparseable colour, not opaque black MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `shadows_from_canonical` fell back to `[0,0,0,1.0]` (opaque black) when `parse_hex` rejected a shadow colour — so an `rgba()`, named, or short-hex colour imported as a wrong solid-black shadow (codex stop-gate). Switch the fallback to `filter_map` `None`: an unparseable colour drops that shadow entirely, which is honest (no shadow) rather than misleading (wrong shadow). Matches `first_solid_color`'s existing `parse_hex(...)?` discipline. --- crates/openpencil-desktop/src/pen_doc_adapter.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/openpencil-desktop/src/pen_doc_adapter.rs b/crates/openpencil-desktop/src/pen_doc_adapter.rs index 2b71e8f31..37b1283b1 100644 --- a/crates/openpencil-desktop/src/pen_doc_adapter.rs +++ b/crates/openpencil-desktop/src/pen_doc_adapter.rs @@ -341,12 +341,18 @@ fn shadows_from_canonical( effects .iter() .filter_map(|e| match e { + // Drop the shadow when its colour doesn't parse rather + // than fabricating opaque black — an `rgba()` / named / + // short-hex colour would otherwise import as a wrong + // solid-black shadow (codex stop-gate). PenEffect::Shadow(s) => { - Some(crate::persistence_effects::ShadowPayload { - offset_x: s.offset_x, - offset_y: s.offset_y, - blur: s.blur, - color: parse_hex(&s.color).unwrap_or([0.0, 0.0, 0.0, 1.0]), + parse_hex(&s.color).map(|color| { + crate::persistence_effects::ShadowPayload { + offset_x: s.offset_x, + offset_y: s.offset_y, + blur: s.blur, + color, + } }) } PenEffect::Blur(_) | PenEffect::BackgroundBlur(_) => None,