ani.options {animation}R Documentation

Set or Query Animation Parameters

Description

Set or query various parameters that control the behaviour of the animation, such as time interval, maximum frames, height and width, etc. This function is based on options to set an option ani which is a list containing the animation parameters.

Usage

ani.options(...)

Arguments

... arguments in tag = value form, or a list of tagged values. The tags must come from the animation parameters described below.

Value

a list containing the options.
When parameters are set, their former values are returned in an invisible named list. Such a list can be passed as an argument to ani.options to restore the parameter values.

Animation Parameters

interval
a positive number to set the time interval of the animation (unit in seconds); default to be 1.
nmax
maximum number of steps for a loop (e.g. iterations) to create animation frames. Note: the actual number of frames can be less than this number, depending on specific animations. Default to be 50.
ani.width, ani.height
width and height of image frames (unit in px); see graphics devices like png, jpeg, ...; default to be 480.
outdir
character: specify the output dir if we want to create HTML animation pages; default to be tempdir.
imgdir
character: the name of the directory for images when creating HTML animation pages; default to be "images".
filename
character: name of the target HTML main file
withprompt
character: prompt to display while using ani.start (restore with ani.stop)
ani.type
character: image format for animation frames, e.g. png, jpg, ...; default to be "png"
ani.dev
a function or a function name: the graphics device; e.g. (png, jpeg, ...); default to be "png"
title
character: the title of animation
description
character: a description about the animation
footer
logical or character: if TRUE, write a foot part in the HTML page containing information such as date/time of creation; if given a character string, it will be used as the footer message; in other cases, the footer of the page will be blank.
loop
whether to iterate or not (default TRUE to interate for infinite times)
autobrowse
logical: whether auto-browse the animation page immediately after it is created?

Note

Please note that nmax is usually equal to the number of animation frames (e.g. for brownian.motion) but not always! The reason is that sometimes there are more than one frame recorded in a single step of a loop, for instance, there are 2 frames generated in each step of kmeans.ani, and 4 frames in knn.ani, etc.

This function can be used for almost all the animation functions such as brownian.motion, boot.iid, buffon.needle, cv.ani, flip.coin, kmeans.ani, knn.ani, etc. All the parameters will affect the behaviour of HTML animations, but only interval will affect animations in windows graphics device.

When R is not running interactively, interval will be set to 0 because it does not make much sense to let R wait for a possibly very long time when we cannot watch the animations in real time.

Author(s)

Yihui Xie <http://yihui.name>

References

http://animation.yihui.name/animation:options

See Also

options

Examples

## Not run: 
# store the old option to restore it later
oopt = ani.options(interval = 0.05, nmax = 100, ani.dev = "png", 
    ani.type = "png")
ani.start() 
opar = par(mar = c(3, 3, 2, 0.5), mgp = c(2, .5, 0), tcl = -0.3,
    cex.axis = 0.8, cex.lab = 0.8, cex.main = 1) 
brownian.motion( pch = 21, cex = 5, col = "red", bg = "yellow",
    main = "Demonstration of Brownian Motion",)
par(opar)
ani.stop() 
ani.options(oopt)
## End(Not run)

[Package animation version 1.0-10 Index]