Compares two scenes structurally and reports the differences in terms of the
scene — "the node axis-x moved", "3 marks changed fill" — rather than as a
pixel diff.
Arguments
- a, b
Two scenes (
vl_scene(), or anything with anas_vellum_scene()method).- max_depth
Stop descending after this many levels (guards a runaway report on deeply nested trees).
Value
A data frame with columns path (where in the tree), change
("added", "removed", or "changed"), and detail. Empty when the two
scenes are equivalent. Printing shows a readable summary.
Details
This is a better basis for visual-regression testing than comparing rendered images, for one specific reason: an image diff is sensitive to the font stack, so the same code compared across two machines produces differences that swamp the real change. A structural diff compares what was asked for, and is unaffected.
See also
scene_hash() for a yes/no answer, as_scene_spec().
Examples
a <- vl_scene(3, 2) |> draw(circle_grob(r = 0.3, gp = vl_gpar(fill = "red")))
b <- vl_scene(3, 2) |> draw(circle_grob(r = 0.4, gp = vl_gpar(fill = "blue")))
scene_diff(a, b)
#> 2 differences:
#> • ~ root$children[1]$gp$fill: red -> blue
#> • ~ root$children[1]$r: 0.3npc -> 0.4npc
