Skip to content

Commit

Permalink
fix: Support 'ani.res' for arbitrary graphic devices (#135)
Browse files Browse the repository at this point in the history
* Add support for 'ani.res' for arbitrary graphic devices
  in 'saveGIF()', 'saveHTML()', and 'saveVideo()'.
* Should work for any graphic device function with 'res'
  as an argument.  In particular should continue to support R's built-in
  raster image format devices as well as 'ragg::agg_png()'
  and R's built-in devices passed in as a function instead of string.
* Still no 'ani.res' support in 'saveLatex()' ('pdf' devices recommended)
  nor 'saveSWF()' (flash no longer supported in many browsers)
* Also fixes bug when 'ani.dev' is a function instead of a character vector

closes #133, closes #134


Checked, works fine on CentOS8.

Thank you Trevor!
  • Loading branch information
trevorld committed Jul 21, 2021
1 parent 740196e commit 5195d61
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions R/saveGIF.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ saveGIF = function(
img.fmt = paste(img.name, ani.options('imgnfmt'), '.', file.ext, sep = '')

if ((use.dev <- ani.options('use.dev'))){
if (is.character(ani.options('ani.dev')) &&
any(grepl(ani.options('ani.dev'), c("png", "bmp", "jpeg", "tiff")))){
if ("res" %in% names(formals(ani.dev))){
ani.dev(file.path(tempdir(), img.fmt), width = ani.options('ani.width'),
height = ani.options('ani.height'), res = ani.options('ani.res'))
# ,bg = ani.options('ani.bg')
} else {
ani.dev(file.path(tempdir(), img.fmt), width = ani.options('ani.width'),
height = ani.options('ani.height'))
Expand Down
3 changes: 1 addition & 2 deletions R/saveHTML.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ saveHTML = function(
img.fmt = file.path(imgdir, paste(img.name, ani.options('imgnfmt'), '.', ani.type, sep = ''))
ani.options(img.fmt = img.fmt)
if ((use.dev <- ani.options('use.dev'))) {
if (is.character(ani.options('ani.dev')) &&
any(grepl(ani.options('ani.dev'), c("png", "bmp", "jpeg", "tiff")))) {
if ("res" %in% names(formals(ani.dev))){
ani.dev(img.fmt, width = ani.options('ani.width'),
height = ani.options('ani.height'), res = ani.options('ani.res'))
} else {
Expand Down
3 changes: 1 addition & 2 deletions R/saveVideo.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ saveVideo = function(
img.fmt = file.path(tempdir(), img.fmt)
ani.options(img.fmt = img.fmt)
if ((use.dev <- ani.options('use.dev'))) {
if (is.character(ani.options('ani.dev')) &&
any(grepl(ani.options('ani.dev'), c("png", "bmp", "jpeg", "tiff")))) {
if ("res" %in% names(formals(ani.dev))){
ani.dev(img.fmt, width = ani.options('ani.width'),
height = ani.options('ani.height'), res = ani.options('ani.res'))
} else {
Expand Down

0 comments on commit 5195d61

Please sign in to comment.