Skip to content

Commit

Permalink
add xDetails()/yDetails() methods (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand authored May 2, 2024
1 parent d65b2d4 commit c9f2cd1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ S3method(print,marquee_style)
S3method(print,marquee_trbl)
S3method(str,marquee_style)
S3method(widthDetails,marquee_grob)
S3method(xDetails,marquee_grob)
S3method(yDetails,marquee_grob)
export(GeomMarquee)
export(base_style)
export(classic_style)
Expand Down
12 changes: 12 additions & 0 deletions R/grob.R
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,10 @@ makeContext.marquee_grob <- function(x) {
tlx <- x0*crad - y1*srad
tly <- x0*srad + y1*crad

x$bbox <- list(
x = rep(x$x, 4) + unit(c(blx, brx, trx, tlx), "bigpts"),
y = rep(x$y, 4) + unit(c(bly, bry, try, tly), "bigpts")
)
if (length(x$x) > 1) {
x$full_width <- max(x$x + unit(pmax(blx, brx, trx, tlx), "bigpts")) - min(x$x + unit(pmin(blx, brx, trx, tlx), "bigpts"))
x$full_height <- max(x$y + unit(pmax(bly, bry, try, tly), "bigpts")) - min(x$y + unit(pmin(bly, bry, try, tly), "bigpts"))
Expand Down Expand Up @@ -684,6 +688,14 @@ heightDetails.marquee_grob <- function(x) {
widthDetails.marquee_grob <- function(x) {
x$full_width
}
#' @export
xDetails.marquee_grob <- function(x, theta) {
xDetails(structure(x$bbox, class = "points"), theta)
}
#' @export
yDetails.marquee_grob <- function(x, theta) {
yDetails(structure(x$bbox, class = "points"), theta)
}

#' @export
makeContent.marquee_grob <- function(x) {
Expand Down

0 comments on commit c9f2cd1

Please sign in to comment.