R/s3-ggplot2-CoordFixed.R

Defines functions .cstr_construct.CoordFixed.coord_fixed .cstr_construct.CoordFixed.environment is_corrupted_CoordFixed .cstr_construct.CoordFixed opts_CoordFixed

Documented in opts_CoordFixed

#' @export
#' @rdname other-opts
opts_CoordFixed <- function(constructor = c("coord_fixed", "next", "environment"), ...) {
  .cstr_options("CoordFixed", constructor = constructor[[1]], ...)
}

#' @export
#' @method .cstr_construct CoordFixed
.cstr_construct.CoordFixed <- function(x, ...) {
  opts <- list(...)$opts$CoordFixed %||% opts_CoordFixed()
  if (is_corrupted_CoordFixed(x) || opts$constructor == "next") return(NextMethod())
  UseMethod(".cstr_construct.CoordFixed", structure(NA, class = opts$constructor))
}

is_corrupted_CoordFixed <- function(x) {
  # TODO
  FALSE
}

#' @export
#' @method .cstr_construct.CoordFixed environment
.cstr_construct.CoordFixed.environment <- function(x, ...) {
  .cstr_construct.environment(x, ...)
}

#' @export
#' @method .cstr_construct.CoordFixed coord_fixed
.cstr_construct.CoordFixed.coord_fixed <- function(x, ...) {
  args <- list(
  xlim = x$limits$x,
  ylim = x$limits$y,
  ratio = x$ratio,
  expand = x$expand,
  clip = x$clip
)
args <- keep_only_non_defaults(args, ggplot2::coord_fixed)
.cstr_apply(args, "ggplot2::coord_fixed", ...)
}

Try the constructive package in your browser

Any scripts or data that you put into this service are public.

constructive documentation built on April 3, 2025, 9:39 p.m.