Merge pull request #8000 from dotCooCoo/fix/transform-copies-raster-effects-rows

Effects: each copy of a fill's or stroke's Transform effect carries the raster effect listed before it
This commit is contained in:
BFlat
2026-11-16 12:55:24 +07:00
committed by GitHub
7 changed files with 505 additions and 41 deletions
+3 -2
View File
@@ -96,8 +96,9 @@ pub(crate) fn visual_bounds(symbols: &SymbolBoxes, n: &Node) -> Option<Rect> {
return art.visual_bounds_with(symbols).map(|r| with_raster_reach(symbols, n, r));
}
// Copies that each carry the raster effects listed before their Transform effect reach as far
// as each copy's raster effects paint, and the raster effects after it spread them all.
if effects::outer_effects(n).len() < n.appearance.effects.len()
// as each copy's raster effects paint, and the raster effects after it spread them all,
// as do copies whose fills and strokes each carry their own raster effects.
if (effects::outer_effects(n).len() < n.appearance.effects.len() || effects::has_copied_row_raster(n))
&& let Some(art) = effects::reshape(Some(symbols.document()), n, None)
{
return cull_bounds(symbols, &art);
+39
View File
@@ -1243,6 +1243,45 @@ fn each_copy_of_a_transform_effect_draws_its_own_shadow() {
assert!(b.x1 >= 80.0 - 1e-9, "{b:?}");
}
/// Each copy of a fill's own Transform effect, and each copy of its object's Transform effect,
/// draws the fill's drop shadow under itself, scaled with it: as for the object's own shadow
/// above, the copy's green shadow is 40 pt to its right. A 4 pt stroke's own Transform effect
/// gives each copy the shadow of its stroke: the copy's right edge (38..42 across) casts it at
/// 78..82. The bounds reach as far as the copy's shadow.
#[test]
fn each_copy_of_a_fills_or_strokes_transform_draws_its_own_shadow() {
let shadow = || fx("stylize.dropShadow", json!({"x": 20, "y": 0, "blur": 0, "opacity": 100, "mode": "normal", "color": "#00ff00"}));
let copies = || fx("distort.transform", json!({"scaleH": 200, "scaleV": 200, "moveV": 60, "copies": 1}));
let square = |item: AppearanceItem| {
Node::path(NodeId(0), shapes::rectangle(Rect::new(10.0, 10.0, 30.0, 30.0)), Appearance { items: vec![item], ..Default::default() })
};
let mut red = FillLayer::new(Paint::solid(Color::rgb(1.0, 0.0, 0.0)));
red.effects = vec![shadow(), copies()];
let own = square(AppearanceItem::Fill(red.clone()));
red.effects = vec![shadow()];
let mut owner = square(AppearanceItem::Fill(red));
owner.appearance.effects = vec![copies()];
for (what, n) in [("own", own), ("object's", owner)] {
let d = doc_with(Document::new(100.0, 100.0), n);
let img = render(&d);
assert_eq!(img.pixel(20, 20), [255, 0, 0, 255], "{what}: the square");
assert_eq!(img.pixel(45, 20), [0, 255, 0, 255], "{what}: the square's shadow");
assert_eq!(img.pixel(20, 80), [255, 0, 0, 255], "{what}: the copy");
assert_eq!(img.pixel(70, 80), [0, 255, 0, 255], "{what}: the copy's shadow, 40 pt to its right");
assert_eq!(img.pixel(85, 80), [255, 255, 255, 255], "{what}: past the copy's shadow");
let n = &d.layers[0].children().unwrap()[0];
let b = crate::fx::visual_bounds(&d.symbol_boxes(), n).unwrap();
assert!(b.x1 >= 80.0 - 1e-9, "{what}: {b:?}");
}
let mut blue = StrokeLayer::new(Paint::solid(Color::rgb(0.0, 0.0, 1.0)), 4.0);
blue.effects = vec![shadow(), copies()];
let d = doc_with(Document::new(100.0, 100.0), square(AppearanceItem::Stroke(blue)));
let img = render(&d);
assert_eq!(img.pixel(50, 20), [0, 255, 0, 255], "the square's stroke shadow");
assert_eq!(img.pixel(80, 80), [0, 255, 0, 255], "the copy's stroke shadow, 40 pt to the right of its edge");
assert_eq!(img.pixel(60, 80), [255, 255, 255, 255], "inside the copy's stroke shadow");
}
/// Each copy of an image's Transform effect draws the drop shadow listed before the effect under
/// itself, scaled with it: the red image (20..50) has its green shadow 10 pt to its right, and its
/// copy scaled 50 % and moved 40 pt down (27.5..42.5 across, 67.5..82.5 down) has its own 5 pt to