fix(import): drop shadow on unparseable colour, not opaque black

`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.
This commit is contained in:
Kayshen-X 2026-05-15 22:52:28 +08:00
parent e8a5422578
commit 3ba7d6cd6b

View file

@ -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,