Skip to contents

A stable hash of everything that defines the scene — geometry, style, page size, background. Two scenes that would render identically hash identically; any change to what is drawn changes the hash.

Usage

scene_hash(scene)

Arguments

scene

A vl_scene(), or anything with an as_vellum_scene() method.

Value

A length-1 character hash.

Details

Useful for caching (has this scene changed since I last rendered it?) and for asserting in tests that a refactor did not alter the scene.

See also

scene_diff() to see what changed, as_scene_spec().

Examples

a <- vl_scene(2, 2) |> draw(circle_grob(gp = vl_gpar(fill = "red")))
b <- vl_scene(2, 2) |> draw(circle_grob(gp = vl_gpar(fill = "blue")))
scene_hash(a) == scene_hash(a)
#> [1] TRUE
scene_hash(a) == scene_hash(b)
#> [1] FALSE