Parcourir la source

Completes animation options framework via anim_options()

- Collected in animate_options.R
- Sets global defaults in plot_settings environment
- Adds ability to set animation options, similar to theme_set() from ggplot2
- Adds getters for current (if set) or default animation options

Merge branch 'pkg-add-anim-options-merge' into pkg-add-anim-options

# Conflicts:
#	NAMESPACE
#	R/animate_tidyr.R
#	R/plot_helpers.R
#	man/anim_options.Rd
#	man/animate_gather.Rd
#	man/animate_spread.Rd
#	man/static_plot.Rd
pkg-add-anim-opts-fixed
Garrick Aden-Buie il y a 7 ans
Parent
révision
9efdb97da5
12 fichiers modifiés avec 304 ajouts et 152 suppressions
  1. +2
    -0
      NAMESPACE
  2. +201
    -0
      R/animate_options.R
  3. +4
    -3
      R/animate_tidyr.R
  4. +2
    -121
      R/plot_helpers.R
  5. +13
    -0
      R/zzzz-package.R
  6. +26
    -14
      man/anim_options.Rd
  7. +3
    -1
      man/animate_gather.Rd
  8. +2
    -2
      man/animate_plot.Rd
  9. +3
    -1
      man/animate_spread.Rd
  10. +9
    -1
      man/set_font_size.Rd
  11. +12
    -9
      man/static_plot.Rd
  12. +27
    -0
      tests/testthat/test-anim_options.R

+ 2
- 0
NAMESPACE Voir le fichier

@@ -2,6 +2,7 @@

export("%>%")
export(anim_options)
export(anim_options_set)
export(animate_anti_join)
export(animate_full_join)
export(animate_gather)
@@ -14,6 +15,7 @@ export(animate_setdiff)
export(animate_spread)
export(animate_union)
export(animate_union_all)
export(get_font_size)
export(set_font_size)
importFrom(dplyr,anti_join)
importFrom(dplyr,arrange)

+ 201
- 0
R/animate_options.R Voir le fichier

@@ -0,0 +1,201 @@
#' Animation Options
#'
#' Helper function to set animation and plotting options to be passed to
#' [animate_plot()] and [static_plot()].
#'
#' @param text_family Font family for the plot text, default is "Fira Mono". Use
#' [set_font_size()] to set global default font sizes.
#' @param title_family Font family for the plot title, default is "Fira Mono".
#' Use [set_font_size()] to set global default font sizes.
#' @param text_size Font size of the plot text, default is 5.
#' @param title_size Font size of the plot title, default is 17.
#' @param ease_default Default aes easing function. See [tweenr::display_ease()]
#' for more options. The tidyexplain default value is `sine-in-out`.
#' @param ease_other Additional aes easing options, specified as a named list.
#' List entries are named with the aesthetic to which the easeing should be
#' applied, consistent with [gganimate::ease_aes()]. E.g. `list(color =
#' "sine")`.
#' @param enter Enter fading function applied to objects in the animation. See
#' [gganimate::enter_exit] for a complete list of options. The tidyexplain
#' default is [gganimate::enter_fade()].
#' @param exit Exit fading function applied to objects in the animation. See
#' [gganimate::enter_exit] for a complete list of options. The tidyexplain
#' default is [gganimate::exit_fade()].
#' @inheritParams gganimate::transition_states
#' @export
anim_options <- function(
transition_length = NULL,
state_length = NULL,
ease_default = NULL,
ease_other = NULL,
enter = NULL,
exit = NULL,
text_family = NULL,
title_family = NULL,
text_size = NULL,
title_size = NULL,
...
){
enter_name <- if (!missing(enter)) rlang::quo_name(rlang::enquo(enter))
exit_name <- if (!missing(exit)) rlang::quo_name(rlang::enquo(exit))
ao <- list(
transition_length = transition_length,
state_length = state_length,
ease_default = ease_default,
ease_other = ease_other,
enter = if (!is.null(enter)) setNames(list(enter), enter_name),
exit = if (!is.null(exit)) setNames(list(exit), exit_name),
text_family = text_family,
text_size = text_size,
title_family = title_family,
title_size = title_size,
...
)
ao <- purrr::compact(ao)
structure(ao, class = "anim_opts")
}


# Global Animation Options Setters and Getters ----------------------------

