This code is to be run with R 4.2.0 to produce images that reflect the old behaviour of Cairo compositing operators.
library(grid)
src <- rectGrob(x=2/3, y=1/3, width=.5, height=.5, gp=gpar(col=NA, fill=rgb(0, 0, .9))) dst <- rectGrob(x=1/3, y=2/3, width=.5, height=.5, gp=gpar(col=NA, fill=rgb(.7, 0, 0)))
group <- function(src, op, dst) { pushViewport(viewport(width=.95, height=.95)) grid.rect() grid.group(src, op, dst) grid.text(op, x=.1, y=.1, just=c("left", "bottom"), gp=gpar(cex=.7, fontfamily="HersheySans")) popViewport() }
pushViewport(viewport(x=0, width=.5, just="left")) group(src, "clear", dst) popViewport() pushViewport(viewport(x=.5, width=.5, just="left")) group(src, "source", dst) popViewport()