Create cubing animation and record png frames using OpenGL.
animate(aCube, moves, fpt = 8, colvec = getOption("cubing.colors"), recolor = FALSE,
bg = grey(0.8), rand.col = FALSE, size = 0.98, col.interior = grey(0.5),
al.interior = 0.4, al.exterior = 1, start.delay = 2, move.delay = 0, rinit = 30,
bbox = TRUE, bbcolor = "#333377", bbemission = "#333377", bbspecular = "#3333FF",
bbshininess = 5, bbalpha = 0.5, movie = NULL, dir = file.path(getwd(), movie),
verbose = TRUE, start.fdelay = fpt, end.fdelay = fpt, move.fdelay = 1, …)
Any cube object.
A move sequence; either a single string or a character vector with one element per move. Can include URFDLBEMS face turns, wide turns and xyz rotations.
Number of frames per quarter turn. Must be a non-negative even integer. Whole cube rotations and wide moves use half the number of frames.
Vector of sticker colors. The default is the cubing.colors
option.
If TRUE
, previous rotations are ignored
and therefore the cube is recolored when initially displayed.
Background color.
If TRUE
then sticker colors are chosen at
random and colvec
is ignored.
Size of the individual cubies. Must be less than one. Values closer to one give cubes that look stickerless because the gap between cubies decreases. Smaller sizes give exploded cubes.
Color of the cube interior.
Alpha value of cube interior.
Alpha value of cube exterior.
The delay in seconds added to the start.
The delay in seconds between moves (turns or rotations).
The initial plot is rotated rinit
degrees about the z-axis.
Use a bounding box?
Bounding box parameter.
Bounding box parameter.
Bounding box parameter.
Bounding box parameter.
Bounding box parameter.
If movie
is a character string, then a png file is saved for every frame,
using movie
as the base file name. The following arguments are only relevant when
movie
is a character string.
The directory where the png frames are stored. If the directory does not exist then it is created. By default the name of the directory is the same as the base filename and is located within the working directory.
Print progress on the saving of the png frames?
The number of additional repeated frames added to the start.
The number of additional repeated frames added to the end.
The number of additional repeated frames between moves (turns or rotations).
Other parameters to be passed through to plotting functions.
The move U3 represents three quarter turns in a clockwise direction, and so the animation is different to the quarter turn anti-clockwise move U', even though the resulting cube is the same. This similarly applies to the U3' and U moves, and to the half turn moves U2 and U2'. Wide turns can be denoted by lower case or w notation, so u2 and Uw2 are equivalent.
This function uses the R package rgl which is an interface to OpenGL.
During the animation, the cube can be rotated using a mouse, and the rotations
will be captured in the png frames if movie
is not NULL
. See the
documentation for the rgl package to explore the large number of options available.
Following the production of the png frames, you can create movies or gifs using external utilities. One powerful command line utility is ffmpeg. ImageMagick is a software suite which performs similar conversions.
The plot3D
function also uses the rgl package to produce interactive plots
for individual cubes.
For a 2D version of the animate function, see plot.seqCubes
.
# NOT RUN {
scramb <- "D2F2UF2DR2DBL'BRULRUL2FL'U'"
aCube <- getMovesCube(scramb)
mvs <- "x2D'R'L2'U'FU'F'D'U'U'R'y'R'U'Ry'RU'R'U'RUR'U'R'U'F'UFRU'"
# }
# NOT RUN {
animate(aCube, mvs, movie = "ChoWRSolve")
# }
Run the code above in your browser using DataLab