From 5704ae25c861d289a4d9be06accf3be5d2ef8924 Mon Sep 17 00:00:00 2001 From: Matthew Henderson Date: Wed, 13 Mar 2024 14:14:43 +0000 Subject: [PATCH] Assume everything is a grid::grob. --- DESCRIPTION | 3 ++- NAMESPACE | 5 ----- R/above-grob.R | 15 --------------- R/above.R | 15 +++++++++------ R/beside-grob.R | 15 --------------- R/beside.R | 8 +++++--- R/cycle.R | 4 ++-- R/flip-grob.R | 8 -------- R/flip.R | 8 ++++---- R/nonet.R | 18 +++++++++--------- R/plot-picture.R | 9 --------- R/quartet.R | 8 ++++---- R/rot-grob.R | 11 ----------- R/rot.R | 12 +++++++----- man/above.Rd | 12 ++++++------ man/above.grob.Rd | 23 ----------------------- man/beside.Rd | 6 ++---- man/beside.grob.Rd | 23 ----------------------- man/flip.Rd | 8 ++++---- man/flip.grob.Rd | 17 ----------------- man/plot.picture.Rd | 19 ------------------- man/rot.Rd | 10 +++++----- man/rot.grob.Rd | 19 ------------------- 23 files changed, 59 insertions(+), 217 deletions(-) delete mode 100644 R/above-grob.R delete mode 100644 R/beside-grob.R delete mode 100644 R/flip-grob.R delete mode 100644 R/plot-picture.R delete mode 100644 R/rot-grob.R delete mode 100644 man/above.grob.Rd delete mode 100644 man/beside.grob.Rd delete mode 100644 man/flip.grob.Rd delete mode 100644 man/plot.picture.Rd delete mode 100644 man/rot.grob.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 3b44126..4cfddf2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,14 @@ Package: funcgeo Type: Package Title: Functional Geometry in R -Version: 0.2.1 +Version: 0.2.1.9000 Authors@R: person("Matthew", "Henderson", email = "matthew.james.henderson@gmail.com", role = c("aut", "cre")) Description: Peter Henderson's Functional Geometry in R. License: MIT + file LICENSE Imports: grid +Encoding: UTF-8 RoxygenNote: 7.2.3 URL: https://github.com/mhenderson/funcgeo BugReports: https://github.com/mhenderson/funcgeo/issues diff --git a/NAMESPACE b/NAMESPACE index b51553a..1feeb4c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,10 +1,5 @@ # Generated by roxygen2: do not edit by hand -S3method(above,grob) -S3method(beside,grob) -S3method(flip,grob) -S3method(plot,picture) -S3method(rot,grob) export(above) export(beside) export(cycle) diff --git a/R/above-grob.R b/R/above-grob.R deleted file mode 100644 index 964e259..0000000 --- a/R/above-grob.R +++ /dev/null @@ -1,15 +0,0 @@ -#' Superimpose two grobs, one above the other. -#' -#' @param p A grob -#' @param q Another grob -#' @param m An integer -#' @param n Another integer -#' @return A new grob obtained by superimposing p and q, one above the other. -#' @export -above.grob <- function(p, q, m = 1, n = 1) { - fg <- grid::frameGrob(layout = grid::grid.layout(2, 1)) - fg <- grid::packGrob(fg, p, row = 1, height = grid::unit(m/(m + n), "npc")) - fg <- grid::packGrob(fg, q, row = 2, height = grid::unit(n/(m + n), "npc")) - class(fg) <- c("picture", class(fg)) - return(fg) -} diff --git a/R/above.R b/R/above.R index af93c09..dfbf0f7 100644 --- a/R/above.R +++ b/R/above.R @@ -1,11 +1,14 @@ -#' Superimpose two pictures, one above the other. +#' Superimpose two grobs, one above the other. #' -#' @param p A picture -#' @param q Another picture +#' @param p A grob +#' @param q Another grob #' @param m An integer #' @param n Another integer -#' @return A picture +#' @return A new grob obtained by superimposing p and q, one above the other. #' @export -above <- function(p, q, m, n) { - UseMethod("above") +above <- function(p, q, m = 1, n = 1) { + fg <- grid::frameGrob(layout = grid::grid.layout(2, 1)) + fg <- grid::packGrob(fg, p, row = 1, height = grid::unit(m/(m + n), "npc")) + fg <- grid::packGrob(fg, q, row = 2, height = grid::unit(n/(m + n), "npc")) + return(fg) } diff --git a/R/beside-grob.R b/R/beside-grob.R deleted file mode 100644 index c7c9834..0000000 --- a/R/beside-grob.R +++ /dev/null @@ -1,15 +0,0 @@ -#' Superimpose two grobs side-by-side. -#' -#' @param p grob -#' @param q grob -#' @param m An integer -#' @param n Another integer -#' @return A grob -#' @export -beside.grob <- function(p, q, m = 1, n = 1) { - fg <- grid::frameGrob(layout = grid::grid.layout(1, 2)) - fg <- grid::packGrob(fg, p, col = 1, width = grid::unit(m/(m + n), "npc")) - fg <- grid::packGrob(fg, q, col = 2, width = grid::unit(n/(m + n), "npc")) - class(fg) <- c("picture", class(fg)) - return(fg) -} diff --git a/R/beside.R b/R/beside.R index ee5f837..b656ee6 100644 --- a/R/beside.R +++ b/R/beside.R @@ -1,12 +1,14 @@ -#' Superimpose two grobs, side-by-side. +#' Superimpose two grobs side-by-side. #' #' @param p grob #' @param q grob #' @param m An integer #' @param n Another integer #' @return A grob -#' @return A picture #' @export beside <- function(p, q, m = 1, n = 1) { - UseMethod("beside", p) + fg <- grid::frameGrob(layout = grid::grid.layout(1, 2)) + fg <- grid::packGrob(fg, p, col = 1, width = grid::unit(m/(m + n), "npc")) + fg <- grid::packGrob(fg, q, col = 2, width = grid::unit(n/(m + n), "npc")) + return(fg) } diff --git a/R/cycle.R b/R/cycle.R index ce44549..077be0c 100644 --- a/R/cycle.R +++ b/R/cycle.R @@ -1,7 +1,7 @@ #' Cycle #' -#' @param p A picture -#' @return A picture +#' @param p A grob +#' @return A grob #' @export cycle <- function(p) { return(quartet(p, rot(rot(rot(p))), rot(p), rot(rot(p)))) diff --git a/R/flip-grob.R b/R/flip-grob.R deleted file mode 100644 index 615ab79..0000000 --- a/R/flip-grob.R +++ /dev/null @@ -1,8 +0,0 @@ -#' Flip a grob. -#' -#' @param g A grob -#' @return Flipped grob -#' @export -flip.grob <- function(g) { - grid::editGrob(g, x = grid::unit(1, "npc") - g$x) -} diff --git a/R/flip.R b/R/flip.R index 2069526..ad1733f 100644 --- a/R/flip.R +++ b/R/flip.R @@ -1,8 +1,8 @@ -#' Flip a picture. +#' Flip a grob. #' -#' @param g A picture -#' @return Flipped picture +#' @param g A grob +#' @return Flipped grob #' @export flip <- function(g) { - UseMethod("flip", g) + grid::editGrob(g, x = grid::unit(1, "npc") - g$x) } diff --git a/R/nonet.R b/R/nonet.R index d5c7f84..3c0cb73 100644 --- a/R/nonet.R +++ b/R/nonet.R @@ -1,14 +1,14 @@ #' Nonet #' -#' @param a A picture -#' @param s Another picture -#' @param d Yet another picture -#' @param f The last picture -#' @param g A picture -#' @param h Another picture -#' @param j Yet another picture -#' @param k The last picture -#' @param l The last picture +#' @param a A grob +#' @param s Another grob +#' @param d Yet another grob +#' @param f The last grob +#' @param g A grob +#' @param h Another grob +#' @param j Yet another grob +#' @param k The last grob +#' @param l The last grob #' @return A grob #' @export nonet <- function(a, s, d, f, g, h, j, k, l) { C <- beside(f, beside(g, h, m = 1, n = 1), m = 1, n = 2) diff --git a/R/plot-picture.R b/R/plot-picture.R deleted file mode 100644 index e1e4b23..0000000 --- a/R/plot-picture.R +++ /dev/null @@ -1,9 +0,0 @@ -#' plot.picture -#' -#' @param x A picture -#' @param ... Anything else. -#' @return grid.draw(picture) -#' @export -plot.picture <- function(x, ...) { - grid::grid.draw(x) -} diff --git a/R/quartet.R b/R/quartet.R index e5347a3..ea91e47 100644 --- a/R/quartet.R +++ b/R/quartet.R @@ -1,9 +1,9 @@ #' Quartet #' -#' @param p A picture -#' @param q Another picture -#' @param r Yet another picture -#' @param s The last picture +#' @param p A grob +#' @param q Another grob +#' @param r Yet another grob +#' @param s The last grob #' @return A grob #' @export quartet <- function(p, q, r, s) { diff --git a/R/rot-grob.R b/R/rot-grob.R deleted file mode 100644 index 97a84b3..0000000 --- a/R/rot-grob.R +++ /dev/null @@ -1,11 +0,0 @@ -#' Rotate a grob. -#' -#' @param g A grob -#' @param angle An angle -#' @return Rotated grob -#' @export -rot.grob <- function(g, angle = 90) { - grid::editGrob(g, vp = grid::viewport( - angle = ifelse(is.null(g$vp$angle), angle, g$vp$angle + angle)) - ) -} diff --git a/R/rot.R b/R/rot.R index efe7da8..6101a5d 100644 --- a/R/rot.R +++ b/R/rot.R @@ -1,9 +1,11 @@ -#' Rotate a picture. +#' Rotate a grob. #' -#' @param g A picture +#' @param g A grob #' @param angle An angle -#' @return Rotated picture +#' @return Rotated grob #' @export -rot <- function(g, angle) { - UseMethod("rot", g) +rot <- function(g, angle = 90) { + grid::editGrob(g, vp = grid::viewport( + angle = ifelse(is.null(g$vp$angle), angle, g$vp$angle + angle)) + ) } diff --git a/man/above.Rd b/man/above.Rd index 7156132..10386c1 100644 --- a/man/above.Rd +++ b/man/above.Rd @@ -2,22 +2,22 @@ % Please edit documentation in R/above.R \name{above} \alias{above} -\title{Superimpose two pictures, one above the other.} +\title{Superimpose two grobs, one above the other.} \usage{ -above(p, q, m, n) +above(p, q, m = 1, n = 1) } \arguments{ -\item{p}{A picture} +\item{p}{A grob} -\item{q}{Another picture} +\item{q}{Another grob} \item{m}{An integer} \item{n}{Another integer} } \value{ -A picture +A new grob obtained by superimposing p and q, one above the other. } \description{ -Superimpose two pictures, one above the other. +Superimpose two grobs, one above the other. } diff --git a/man/above.grob.Rd b/man/above.grob.Rd deleted file mode 100644 index 19ed06f..0000000 --- a/man/above.grob.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/above-grob.R -\name{above.grob} -\alias{above.grob} -\title{Superimpose two grobs, one above the other.} -\usage{ -\method{above}{grob}(p, q, m = 1, n = 1) -} -\arguments{ -\item{p}{A grob} - -\item{q}{Another grob} - -\item{m}{An integer} - -\item{n}{Another integer} -} -\value{ -A new grob obtained by superimposing p and q, one above the other. -} -\description{ -Superimpose two grobs, one above the other. -} diff --git a/man/beside.Rd b/man/beside.Rd index e963a18..61832d6 100644 --- a/man/beside.Rd +++ b/man/beside.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/beside.R \name{beside} \alias{beside} -\title{Superimpose two grobs, side-by-side.} +\title{Superimpose two grobs side-by-side.} \usage{ beside(p, q, m = 1, n = 1) } @@ -17,9 +17,7 @@ beside(p, q, m = 1, n = 1) } \value{ A grob - -A picture } \description{ -Superimpose two grobs, side-by-side. +Superimpose two grobs side-by-side. } diff --git a/man/beside.grob.Rd b/man/beside.grob.Rd deleted file mode 100644 index 4007704..0000000 --- a/man/beside.grob.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/beside-grob.R -\name{beside.grob} -\alias{beside.grob} -\title{Superimpose two grobs side-by-side.} -\usage{ -\method{beside}{grob}(p, q, m = 1, n = 1) -} -\arguments{ -\item{p}{grob} - -\item{q}{grob} - -\item{m}{An integer} - -\item{n}{Another integer} -} -\value{ -A grob -} -\description{ -Superimpose two grobs side-by-side. -} diff --git a/man/flip.Rd b/man/flip.Rd index 8d36393..a061fcb 100644 --- a/man/flip.Rd +++ b/man/flip.Rd @@ -2,16 +2,16 @@ % Please edit documentation in R/flip.R \name{flip} \alias{flip} -\title{Flip a picture.} +\title{Flip a grob.} \usage{ flip(g) } \arguments{ -\item{g}{A picture} +\item{g}{A grob} } \value{ -Flipped picture +Flipped grob } \description{ -Flip a picture. +Flip a grob. } diff --git a/man/flip.grob.Rd b/man/flip.grob.Rd deleted file mode 100644 index 20df25a..0000000 --- a/man/flip.grob.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/flip-grob.R -\name{flip.grob} -\alias{flip.grob} -\title{Flip a grob.} -\usage{ -\method{flip}{grob}(g) -} -\arguments{ -\item{g}{A grob} -} -\value{ -Flipped grob -} -\description{ -Flip a grob. -} diff --git a/man/plot.picture.Rd b/man/plot.picture.Rd deleted file mode 100644 index 85d45db..0000000 --- a/man/plot.picture.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot-picture.R -\name{plot.picture} -\alias{plot.picture} -\title{plot.picture} -\usage{ -\method{plot}{picture}(x, ...) -} -\arguments{ -\item{x}{A picture} - -\item{...}{Anything else.} -} -\value{ -grid.draw(picture) -} -\description{ -plot.picture -} diff --git a/man/rot.Rd b/man/rot.Rd index 1d3b486..ecd57a5 100644 --- a/man/rot.Rd +++ b/man/rot.Rd @@ -2,18 +2,18 @@ % Please edit documentation in R/rot.R \name{rot} \alias{rot} -\title{Rotate a picture.} +\title{Rotate a grob.} \usage{ -rot(g, angle) +rot(g, angle = 90) } \arguments{ -\item{g}{A picture} +\item{g}{A grob} \item{angle}{An angle} } \value{ -Rotated picture +Rotated grob } \description{ -Rotate a picture. +Rotate a grob. } diff --git a/man/rot.grob.Rd b/man/rot.grob.Rd deleted file mode 100644 index 557fe4b..0000000 --- a/man/rot.grob.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rot-grob.R -\name{rot.grob} -\alias{rot.grob} -\title{Rotate a grob.} -\usage{ -\method{rot}{grob}(g, angle = 90) -} -\arguments{ -\item{g}{A grob} - -\item{angle}{An angle} -} -\value{ -Rotated grob -} -\description{ -Rotate a grob. -}