anim_rotation: Animate an element through rotation

Description Usage Arguments Value Examples

View source: R/anim_rotation.R

Description

Within an anims() call, itself passed to any anims argument, the anim_rotation() function can be used to express an animation where the target element undergoes a rotation change with time.

Usage

1
2
3
4
5
6
anim_rotation(
  rotation = NULL,
  anchor = "center",
  easing_fn = NULL,
  initial = FALSE
)

Arguments

rotation

The rotation value of the element at the keyframe time (given as the LHS value in the anims() call).

anchor

The location of the element anchor about which rotation will occur. By default, this is the keyword "center".

easing_fn

The timing or easing function to use for the animation. If not provided, the linear() timing function will be used (which is doesn't use any easing in the animation, just a linear movement). The other timing and easing functions are: step_start(), step_end(), ease_in(), ease_out(), and ease_in_out().

initial

Should this rotation value be the initial rotation state of the element? If so, use TRUE and any value provided to rotation will be disregarded.

Value

An anim_opacity object, which is to be used as part of an anims() call.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
if (interactive()) {

# This is a basic animation of an
# element's rotation state (moving to
# a new `rotation` value)
SVG(width = 300, height = 300) %>%
  svg_rect(
    x = 50, y = 50,
    width = 50, height = 50,
    attrs = svg_attrs_pres(
      stroke = "magenta",
      fill = "lightblue"
    ),
    anims = anims(
      2.0 ~ anim_rotation(rotation = 180)
    )
  )
}

omsvg documentation built on Feb. 10, 2021, 5:10 p.m.