#' @describeIn anim_options Set default animation options for the current session.
#' @param anim_opts An [anim_options()] options list.
#' @export
anim_options_set <- function(anim_opts) {
stopifnot(is.anim_opts(anim_opts))
ao_old <- plot_settings$anim_opts
plot_settings$anim_opts <- merge(anim_opts, plot_settings$anim_opts)
invisible(ao_old)
}

get_anim_opt <- function(anim_opt = NULL) {
if (is.null(anim_opt)) return(plot_settings$anim_opts)
if (anim_opt %in% c("text_size", "title_size")) rlang::abort(
"Use get_text_size() or get_title_size()"
)
plot_settings$anim_opts[[anim_opt]] %||% plot_settings$default[[anim_opt]]
}


# Animation Options Methods -----------------------------------------------

print.anim_opts <- function(ao) {
aop <- purrr::discard(ao, is.null)
# Replace ggproto (enter/exit functions) with their names
if ("enter" %in% names(aop)) aop$enter <- paste("ggproto:", names(ao$enter))
if ("exit" %in% names(aop)) aop$exit <- paste("ggproto:", names(ao$exit))
str(aop)
invisible(ao)
}

is.anim_opts <- function(ao) inherits(ao, "anim_opts")


# Fill, Validate, Merge Animation Options ---------------------------------

# Fills in default animation options
fill_anim_opts <- function(ao) {
ao$transition_length <- ao$transition_length %||% get_anim_opt("transition_length")
ao$state_length <- ao$state_length %||% get_anim_opt("state_length")
ao$ease_default <- ao$ease_default %||% get_anim_opt("ease_default")
ao$ease_other <- ao$ease_other %||% get_anim_opt("ease_other")
ao$enter <- ao$enter %||% get_anim_opt("enter")
ao$exit <- ao$exit %||% get_anim_opt("exit")
ao$text_family <- ao$text_family %||% get_anim_opt("text_family")
ao$title_family <- ao$title_family %||% get_anim_opt("title_family")
ao
}

validate_anim_opts <- function(ao, quiet = FALSE, strict = getOption("tidyexplain.strict_dots", FALSE)) {
if (!inherits(ao, "anim_opts")) {
rlang::warn("Use `anim_options()` to set `anim_opts`")
}
ao <- fill_anim_opts(ao)
stopifnot(is.ggproto(ao$enter[[1]]), is.ggproto(ao$exit[[1]]))
extra_names <- setdiff(names(ao), names(formals(anim_options)))
if (!quiet && length(extra_names)) {
extra_names <- paste0(sprintf("`%s`", extra_names), collapse = ", ")
msg <- paste("Unknown animation options will be ignored:", extra_names)
if (isTrue(strict)) rlang::abort(msg) else rlang::warn(msg)
}
invisible(ao)
}

merge.anim_opts <- function(ao_new, ao_base = anim_options()) {
ao_new <- purrr::discard(ao_new, is.null)
ao_base <- purrr::discard(ao_base, is.null)
unique_base <- setdiff(names(ao_base), names(ao_new))
ao <- append(ao_new, ao_base[unique_base])
ao <- ao[names(formals(anim_options))]
ao <- purrr::discard(ao, is.null)
class(ao) <- "anim_opts"
ao
}


# Default Animation Options for Verb Families -----------------------------

default_anim_opts <- function(family, ao_custom = NULL) {
family_options <- c("join", "set", "gather", "spread")
family <- match.arg(family, family_options, several.ok = FALSE)
ao_default <- switch(
family,
"gather" = anim_options(enter = enter_fade(), exit = exit_fade(),
ease_default = "sine-in-out",
ease_other = list(y = "cubic-out", x = "cubic-in")),
"spread" = anim_options(enter = enter_fade(), exit = exit_fade(),
ease_default = "sine-in-out",
ease_other = list(y = "cubic-out", x = "cubic-in")),
anim_options()
)
if (is.null(ao_custom)) ao_default else merge(ao_custom, ao_default)
}

# Font Size Setters and Getters -------------------------------------------

#' Set Default Text Sizes for Animation Plots
#'
#' Sets the default text sizes for the animated and static plots produced by
#' this package during the current session.
#'
#' @param text_size Font size of value labels inside the data frame squares
#' @param title_size Font size of the function call or plot title
#' @export
set_font_size <- function(text_size = NULL, title_size = NULL) {
old <- list()
if (!is.null(text_size)) old$text_size <- set_text_size(text_size)
if (!is.null(title_size)) old$title_size <- set_title_size(title_size)
invisible(old)
}

