tween_events {tweenr} | R Documentation |
Transition in and out of events
Description
This tweening function is a more powerful version of tween_appear()
, with
support for newer features such as enter/exits and tween phase
identification. The tweener treats each row in the data as unique events in
time, and creates frames with the correct events present at any given time.
Usage
tween_events(
.data,
ease,
nframes,
start,
end = NULL,
range = NULL,
enter = NULL,
exit = NULL,
enter_length = 0,
exit_length = 0
)
Arguments
.data |
A data.frame with components at different stages |
ease |
The easing function to use. Either a single string or one for each column in the data set. |
nframes |
The number of frames to calculate for the tween |
start , end |
The start (and potential end) of the event encoded in the
row, as unquoted expressions. Will be evaluated in the context of |
range |
The range of time points to include in the tween. If |
enter , exit |
functions that calculate a start state for new observations
that appear in |
enter_length , exit_length |
The lenght of the opening and closing
transitions if |
Value
A data.frame with the same columns as .data
along with .id
giving
the component id, .phase
giving the state of each component in each frame,
and .frame
giving the frame membership of each row.
See Also
Other data.frame tween:
tween_along()
,
tween_appear()
,
tween_components()
,
tween_elements()
,
tween_states()
Examples
d <- data.frame(
x = runif(20),
y = runif(20),
time = runif(20),
duration = runif(20, max = 0.1)
)
from_left <- function(x) {
x$x <- -0.5
x
}
to_right <- function(x) {
x$x <- 1.5
x
}
tween_events(d, 'cubic-in-out', 50, start = time, end = time + duration,
enter = from_left, exit = to_right, enter_length = 0.1,
exit_length = 0.05)