Skip to content

Commit

Permalink
Assume everything is a grid::grob. (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
MHenderson authored Mar 13, 2024
1 parent 979b1c4 commit 1e120b9
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 217 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
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
5 changes: 0 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
15 changes: 0 additions & 15 deletions R/above-grob.R

This file was deleted.

15 changes: 9 additions & 6 deletions R/above.R
Original file line number Diff line number Diff line change
@@ -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)
}
15 changes: 0 additions & 15 deletions R/beside-grob.R

This file was deleted.

8 changes: 5 additions & 3 deletions R/beside.R
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 2 additions & 2 deletions R/cycle.R
Original file line number Diff line number Diff line change
@@ -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))))
Expand Down
8 changes: 0 additions & 8 deletions R/flip-grob.R

This file was deleted.

8 changes: 4 additions & 4 deletions R/flip.R
Original file line number Diff line number Diff line change
@@ -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)
}
18 changes: 9 additions & 9 deletions R/nonet.R
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
9 changes: 0 additions & 9 deletions R/plot-picture.R

This file was deleted.

8 changes: 4 additions & 4 deletions R/quartet.R
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
11 changes: 0 additions & 11 deletions R/rot-grob.R

This file was deleted.

12 changes: 7 additions & 5 deletions R/rot.R
Original file line number Diff line number Diff line change
@@ -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))
)
}
12 changes: 6 additions & 6 deletions man/above.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions man/above.grob.Rd

This file was deleted.

6 changes: 2 additions & 4 deletions man/beside.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions man/beside.grob.Rd

This file was deleted.

8 changes: 4 additions & 4 deletions man/flip.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions man/flip.grob.Rd

This file was deleted.

19 changes: 0 additions & 19 deletions man/plot.picture.Rd

This file was deleted.

10 changes: 5 additions & 5 deletions man/rot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1e120b9

Please sign in to comment.