R Under development (unstable) (2025-07-22 r88445 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(grid) > library(gridSVG) Attaching package: 'gridSVG' The following objects are masked from 'package:grid': linearGradient, pattern, radialGradient The following object is masked from 'package:grDevices': dev.off > > pdf(file = NULL) > grid.newpage() > # We are just going to be drawing a cross for our pattern > crossGrob <- gTree(children = gList( + linesGrob(), + linesGrob(x = unit(0:1, "npc"), y = unit(1:0, "npc"), + gp = gpar(lwd = 1)) + )) > > # Call the pattern "cross" > # Using a small device size because the line widths > # will be too small otherwise > registerPatternFill("cross", grob = crossGrob, + dev.width = 1, dev.height = 1) > > grid.circle(name = "filledcircle") > # Applying the pattern semi-transparently to the circle > grid.patternFill("filledcircle", label = "cross", alpha = 0.5) > grid.export("pattern-test.svg") > dev.off() null device 1 > > # Now lets create a new pattern that uses the existing pattern > # but much larger > pdf(file = NULL) > grid.newpage() > registerPatternFillRef("bigcross", "cross", + width = 0.3, height = 0.3) > grid.circle(name = "filledcircle") > grid.patternFill("filledcircle", label = "bigcross", alpha = 0.5) > grid.export("pattern-test-ref.svg") > dev.off() null device 1 > > # Test pattern offset > pdf(file = NULL) > grid.newpage() > grid.rect(y=1, height=.5, just="top", name="zero-offset") > grid.patternFill("zero-offset", label="cross") > offsetPattern <- pattern(crossGrob, x=unit(1, "cm"), + dev.width=1, dev.height=1) > grid.rect(y=0, height=.5, just="bottom", name="non-zero-offset") > grid.patternFill("non-zero-offset", offsetPattern) > grid.export("pattern-test-offset.svg") > dev.off() null device 1 > > > proc.time() user system elapsed 0.81 0.12 0.92