gen_components {tweenr}R Documentation

Generator for tweening components separately from each other

Description

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.

Usage

gen_components(
  .data,
  ease,
  nframes,
  time,
  id = 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

time

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

id

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

range

The range of time points to include in the tween. If NULL it will use the range of time

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.

enter_length, exit_length

The lenght of the opening and closing transitions if enter and/or exit is given. Measured in the same units as time

Value

A component_generator object

See Also

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

Examples

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)

[Package tweenr version 2.0.3 Index]