#' @describeIn set_font_size Get current global font sizes
#' @export
get_font_size <- function() {
list("text_size" = get_text_size(), "title_size" = get_title_size())
}

set_text_size <- function(size) {
old <- plot_settings$text_size
anim_options_set(anim_options(text_size = size))
invisible(old)
}

set_title_size <- function(size) {
old <- plot_settings$title_size
anim_options_set(anim_options(title_size = size))
invisible(old)
}

get_text_size <- function(x = NULL) {
if (!is.null(x)) return(x)
plot_settings$anim_opts$text_size %||%
getFromNamespace("theme_env", "ggplot2")$current$text$size %||%
plot_settings$default$text_size
}

get_title_size <- function(x = NULL) {
if (!is.null(x)) return(x)
plot_settings$anim_opts$text_size %||%
getFromNamespace("theme_env", "ggplot2")$current$plot.title$size %||%
plot_settings$default$title_size
}

+ 4
- 3
R/animate_tidyr.R Voir le fichier

@@ -1,4 +1,3 @@

#' Animates the gather function
#'
#' @param w a data_frame in the wide format
@@ -29,7 +28,8 @@
#' # if you want to have a less detailed animation, you can also use
#' animate_gather(wide, "person", "sales", -year, export = "gif", detailed = FALSE)
#' }
animate_gather <- function(w, key, value, ..., export = "gif", detailed = TRUE, anim_opts = anim_options()) {
animate_gather <- function(w, key, value, ..., export = "gif", detailed = TRUE, anim_opts = NULL) {
anim_opts <- default_anim_opts("gather", anim_opts)
lhs <- w
rhs <- tidyr::gather(w, !!key, !!value, ...)

@@ -88,7 +88,8 @@ animate_gather <- function(w, key, value, ..., export = "gif", detailed = TRUE,
#' # if you want to have a less detailed animation, you can also use
#' animate_spread(long, key = "person", value = "sales", export = "gif", detailed = FALSE)
#' }
animate_spread <- function(l, key, value, export = "gif", detailed = TRUE, ..., anim_opts = anim_options()) {
animate_spread <- function(l, key, value, export = "gif", detailed = TRUE, ..., anim_opts = NULL) {
anim_opts <- default_anim_opts("spread", anim_opts)

lhs <- l
rhs <- tidyr::spread(l, key = key, value = value)

+ 2
- 121
R/plot_helpers.R Voir le fichier

@@ -1,82 +1,5 @@
#' Animation Options
#'
#' Helper function to set animation and plotting options to be passed to
#' [animate_plot()] and [static_plot()].
#'
#' @param text_family Font family for the plot text
#' @param title_family Font family for the plot title
#' @param text_size Font size of the plot text
#' @param title_size Font size of the plot title
#' @param ease_default Default aes easing function. See [tweenr::display_ease()]
#' for more options.
#' @param ease_other Additional aes easing options, specified as a named list.
#' List entries are named with the aesthetic to which the easeing should be
#' applied, consistent with [gganimate::ease_aes()].
#' E.g. `list(color = "sine")`.
#' @param enter Enter fading function applied to objects in the animation. See
#' [gganimate::enter_exit] for a complete list of options.
#' @param exit Exit fading function applied to objects in the animation. See
#' [gganimate::enter_exit] for a complete list of options.
#' @inheritParams gganimate::transition_states
#' @export
anim_options <- function(
transition_length = 2,
state_length = 1,
ease_default = "sine-in-out",
ease_other = NULL,
enter = enter_fade(),
exit = exit_fade(),
text_family = "Fira Sans",
title_family = "Fira Mono",
text_size = NULL,
title_size = NULL,
...
){
enter_name <- rlang::quo_name(rlang::enquo(enter))
exit_name <- rlang::quo_name(rlang::enquo(exit))
structure(
list(
transition_length = transition_length,
state_length = state_length,
ease_default = ease_default,
ease_other = ease_other,
enter = setNames(list(enter), enter_name),
exit = setNames(list(exit), exit_name),
text_family = text_family,
text_size = text_size,
title_family = title_family,
title_size = title_size,
...
),
class = "anim_opts"
)
}

print.anim_opts <- function(ao) {
aop <- ao
# Replace ggproto (enter/exit functions) with their names
aop$enter <- paste("ggproto:", names(ao$enter))
aop$exit <- paste("ggproto:", names(ao$exit))
str(aop)
invisible(ao)
}

validate_anim_opts <- function(ao, quiet = FALSE, strict = getOption("tidyexplain.strict_dots", FALSE)) {
if (!inherits(ao, "anim_opts")) {
rlang::warn("Use `anim_options()` to set `anim_opts`")
}
stopifnot(is.ggproto(ao$enter[[1]]), is.ggproto(ao$exit[[1]]))
extra_names <- setdiff(names(ao), names(formals(anim_options)))
if (!quiet && length(extra_names)) {
extra_names <- paste0(sprintf("`%s`", extra_names), collapse = ", ")
msg <- paste("Unknown animation options will be ignored:", extra_names)
if (isTrue(strict)) rlang::abort(msg) else rlang::warn(msg)
}
invisible(ao)
}

#' Animates a plot
#'
#' @param d a processed dataset
#' @param title the title of the plot
#' @param anim_opts Animation options generated with [anim_options()]. Overrides
@@ -121,8 +44,8 @@ static_plot <- function(
anim_opts = anim_options(...)
) {
ao <- validate_anim_opts(anim_opts)
text_size <- get_text_size(ao$text_size, default = 5)
title_size <- get_title_size(ao$title_size, default = 17)
text_size <- get_text_size(ao$text_size)
title_size <- get_title_size(ao$title_size)

if (!".alpha" %in% names(d)) d <- d %>% mutate(.alpha = 1)
if (!".textcolor" %in% names(d))
@@ -147,45 +70,3 @@ static_plot <- function(
theme_void() +
theme(plot.title = element_text(family = ao$title_family, hjust = 0.5, size = title_size))
}

#' Set Default Text Sizes for Animation Plots
#'
#' Sets the default text sizes for the animated and static plots produced by
#' this package during the current session.
#'
#' @param text_size Font size of value labels inside the data frame squares
#' @param title_size Font size of the function call or plot title
#' @export
set_font_size <- function(text_size = NULL, title_size = NULL) {
old <- list()
if (!is.null(text_size)) old$text_size <- set_text_size(text_size)
if (!is.null(title_size)) old$title_size <- set_title_size(title_size)
invisible(old)
}

set_text_size <- function(size) {
old <- plot_settings$text_size
plot_settings$text_size <- size
invisible(old)
}

set_title_size <- function(size) {
old <- plot_settings$title_size
plot_settings$title_size <- size
invisible(old)
}

get_text_size <- function(x = NULL, default = 5) {
if (!is.null(x)) return(x)
plot_settings$text_size %||%
getFromNamespace("theme_env", "ggplot2")$current$text$size %||%
default
}

get_title_size <- function(x = NULL, default = 17) {
if (!is.null(x)) return(x)
plot_settings$title_size %||%
getFromNamespace("theme_env", "ggplot2")$current$plot.title$size %||%
default
}


+ 13
- 0
R/zzzz-package.R Voir le fichier

@@ -5,3 +5,16 @@
"_PACKAGE"

plot_settings <- new.env(parent = emptyenv())
plot_settings$default <- list(
transition_length = 2,
state_length = 1,
ease_default = "sine-in-out",
ease_other = NULL,
enter = setNames(list(enter_fade()), "enter_fade()"),
exit = setNames(list(exit_fade()), "exit_fade()"),
text_family = "Fira Mono",
title_family = "Fira Mono",
text_size = 5,
title_size = 17
)


+ 26
- 14
man/anim_options.Rd Voir le fichier

@@ -1,14 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_helpers.R
% Please edit documentation in R/animate_options.R
\name{anim_options}
\alias{anim_options}
\alias{anim_options_set}
\title{Animation Options}
\usage{
anim_options(transition_length = 2, state_length = 1,
ease_default = "sine-in-out", ease_other = NULL,
enter = enter_fade(), exit = exit_fade(),
text_family = "Fira Sans", title_family = "Fira Mono",
anim_options(transition_length = NULL, state_length = NULL,
ease_default = NULL, ease_other = NULL, enter = NULL,
exit = NULL, text_family = NULL, title_family = NULL,
text_size = NULL, title_size = NULL, ...)

anim_options_set(anim_opts)
}
\arguments{
\item{transition_length}{The relative length of the transition. Will be
@@ -18,28 +20,38 @@ recycled to match the number of states in the data}
recycled to match the number of states in the data}

\item{ease_default}{Default aes easing function. See \code{\link[tweenr:display_ease]{tweenr::display_ease()}}
for more options.}
for more options. The tidyexplain default value is \code{sine-in-out}.}

\item{ease_other}{Additional aes easing options, specified as a named list.
List entries are named with the aesthetic to which the easeing should be
applied, consistent with \code{\link[gganimate:ease_aes]{gganimate::ease_aes()}}.
E.g. \code{list(color = "sine")}.}
applied, consistent with \code{\link[gganimate:ease_aes]{gganimate::ease_aes()}}. E.g. \code{list(color = "sine")}.}

\item{enter}{Enter fading function applied to objects in the animation. See
\link[gganimate:enter_exit]{gganimate::enter_exit} for a complete list of options.}
\link[gganimate:enter_exit]{gganimate::enter_exit} for a complete list of options. The tidyexplain
default is \code{\link[gganimate:enter_fade]{gganimate::enter_fade()}}.}

\item{exit}{Exit fading function applied to objects in the animation. See
\link[gganimate:enter_exit]{gganimate::enter_exit} for a complete list of options.}
\link[gganimate:enter_exit]{gganimate::enter_exit} for a complete list of options. The tidyexplain
default is \code{\link[gganimate:exit_fade]{gganimate::exit_fade()}}.}

\item{text_family}{Font family for the plot text, default is "Fira Mono". Use
\code{\link[=set_font_size]{set_font_size()}} to set global default font sizes.}

\item{text_family}{Font family for the plot text}
\item{title_family}{Font family for the plot title, default is "Fira Mono".
Use \code{\link[=set_font_size]{set_font_size()}} to set global default font sizes.}

\item{title_family}{Font family for the plot title}
\item{text_size}{Font size of the plot text, default is 5.}

\item{text_size}{Font size of the plot text}
\item{title_size}{Font size of the plot title, default is 17.}

\item{title_size}{Font size of the plot title}
\item{anim_opts}{An \code{\link[=anim_options]{anim_options()}} options list.}
}
\description{
Helper function to set animation and plotting options to be passed to
\code{\link[=animate_plot]{animate_plot()}} and \code{\link[=static_plot]{static_plot()}}.
}
\section{Functions}{
\itemize{
\item \code{anim_options_set}: Set default animation options for the current session.
}}


+ 3
- 1
man/animate_gather.Rd Voir le fichier

@@ -5,7 +5,7 @@
\title{Animates the gather function}
\usage{
animate_gather(w, key, value, ..., export = "gif", detailed = TRUE,
anim_opts = anim_options())
anim_opts = NULL)
}
\arguments{
\item{w}{a data_frame in the wide format}
@@ -22,6 +22,8 @@ export ggplots of the first/last state of the join}

\item{detailed}{boolean value if the animation should show one step for each
key value}

\item{anim_opts}{An \code{\link[=anim_options]{anim_options()}} options list.}
}
\value{
a gif or a ggplot

+ 2
- 2
man/animate_plot.Rd Voir le fichier

@@ -2,7 +2,7 @@
% Please edit documentation in R/plot_helpers.R
\name{animate_plot}
\alias{animate_plot}
\title{Animates a plot}
\title{Animation Options}
\usage{
animate_plot(d, title = "", ..., anim_opts = anim_options(...))
}
@@ -18,7 +18,7 @@ any options set in \code{...}.}
a \code{gganim} object
}
\description{
Animates a plot
Animation Options
}
\examples{
NULL

+ 3
- 1
man/animate_spread.Rd Voir le fichier

@@ -5,7 +5,7 @@
\title{Animates the spread function}
\usage{
animate_spread(l, key, value, export = "gif", detailed = TRUE, ...,
anim_opts = anim_options())
anim_opts = NULL)
}
\arguments{
\item{l}{a data_frame in the long/tidy format}
@@ -21,6 +21,8 @@ export ggplots of the first/last state of the join}
key value}

