File: gen_components.Rd

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 (80 lines) | stat: -rw-r--r-- 2,608 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gen_components.R
\name{gen_components}
\alias{gen_components}
\title{Generator for tweening components separately from each other}
\usage{
gen_components(
  .data,
  ease,
  nframes,
  time,
  id = NULL,
  range = NULL,
  enter = NULL,
  exit = NULL,
  enter_length = 0,
  exit_length = 0
)
}
\arguments{
\item{.data}{A data.frame with components at different stages}

\item{ease}{The easing function to use. Either a single string or one for
each column in the data set.}

\item{nframes}{The number of frames to calculate for the tween}

\item{time}{An unquoted expression giving the timepoint for the different
stages of the components. Will be evaluated in the context of \code{.data} so can
refer to a column from that}

\item{id}{An unquoted expression giving the component id for each row. Will
be evaluated in the context of \code{.data} so can refer to a column from that}

\item{range}{The range of time points to include in the tween. If \code{NULL} it
will use the range of \code{time}}

\item{enter, exit}{functions that calculate a start state for new observations
that appear in \code{to} or an end state for observations that are not present in
\code{to}. If \code{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 \emph{Match, Enter, and Exit}
section for more information.}

\item{enter_length, exit_length}{The lenght of the opening and closing
transitions if \code{enter} and/or \code{exit} is given. Measured in the same units as
\code{time}}
}
\value{
A \code{component_generator} object
}
\description{
This is a generator versions of \code{\link[=tween_components]{tween_components()}}. It returns a generator
that can be used with \code{\link[=get_frame]{get_frame()}} and \code{\link[=get_raw_frames]{get_raw_frames()}} to extract frames
for a specific time point scaled between 0 and 1.
}
\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)
}
\seealso{
Other Other generators: 
\code{\link{gen_along}()},
\code{\link{gen_at}()},
\code{\link{gen_events}()},
\code{\link{gen_keyframe}()}
}
\concept{Other generators}