File: gen_at.R

package info (click to toggle)
r-cran-tweenr 2.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,060 kB
  • sloc: cpp: 1,052; ansic: 558; sh: 13; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 792 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#' Generator for interpolating between two data frames
#'
#' 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.
#'
#' @inheritParams tween_at
#' @inheritParams tween_state
#'
#' @return A `keyframe_generator` object
#'
#' @family Other generators
#'
#' @export
#'
#' @examples
#' gen <- gen_at(mtcars[1:6, ], mtcars[6:1, ], 'cubic-in-out')
#'
#' get_frame(gen, 0.3)
gen_at <- function(from, to, ease, id = NULL, enter = NULL, exit = NULL) {
  gen <- gen_keyframe(from, 0)
  add_keyframe(gen, to, ease = ease, length = 1, id = {{ id }}, enter = enter, exit = exit)
}