This is a generator version of tween_at() with the additional functionality of supporting enter and exit functions. 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_at(from, to, ease, id = NULL, enter = NULL, exit = NULL)

Arguments

from, to

A data.frame or vector of the same type. If either is of length/nrow 1 it will get repeated to match the length of the other

ease

A character vector giving valid easing functions. Recycled to match the ncol of from

id

The column to match observations on. If NULL observations will be matched by position. See the Match, Enter, and Exit section for more information.

enter, exit

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.

Value

A keyframe_generator object

See also

Other Other generators: gen_along(), gen_components(), gen_events(), gen_keyframe()

Examples

gen <- gen_at(mtcars[1:6, ], mtcars[6:1, ], 'cubic-in-out')

get_frame(gen, 0.3)
#>       mpg   cyl   disp      hp    drat      wt     qsec    vs    am  gear  carb
#> 1 20.6868 6.000 167.02 109.460 3.77688 2.71072 16.86608 0.108 0.892 3.892 3.676
#> 2 20.7516 6.216 181.60 117.020 3.81900 2.93602 17.02000 0.000 0.892 3.892 3.784
#> 3 22.6488 4.216 124.20  94.836 3.76684 2.41666 18.69964 1.000 0.892 3.892 1.000
#> 4 21.5512 5.784 241.80 108.164 3.16316 3.11834 19.35036 1.000 0.108 3.108 1.000
#> 5 18.9484 7.784 338.40 167.980 3.23100 3.37898 17.02000 0.000 0.108 3.108 2.216
#> 6 18.4132 6.000 217.98 105.540 2.88312 3.36928 19.81392 0.892 0.108 3.108 1.324
#>       .phase
#> 1 transition
#> 2 transition
#> 3 transition
#> 4 transition
#> 5 transition
#> 6 transition