JBezier: Parameterised transition timings

View source: R/anim-tools.R

JBezierR Documentation

Parameterised transition timings

Description

These functions allow you to create custom transition timing functions. See Examples below for usage.

Usage

JBezier(p0, p1, p2, p3)

JStep(time)

Arguments

p0, p1, p2, p3

Define the two control points (P1 & P2) of a cubic bezier curve with end points at (0, 0) and (1, 1).

time

Time at which to step from initial value to final value. Time is expressed as a fraction of the scene duration. The scene starts at time 0 and ends at time 1.

Value

A timing function.

See Also

JTransition, JEase, JScene, JLoop, JEase

Examples

## Not run: 
# Replicate the \link{JEaseOut} timing function
JScene(1, 30,
       width = JTransition(.1, 1, timing = JBezier(0, 0, 0.58, 1)),
       plotFn = function(width) {
           # Do something with width
       })

## End(Not run)

# Function to graphically visualise a timing function
VisualiseTimingFun <- function(fn) plot(seq(0, 1, .001), fn(seq(0, 1, .001)), type = "l")

# Visualise a custom step function
VisualiseTimingFun(JStep(0.3))

# Visualise a custom bezier function which begins slowly and ends fast
VisualiseTimingFun(JBezier(0.7, 0.1, 0.95, 0.7))


JimMcL/JUtils documentation built on Nov. 7, 2024, 11:25 a.m.