JScene | R Documentation |
A JScene is a portion of a complex animation. It consists of some metadata (duration, frame rate), a set of animation transitions and a plotting function.
JScene(duration, fps, startAfter = 0, ..., plotFn)
duration |
Scene duration in seconds. |
fps |
Frame rate (frames per second). |
startAfter |
Timing of the start of this frame. Number of seconds after the end of the previous scene that this scene starts. |
... |
Ordered set of transitions. Transitions may be named for documentation purposes, but names are not required. |
plotFn |
The parameterised plotting function. Called with one positional
argument for each transition, and an optional final boolean argument,
|
A list, known as a JScene
, that can be included in a list of
scenes then used to create an animation.
JAnimateScenes
, JTransition
, JPlotSceneFn
# Construct a single-scene animation
scenes <- list(JScene(1, # Duration
20, # Frame rate
# Parameters to be passed to plotFn
pt1 = JTransition(1, 0),
pt2 = JTransition(0, 1),
# Plotting function with parameters matching those defined above
plotFn = function(pt1, pt2) {
plot(c(pt1, 1 - pt2), c(pt2, pt1), type = "b",
xlim = c(0, 1), ylim = c(0, 1))
}))
# Plot 20 frames
for (i in 1:20) {
JPlotSceneFn(scenes)(i)
# Crude way to animate in real time
dev.flush()
Sys.sleep(0.05)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.