Effects: copies of a later copying Transform effect carry the raster effects before it

A Transform effect that makes copies and is listed after a fill's or
stroke's first Transform effect with Transform Patterns or Scale Strokes
& Effects on made its copies without following the raster effects listed
before it, so a Drop Shadow kept its offset on every copy. Each copy now
takes the raster effects before it turned, reflected and scaled with that
copy's map, as the first Transform effect's copies do. Without either
option of its own, it does so only when no raster effect is listed after
it.
This commit is contained in:
dotCooCoo
2026-11-15 16:36:48 -08:00
parent efd394bb5d
commit 61062d7d98
3 changed files with 71 additions and 8 deletions
+56 -7
View File
@@ -2546,6 +2546,7 @@ fn transform_piece(
count = count.max(item.effects().len());
}
});
let outer = held;
// The effects before a Transform effect among the piece's effects that makes copies or moves at
// random are held back from the Transform effects before it too.
let mut held = held;
@@ -2566,7 +2567,7 @@ fn transform_piece(
let from = held.min(j);
let mut holds = false;
let stage = vectorcraft_plugins::deferred::Stage { object: seed, effect: kept.get(j).copied().unwrap_or(j), item: Some(source) };
let at = PieceStage { j, from, seed, bounds, doc, stage };
let at = PieceStage { j, from, outer, seed, bounds, doc, stage };
// Stage `j` on `leaf`, a path `used` counts at `piece_cost` when `share`: whether `used`
// counts each path it became so, or `None` when it stays as it was.
let mut on_leaf = |leaf: &mut Node, share: bool| -> Option<Vec<bool>> {
@@ -2787,12 +2788,14 @@ thread_local! {
/// Where a stage of [`transform_piece`] runs: `j`, the index of its effect among the piece's
/// effects; `from`, the first of the effects before it whose raster effects follow a Transform
/// effect; the object's `seed`; the reference box `bounds` of all the piece's paths; the document
/// that painted pieces' swatches and patterns must be in; and the `stage` a deferred live-effect
/// plug-in is listed by.
/// effect; `outer`, how many of the piece's effects a Transform effect before them holds back; the
/// object's `seed`; the reference box `bounds` of all the piece's paths; the document that painted
/// pieces' swatches and patterns must be in; and the `stage` a deferred live-effect plug-in is
/// listed by.
struct PieceStage<'a> {
j: usize,
from: usize,
outer: usize,
seed: u64,
bounds: Rect,
doc: Option<&'a Document>,
@@ -2835,15 +2838,30 @@ fn piece_stage(leaf: &mut Node, e: &Effect, at: &PieceStage, (appearance, index)
let params = merged_params(&e.id, &e.params);
return paint_piece(leaf, &item, (appearance, index), (plugin, &params), at.bounds, room, at.doc, Some(at.stage));
}
if reaches_appearance(e) {
let copied = copies_carry(item.effects(), e, at);
if reaches_appearance(e) || copied {
let params = merged_params(&e.id, &e.params);
let (_, copies) = crate::distort::transform_map(at.bounds, &params, at.seed);
let options = crate::distort::TransformOptions::of(&params);
let map = crate::distort::transform_affine(at.bounds, &params, at.seed);
let j = at.j;
let keep = |k: usize| k > j || (k < j && !options.objects);
let (made, moved) = transform_leaf(leaf, &path, map, copies, options, room, false, Some((item.effects(), &keep)));
if moved {
let (made, moved) = transform_leaf(leaf, &path, map, copies, options, room, copied, Some((item.effects(), &keep)));
if moved && copied {
// Each copy's raster effects before the Transform effect follow that copy's map. The
// Transform effects before it have already moved them, so each run between two of
// them follows on its own.
let fx = item.effects();
let mut start = 0;
for k in 0..=j {
if k == j || fx.get(k).is_some_and(|f| f.id == "distort.transform") {
if start < k {
follow_copies(leaf, map, Some(start..k));
}
start = k + 1;
}
}
} else if moved {
follow_piece(leaf, was, at.from, e);
}
return Some(made);
@@ -2868,6 +2886,37 @@ fn piece_stage(leaf: &mut Node, e: &Effect, at: &PieceStage, (appearance, index)
Some(made)
}
/// Does Transform effect `e`, at stage `at` of [`transform_piece`] of a fill or stroke whose effects
/// are `fx`, make copies that each carry the raster effects listed before it, following that copy's
/// map ([`follow_copies`]), as the copies of the piece's first Transform effect do
/// ([`transform_item_leaf`])? It does when it makes copies with Transform Objects on, a visible
/// raster effect that follows a Transform effect ([`crate::raster::follows`]) is listed before it,
/// and no Transform effect that makes copies or moves at random holds those raster effects back:
/// none before the piece's effects, none listed before it after such a raster effect, and none
/// after it. Without Transform Patterns and Scale Strokes & Effects, every other visible effect
/// before it must also be a geometry effect or such a raster effect, and no visible raster effect
/// may be listed after it, as for [`copied_row_raster_at`].
fn copies_carry(fx: &[Effect], e: &Effect, at: &PieceStage) -> bool {
if !e.visible || e.id != "distort.transform" || at.outer > 0 {
return false;
}
let params = merged_params(&e.id, &e.params);
if !crate::distort::TransformOptions::of(&params).objects || crate::distort::transform_map(Rect::ZERO, &params, 0).1 == 0 {
return false;
}
let before = fx.get(..at.j).unwrap_or_default();
let after = fx.get(at.j + 1..).unwrap_or_default();
if crate::raster::held_back(before) > 0
|| !before.iter().any(|f| f.visible && crate::raster::follows(&f.id))
|| after.iter().any(crate::raster::holds_back)
{
return false;
}
reaches_appearance(e)
|| (before.iter().all(|f| !f.visible || is_geometry(&f.id) || crate::raster::follows(&f.id))
&& !after.iter().any(|f| f.visible && crate::is_raster(&f.id)))
}
/// Are `a` and `b` paths or compound paths that differ only in their fills and strokes?
fn same_path(a: &Node, b: &Node) -> bool {
let leaf = |n: &Node| matches!(n.kind, NodeKind::Path { .. } | NodeKind::Compound { .. });
+14
View File
@@ -1295,6 +1295,20 @@ fn each_copy_of_a_fills_or_strokes_own_transform_carries_the_shadow_before_it()
}
}
/// A Transform effect that makes copies, listed after a fill's or stroke's first Transform effect
/// with Transform Patterns on, gives each copy the shadow listed before it, as the first one's
/// copies do, with or without options of its own: drawn, expanded and baked.
#[test]
fn each_copy_of_a_later_copying_transform_carries_the_shadow_before_it() {
for stroke in [false, true] {
for (params, want, blurs) in copying_cases() {
let effects = vec![transform(json!({"patterns": true})), shadow(10.0, 0.0, 4.0), transform(params.clone())];
let n = one_row(square(102, vec![]), stroke, effects);
assert_copies_carry(&n, &want, &blurs, &format!("stroke {stroke}: {params}"));
}
}
}
/// A fill's or stroke's shadow under its object's Transform effect that makes copies is carried by
/// each copy, moved, turned, reflected and scaled with it: for a single fill, a single stroke, and
/// a fill and a stroke that paint each copy below the one before. Drawn, expanded and baked.
+1 -1
View File
@@ -635,7 +635,7 @@ since 2026-10-01.
- **Transform effect options (#885):** Effect › Distort & Transform › Transform… has visible Transform Objects, Transform Patterns and Scale Strokes & Effects checkboxes (`distort.transform` params `objects`, `patterns`, `strokes`; files without them draw as before). With Transform Objects off the geometry stays and makes no copies; Scale Strokes & Effects scales stroke weights, dashes and the fills' and strokes' effect distances by the mean scale, and Transform Patterns moves pattern tiles, each copy `k` by the transformation `k` times. Such objects draw, export and expand through the same per-copy art, so the canvas and Expand Appearance agree (engine `tests_transformfx`, effects `tests_transformfx`, the dialog test). A Transform effect in a fill's or stroke's own effects applies the same options to that fill or stroke: its weight and dashes and its pattern follow the transformation, and with copies each copy is an object of its own; the canvas, export, Expand Appearance and Use Preview Bounds use the same art (effects `tests_transformfx`). The effects listed after it in that fill's or stroke's list keep their own distances and apply to the transformed art and to each copy, as an object's later effects do after the object's Transform effect: a Drop Shadow after it keeps its offset, an Offset Path after it offsets by its own distance, and an SVG filter after it keeps its scale and the origin of its user space. With Transform Objects off, the effects before it keep their distances too. Before, Scale Strokes & Effects scaled a fill's or stroke's later effects by the mean scale, so existing documents with such effects draw differently. Effects apply in the order they are listed ([Appearance attributes](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/appearance-attributes-in-illustrator.html)); how the two options treat the effects after a fill's or stroke's own Transform effect is VectorCraft's own rule, following that order (effects `tests::rasterfollow::a_fills_own_transform_leaves_the_shadow_after_it`, `tests::rasterfollow::a_fills_own_transform_leaves_the_offset_after_it`, `tests::rasterfollow::a_fills_own_transform_leaves_the_svg_filter_after_it`, `tests::transformfx::a_fills_own_transform_with_scale_strokes_and_effects_leaves_its_later_effects`; engine `plugins::a_transform_after_a_painted_fill_effect_leaves_the_later_shadow_on_every_paint`). Public reference: [Scale objects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/scale-objects.html), [How to apply effects](https://helpx.adobe.com/illustrator/using/effects.html), [Distort and transform effects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html). Scores and hours unchanged.
- **Raster effects before a Transform effect:** effects apply in the order they are listed ([Appearance attributes](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/appearance-attributes-in-illustrator.html)). A Drop Shadow, glow, blur, Feather or pixel filter listed before a Transform effect in the same list (an object's effects, or a fill's or stroke's own) now follows that Transform effect: its sizes scale by the mean scale, and a Drop Shadow's offset turns, reflects and scales with the art. VectorCraft applies this rule with Scale Strokes & Effects on or off. Before, such an effect was drawn at its own distances around the transformed art. The canvas, export, Expand Appearance, Object › Expand, Outline Stroke and the 3D effects use the same values (effects `tests::rasterfollow`; render `a_transform_after_a_drop_shadow_scales_the_shadow_with_the_art`; engine `objexpand::a_shadow_before_a_transform_expands_as_the_canvas_draws_it`, `outlinestroke::a_shadow_before_a_transform_outlines_as_the_canvas_draws_it`). Not yet: a Transform effect that makes copies or moves at random leaves the raster effects before it as they are. The light direction of Underpainting, Rough Pastels, Conté Crayon, Bas Relief, Plaster and Texturizer and the stroke direction of Sprayed Strokes and Graphic Pen now turn and reflect with such a Transform effect, each set to the nearest of its menu's choices (at a tie, the one clockwise of it; VectorCraft's own rule), and Color Halftone's four screen angles turn and reflect with the art ([Distort and transform effects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html); effects `tests::rasterfollow::bas_relief_light_follows_rotation_and_reflection` and the tests after it). Not yet: filters whose strokes or patterns run along fixed page axes without a direction setting (Angled Strokes, Crosshatch, Mezzotint's lines, Halftone Pattern's lines, Grain's horizontal and vertical types, De-Interlace) keep those axes, and an uneven scale or a shear sets a direction from the one vector it maps, not a skewed pattern. Scores and hours unchanged.
- **Raster effects before a Transform effect that makes copies:** the Transform effect can make copies with its transformation applied ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html)). Giving each copy the raster effects listed before that effect is VectorCraft's own rule. On a path or compound path, each copy now carries the Drop Shadow, glow, blur, Feather or pixel filter listed before the last Transform effect that makes copies, with its sizes scaled by that copy's mean scale and a Drop Shadow's offset turned, reflected and scaled with the copy; a raster effect listed after it paints once around all the copies. Before, one shadow was drawn under all the copies at the object's own distances. The canvas, the object's bounds, export and Expand Appearance draw the same copies, and copies that stop at the effect budget each keep their effects (effects `tests::rasterfollow::each_copy_of_a_transform_effect_carries_the_shadow_listed_before_it`, `tests::rasterfollow::a_shadow_after_a_copying_transform_paints_once_around_the_copies`, `tests::rasterfollow::copies_past_the_budget_each_keep_their_shadow`; render `objectfx::each_copy_of_a_transform_effect_draws_its_own_shadow`; engine `objexpand::each_copys_shadow_expands_as_the_canvas_draws_it`). A Transform effect without copies draws as before. Not yet: the copies of type, images, symbol instances and groups still share one set of raster effects, and so does a path with Rasterize, an SVG filter or another effect that is neither a geometry effect nor one of those raster effects before the copying effect. Scores and hours unchanged.
- **A fill's or stroke's raster effects on copies:** an effect can be applied to only the fill or only the stroke of an object ([the help page](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-filter-effects/vector-and-raster-effects.html)), and the Transform effect can make copies ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html)). How the copies carry a fill's or stroke's raster effects is VectorCraft's own rule. On a path or compound path, each copy that a fill's or stroke's own Transform effect makes now carries the Drop Shadow, glow, blur, Feather or pixel filter listed before that Transform effect in the fill's or stroke's effects, drawn from that copy's fill area or stroke outline, with its sizes scaled by the copy's mean scale and a Drop Shadow's offset turned, reflected and scaled with the copy; with Transform Patterns or Scale Strokes & Effects on, the shadow is not scaled a second time. A raster effect listed after the Transform effect paints once around all the copies, and with either option on it stays on each copy as before. Each copy of a path's own Transform effect that makes copies now carries the raster effects of its fills and strokes the same way, for a single fill, a single stroke, or several. Before, one shadow was drawn around all the copies at the fill's or stroke's own distances. A Transform effect without copies, or with Transform Objects off, draws as before. The canvas, the object's bounds, export and Expand Appearance draw the same copies, and copies that stop at the effect budget each keep their effects (effects `tests::rasterfollow::each_copy_of_a_fills_or_strokes_own_transform_carries_the_shadow_before_it`, `tests::rasterfollow::each_copy_of_an_objects_transform_carries_its_fills_or_strokes_shadow`, `tests::rasterfollow::a_fills_shadow_after_its_own_copying_transform_paints_once_around_the_copies`, `tests::rasterfollow::row_copies_past_the_budget_each_keep_their_shadow`; render `objectfx::each_copy_of_a_fills_or_strokes_transform_draws_its_own_shadow`; engine `objexpand::each_copys_fill_shadow_expands_as_the_canvas_draws_it`). Not yet: a fill's or stroke's raster effects on the copies of groups, type, images and symbol instances, and a fill or stroke whose effects list raster effects before one of its own Transform effects that make copies and another raster effect after it and before a later Transform effect that makes copies or moves at random (for example Drop Shadow, Transform, Drop Shadow, Transform, with both Transform effects making copies), which still paints its raster effects around all of the copies. Scores and hours unchanged.
- **A fill's or stroke's raster effects on copies:** an effect can be applied to only the fill or only the stroke of an object ([the help page](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-filter-effects/vector-and-raster-effects.html)), and the Transform effect can make copies ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html)). How the copies carry a fill's or stroke's raster effects is VectorCraft's own rule. On a path or compound path, each copy that a fill's or stroke's own Transform effect makes now carries the Drop Shadow, glow, blur, Feather or pixel filter listed before that Transform effect in the fill's or stroke's effects, drawn from that copy's fill area or stroke outline, with its sizes scaled by the copy's mean scale and a Drop Shadow's offset turned, reflected and scaled with the copy; with Transform Patterns or Scale Strokes & Effects on, the shadow is not scaled a second time. A raster effect listed after the Transform effect paints once around all the copies, and with either option on it stays on each copy as before. A Transform effect that makes copies and is listed after another of the fill's or stroke's own Transform effects with either option on gives each of its copies the raster effects listed before it the same way; without either option of its own, it does so only when no raster effect is listed after it. Each copy of a path's own Transform effect that makes copies now carries the raster effects of its fills and strokes the same way, for a single fill, a single stroke, or several. Before, one shadow was drawn around all the copies at the fill's or stroke's own distances. A Transform effect without copies, or with Transform Objects off, draws as before. The canvas, the object's bounds, export and Expand Appearance draw the same copies, and copies that stop at the effect budget each keep their effects (effects `tests::rasterfollow::each_copy_of_a_fills_or_strokes_own_transform_carries_the_shadow_before_it`, `tests::rasterfollow::each_copy_of_a_later_copying_transform_carries_the_shadow_before_it`, `tests::rasterfollow::each_copy_of_an_objects_transform_carries_its_fills_or_strokes_shadow`, `tests::rasterfollow::a_fills_shadow_after_its_own_copying_transform_paints_once_around_the_copies`, `tests::rasterfollow::row_copies_past_the_budget_each_keep_their_shadow`; render `objectfx::each_copy_of_a_fills_or_strokes_transform_draws_its_own_shadow`; engine `objexpand::each_copys_fill_shadow_expands_as_the_canvas_draws_it`). Not yet: a fill's or stroke's raster effects on the copies of groups, type, images and symbol instances, and a fill or stroke whose effects list raster effects before one of its own Transform effects that make copies and another raster effect after it and before a later Transform effect that makes copies or moves at random (for example Drop Shadow, Transform, Drop Shadow, Transform, with both Transform effects making copies), which still paints its raster effects around all of the copies. Scores and hours unchanged.
- **Rasterize before a Transform effect:** effects apply in the order they are listed, each one taking the result of the one before ([the help page](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/appearance-attributes-in-illustrator.html)). On a path or compound path, a Transform effect listed after the object's own Rasterize effect now moves the image that Rasterize makes: the image is made of the art before the Transform effect, at the Rasterize effect's resolution and with its room around the art, and the Transform effect scales, turns, reflects and moves the image with its pixel grid. Before, the Transform effect moved the art and Rasterize made a new image of the moved art on a grid square to the page. Keeping the image's pixel grid under the Transform effect is VectorCraft's own rule. A hidden Transform effect, or one with Transform Objects off, leaves the image where it is, and one that scales it to nothing leaves nothing drawn. The canvas, the object's bounds, Expand Appearance and PDF export draw the same image (effects `tests::rasterfollow::rasterize_following_ignores_hidden_and_objects_off`, `tests::rasterfollow::the_image_moves_by_each_transform_about_the_art_it_takes`; render `rasterize::rasterize_then_scale_uses_the_pretransform_pixels`, `rasterize::rasterize_then_rotate_and_reflect_moves_the_pixel_grid`, `rasterize::rasterize_then_nonuniform_scale_and_zero_scale_are_bounded`; engine `rastersettings::expand_rasterize_then_transform_matches_canvas`). Not yet: a Transform effect that makes copies or moves at random, a Transform effect followed by another kind of effect, a fill's or stroke's own Rasterize effect, and Rasterize on type, images, symbol instances and groups keep the earlier behavior. Scores and hours unchanged.
- **Raster effects before a Transform effect past the effect budget:** VectorCraft leaves out a Transform effect whose result would pass its geometry budget of 2 million anchors or 8 million lines drawn, and the art stays where it was. The raster effects listed before that Transform effect now stay with the art too: a Drop Shadow keeps its own offset and blur, and the Transform effects after it that fit still move both. Before, the art stayed while the shadow scaled with the Transform effect it did not take. This is VectorCraft's own rule. It applies to a path's own effects and to its fills' and strokes' own, also when the path is in a group whose geometry effects run after its members' own, on the canvas and in its bounds, in export, Expand Appearance, Object › Expand and Outline Stroke, and a hidden shadow keeps its values once shown (effects `tests::rasterfollow::a_transform_past_the_line_budget_moves_the_art_with_its_shadow`, `tests::rasterfollow::only_transforms_that_ran_move_a_preceding_shadow`, `tests::rasterfollow::a_skipped_item_transform_keeps_its_shadow`, `tests::rasterfollow::the_shape_art_of_a_skipped_transform_keeps_its_shadows`, `tests::rasterfollow::a_members_skipped_transform_keeps_its_shadow_under_its_groups_effects`; render `objectfx::a_shadow_before_a_skipped_transform_reaches_as_far_as_it_is_drawn`, `fx::renderer::tests::a_path_paints_from_the_transforms_that_moved_it`; engine `objexpand::a_shadow_before_a_skipped_transform_expands_with_its_own_offset`). Not yet: the shadow of type, an image, a symbol instance or a group whose art a Transform effect leaves in place past the budget still follows that effect. Scores and hours unchanged.
- **Raster effects inside an object or group with a Transform effect:** effects applied to a group affect everything in it ([Appearance attributes](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/appearance-attributes-in-illustrator.html)). How a Transform effect changes the raster effects inside a group or object is VectorCraft's own rule. A group's Transform effect that moves it once now transforms the raster effects of its members, of their fills and strokes, of nested groups and of the art of the linked opacity masks in it, after the members' own Transform effects. A raster effect that a member's own Transform effect with copies or random holds back keeps its value through that effect and still transforms with the group's. VectorCraft applies the same rule to the raster effects of an object's fills and strokes under the object's Transform effect. Sizes scale by the mean scale and a Drop Shadow's offset turns, reflects and scales, with Scale Strokes & Effects on or off. Before, they kept their values, or with Scale Strokes & Effects on scaled by the mean scale with the offset unturned. A group's or object's Transform effect that makes copies or moves at random leaves them as before, except a path's Transform effect that makes copies (see "A fill's or stroke's raster effects on copies"). The canvas, the redraw region, export, Expand Appearance, Object › Expand and Outline Stroke use the same values (effects `tests::rasterfollow`, `group::tests::a_compound_shapes_transform_turns_its_fills_shadow`; render `a_transform_scales_the_shadows_of_fills_and_members_with_the_art`; engine `objexpand::a_fills_shadow_under_the_objects_transform_expands_as_the_canvas_draws_it`, `objexpand::shadows_under_a_groups_or_an_objects_transform_expand_appearance_as_the_canvas_draws_them`, `outlinestroke::a_strokes_shadow_under_the_objects_transform_outlines_as_the_canvas_draws_it`). Scores and hours unchanged.