\item{...}{further arguments passed to \link{process_long} or \link{process_wide}}

\item{anim_opts}{An \code{\link[=anim_options]{anim_options()}} options list.}
}
\value{
a ggplot or a gif

+ 9
- 1
man/set_font_size.Rd Voir le fichier

@@ -1,10 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_helpers.R
% Please edit documentation in R/animate_options.R
\name{set_font_size}
\alias{set_font_size}
\alias{get_font_size}
\title{Set Default Text Sizes for Animation Plots}
\usage{
set_font_size(text_size = NULL, title_size = NULL)

get_font_size()
}
\arguments{
\item{text_size}{Font size of value labels inside the data frame squares}
@@ -15,3 +18,8 @@ set_font_size(text_size = NULL, title_size = NULL)
Sets the default text sizes for the animated and static plots produced by
this package during the current session.
}
\section{Functions}{
\itemize{
\item \code{get_font_size}: Get current global font sizes
}}


+ 12
- 9
man/static_plot.Rd Voir le fichier

@@ -13,20 +13,23 @@ static_plot(d, title = "", ..., anim_opts = anim_options(...))

\item{...}{Arguments passed on to \code{anim_options}
\describe{
\item{text_family}{Font family for the plot text}
\item{title_family}{Font family for the plot title}
\item{text_size}{Font size of the plot text}
\item{title_size}{Font size of the plot title}
\item{text_family}{Font family for the plot text, default is "Fira Mono". Use
\code{\link[=set_font_size]{set_font_size()}} to set global default font sizes.}
\item{title_family}{Font family for the plot title, default is "Fira Mono".
Use \code{\link[=set_font_size]{set_font_size()}} to set global default font sizes.}
\item{text_size}{Font size of the plot text, default is 5.}
\item{title_size}{Font size of the plot title, default is 17.}
\item{ease_default}{Default aes easing function. See \code{\link[tweenr:display_ease]{tweenr::display_ease()}}
for more options.}
for more options. The tidyexplain default value is \code{sine-in-out}.}
\item{ease_other}{Additional aes easing options, specified as a named list.
List entries are named with the aesthetic to which the easeing should be
applied, consistent with \code{\link[gganimate:ease_aes]{gganimate::ease_aes()}}.
E.g. \code{list(color = "sine")}.}
applied, consistent with \code{\link[gganimate:ease_aes]{gganimate::ease_aes()}}. E.g. \code{list(color = "sine")}.}
\item{enter}{Enter fading function applied to objects in the animation. See
\link[gganimate:enter_exit]{gganimate::enter_exit} for a complete list of options.}
\link[gganimate:enter_exit]{gganimate::enter_exit} for a complete list of options. The tidyexplain
default is \code{\link[gganimate:enter_fade]{gganimate::enter_fade()}}.}
\item{exit}{Exit fading function applied to objects in the animation. See
\link[gganimate:enter_exit]{gganimate::enter_exit} for a complete list of options.}
\link[gganimate:enter_exit]{gganimate::enter_exit} for a complete list of options. The tidyexplain
default is \code{\link[gganimate:exit_fade]{gganimate::exit_fade()}}.}
\item{transition_length}{The relative length of the transition. Will be
recycled to match the number of states in the data}
\item{state_length}{The relative length of the pause at the states. Will be

+ 27
- 0
tests/testthat/test-anim_options.R Voir le fichier

@@ -0,0 +1,27 @@
context("test-anim_options")

test_that("merging of animation options works", {
ao_new <- anim_options(5, 3, text_size = 9, title_size = 13)
ao_old <- anim_options(ease_default = "cubic-in", text_family = "Times New Roman")
ao_merged <- anim_options(5, 3, "cubic-in", text_size = 9, title_size = 13, text_family = "Times New Roman")
expect_equal(merge(ao_new, ao_old), ao_merged)
})

test_that("setting and getting animation options works", {
set_font_size(5, 10)
expect_equal(get_anim_opt(), anim_options(text_size = 5, title_size = 10))
expect_error(get_anim_opt("text_size"))
expect_equal(get_text_size(), get_anim_opt()$text_size)

anim_options_set(anim_options(2, 1))
expect_equal(get_anim_opt("transition_length"), 2)
expect_equal(get_anim_opt("state_length"), 1)
expect_equal(get_anim_opt(), anim_options(2, 1, text_size = 5, title_size = 10))

anim_options_set(anim_options())
expect_equal(get_anim_opt("transition_length"), plot_settings$default$transition_length)

anim_options_set(anim_options(enter = enter_appear(early = TRUE)))
expect_equal(names(get_anim_opt("enter")), "enter_appear(early = TRUE)")
expect_s3_class(get_anim_opt("enter")[[1]], "ggproto")
})

Chargement…
Annuler
Enregistrer