MyNixOS website logo
Description

R Bindings to the 'Anime.js' Animation Library.

Provides low-level R bindings to the 'Anime.js' library (<https://animejs.com>), enabling the creation of browser-native SVG and HTML animations via the 'htmlwidgets' framework.

animejs

CRANstatus R-CMD-check Codecov testcoverage

animejs provides R bindings to Anime.js v4, a JavaScript animation library. It produces self-contained HTML widgets via htmlwidgets that render in browser environments like RStudio Viewer, R Markdown documents, Quarto reports, and Shiny applications.

Installation

You can install the released version of animejs from CRAN:

install.packages("animejs")

Or install the development version of animejs from GitHub with:

# install.packages("pak")
pak::pak("long39ng/animejs")

Usage

Annotate SVG elements with a data-animejs-id attribute or a CSS class, then build a timeline in R and render it as a widget.

library(animejs)

svg_src <- '
<svg viewBox="0 0 400 200" xmlns="http://www.w3.org/2000/svg">
  <circle data-animejs-id="c1" cx="50"  cy="100" r="20" fill="#4e79a7"/>
  <circle data-animejs-id="c2" cx="120" cy="100" r="20" fill="#f28e2b"/>
  <circle data-animejs-id="c3" cx="190" cy="100" r="20" fill="#e15759"/>
</svg>
'

anime_timeline(
  duration = 800,
  ease = anime_easing_elastic(),
  loop = TRUE
) |>
  anime_add(
    selector = anime_target_css("circle"),
    props = list(
      translateY = anime_from_to(-80, 0),
      opacity = anime_from_to(0, 1)
    ),
    stagger = anime_stagger(150, from = "first")
  ) |>
  anime_add(
    selector = anime_target_id("c2"),
    props = list(r = anime_from_to(20, 40)),
    offset = "+=200"
  ) |>
  anime_render(svg = svg_src)
Three circles animating into view with a staggered elastic entrance, followed by the middle circle expanding.

Key concepts

Timeline.anime_timeline() initialises a timeline with default duration, ease, and delay. anime_add() appends animation segments to it.

Properties.anime_from_to() describes a two-value transition; anime_keyframes() describes a multi-step sequence. Both are passed inside the props list of anime_add().

Stagger.anime_stagger() distributes animation start times across the elements matched by a selector. Supports linear, centre-out, and 2-D grid distributions.

Easing. All easing constructors return anime_easing objects serialised to Anime.js v4 strings. Parameterised families – anime_easing_elastic(), anime_easing_spring(), anime_easing_bezier(), anime_easing_steps(), anime_easing_back() – are also available.

Playback.anime_playback() controls looping, direction, and an optional play/pause/scrub control bar injected into the widget.

Metadata

Version

0.1.0

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows