R/ideal_dimension.R

Defines functions .ideal_dimension

#' Internal for now
#' 
#' @noRd
#' @importFrom grDevices dev.cur dev.size  contourLines
#' @importFrom graphics par
#' @importFrom utils head
.ideal_dimension <- function(dimension = 1024, extent = NULL) {
  if (dev.cur() > 1L) {
    px <- ceiling(dev.size("px") * par("pin")/dev.size())
  } else {
    dimension <- rep(dimension, length.out = 2L)
    if (is.null(extent)) extent <- c(0, dimension[1L], 0, dimension[2L])
    px <- ceiling(dimension * sort(c(1, diff(extent[1:2])/diff(extent[3:4])), decreasing = FALSE))
  }
  px
}
hypertidy/vaster documentation built on June 10, 2025, 8:09 a.m.