-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add png_retina function, bump version
- Loading branch information
Showing
5 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#' Create png for retina display | ||
#' | ||
#' This is a drop-in replacement for the \code{\link[grDevices]{png}} function | ||
#' for creating images for the web for retina devices. Internally, it simply | ||
#' doubles the width, height, and resolution specified. The intention is then | ||
#' that in the webpage that you would specify the \code{width} and \code{height} | ||
#' attributes in the html at the original resolution. | ||
#' | ||
#' @inheritParams grDevices::png | ||
#' | ||
#' @return A plot device is opened: nothing is returned to the R interpreter. | ||
#' @export | ||
#' | ||
#' @seealso \code{\link[grDevices]{png}} | ||
#' | ||
#' @examples | ||
#' | ||
#' # You want to display at 500 * 500 in the web: | ||
#' png_retina("myplot.png", width = 500, height = 500) | ||
#' plot(x = 1:500, y = rnorm(500)) | ||
#' dev.off() | ||
#' | ||
#' # Although the output image will be 1000 * 1000, in the html you would put: | ||
#' # <img src="myplot.png", width="500", height="500" /> | ||
#' | ||
png_retina <- function(filename = "Rplot%03d.png", width = 480, height = 480, | ||
units = "px", pointsize = 12, bg = "white", res = NA, | ||
..., type = c("cairo", "cairo-png", "Xlib", "quartz"), | ||
antialias) { | ||
height <- height * 2 | ||
width <- width * 2 | ||
res <- ifelse(is.na(res), 144, res * 2) | ||
|
||
grDevices::png(filename = filename, width = width, height = height, | ||
units = units, pointsize = pointsize, bg = bg, res = res, ..., | ||
type = type, antialias = antialias) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.