R/gen_components.R
gen_components.Rd
This is a generator versions of tween_components()
. It returns a generator
that can be used with get_frame()
and get_raw_frames()
to extract frames
for a specific time point scaled between 0 and 1.
gen_components(
.data,
ease,
nframes,
time,
id = NULL,
range = NULL,
enter = NULL,
exit = NULL,
enter_length = 0,
exit_length = 0
)
A data.frame with components at different stages
The easing function to use. Either a single string or one for each column in the data set.
The number of frames to calculate for the tween
An unquoted expression giving the timepoint for the different
stages of the components. Will be evaluated in the context of .data
so can
refer to a column from that
An unquoted expression giving the component id for each row. Will
be evaluated in the context of .data
so can refer to a column from that
The range of time points to include in the tween. If NULL
it
will use the range of time
functions that calculate a start state for new observations
that appear in to
or an end state for observations that are not present in
to
. If NULL
the new/old observations will not be part of the tween. The
function gets a data.frame with either the start state of the exiting
observations, or the end state of the entering observations and must return
a modified version of that data.frame. See the Match, Enter, and Exit
section for more information.
The lenght of the opening and closing
transitions if enter
and/or exit
is given. Measured in the same units as
time
A component_generator
object
Other Other generators:
gen_along()
,
gen_at()
,
gen_events()
,
gen_keyframe()
from_zero <- function(x) {x$x <- 0; x}
data <- data.frame(
x = c(1, 2, 2, 1, 2, 2),
y = c(1, 2, 2, 2, 1, 1),
time = c(1, 4, 8, 4, 8, 10),
id = c(1, 1, 1, 2, 2, 2)
)
gen <- gen_components(data, 'cubic-in-out', time = time, id = id,
enter = from_zero, enter_length = 4)
get_frame(gen, 0.3)
#> x y time id .phase
#> 1 0.9999375 1 1 1 enter
#> 2 0.0455625 2 4 2 enter