From 2ac875e6684e8d2a77a8f862d43be709405b7d3f Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Tue, 30 Apr 2024 14:26:36 +0200 Subject: [PATCH 1/2] add xDetails/yDetails methods --- NAMESPACE | 2 ++ R/grob.R | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 8a500fa..9652063 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -21,6 +21,8 @@ S3method(print,marquee_skip_inherit) S3method(print,marquee_style) S3method(str,marquee_style) S3method(widthDetails,marquee_grob) +S3method(xDetails,marquee_grob) +S3method(yDetails,marquee_grob) export(base_style) export(box) export(classic_style) diff --git a/R/grob.R b/R/grob.R index 8bccfd7..e06f96c 100644 --- a/R/grob.R +++ b/R/grob.R @@ -537,6 +537,10 @@ makeContext.marquee_grob <- function(x) { tlx <- x0*crad - y1*srad tly <- x0*srad + y1*crad + x$bbox <- list( + x = x$x + unit(c(blx, brx, trx, tlx), "bigpts"), + y = x$y + unit(c(bly, bry, try, tly), "bigpts") + ) 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")) @@ -678,6 +682,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) { From f093484401990a5abe5006e2832453c6102db898 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Tue, 30 Apr 2024 15:23:13 +0200 Subject: [PATCH 2/2] recycle origin --- R/grob.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/grob.R b/R/grob.R index e06f96c..f188dfd 100644 --- a/R/grob.R +++ b/R/grob.R @@ -538,8 +538,8 @@ makeContext.marquee_grob <- function(x) { tly <- x0*srad + y1*crad x$bbox <- list( - x = x$x + unit(c(blx, brx, trx, tlx), "bigpts"), - y = x$y + unit(c(bly, bry, try, tly), "bigpts") + x = rep(x$x, 4) + unit(c(blx, brx, trx, tlx), "bigpts"), + y = rep(x$y, 4) + unit(c(bly, bry, try, tly), "bigpts") ) 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"))