if (require("grid", quietly = TRUE)) {
gp <- gpar(col="black", fill="yellow")
rect <- pp_shape(label="rect")
convex6 <- pp_shape(label="convex6")
circle <- pp_shape(label="circle")
pushViewport(viewport(x=0.25, y=0.75, width=1/2, height=1/2))
grid.draw(rect$shape(gp=gp))
grid.draw(rect$gridlines(gp=gpar(col="blue", lex=4)))
grid.draw(rect$hexlines(gp=gpar(col="green")))
popViewport()
pushViewport(viewport(x=0.75, y=0.75, width=1/2, height=1/2))
grid.draw(convex6$shape(gp=gp))
grid.draw(convex6$checkers(gp=gpar(fill="blue")))
popViewport()
pushViewport(viewport(x=0.25, y=0.25, width=1/2, height=1/2))
grid.draw(circle$shape(gp=gp))
grid.draw(circle$mat(mat_width=0.2, gp=gpar(fill="blue")))
popViewport()
pushViewport(viewport(x=0.75, y=0.25, width=1/2, height=1/2))
grid.draw(rect$shape(gp=gp))
grid.draw(rect$mat(mat_width=c(0.2, 0.1, 0.3, 0.4), gp=gpar(fill="blue")))
popViewport()
}
if (require("grid", quietly = TRUE)) {
grid.newpage()
gp <- gpar(col="black", fill="yellow")
vp <- viewport(x=1/4, y=1/4, width=1/2, height=1/2)
grid.draw(pp_shape("halma")$shape(gp=gp, vp=vp))
vp <- viewport(x=3/4, y=1/4, width=1/2, height=1/2)
grid.draw(pp_shape("pyramid")$shape(gp=gp, vp=vp))
vp <- viewport(x=3/4, y=3/4, width=1/2, height=1/2)
grid.draw(pp_shape("kite")$shape(gp=gp, vp=vp))
vp <- viewport(x=1/4, y=3/4, width=1/2, height=1/2)
grid.draw(pp_shape("meeple")$shape(gp=gp, vp=vp))
}
if (require("grid", quietly = TRUE)) {
grid.newpage()
vp <- viewport(x=1/4, y=1/4, width=1/2, height=1/2)
grid.draw(pp_shape("convex3", 0)$shape(gp=gp, vp=vp))
vp <- viewport(x=3/4, y=1/4, width=1/2, height=1/2)
grid.draw(pp_shape("convex4", 90)$shape(gp=gp, vp=vp))
vp <- viewport(x=3/4, y=3/4, width=1/2, height=1/2)
grid.draw(pp_shape("convex5", 180)$shape(gp=gp, vp=vp))
vp <- viewport(x=1/4, y=3/4, width=1/2, height=1/2)
grid.draw(pp_shape("convex6", 270)$shape(gp=gp, vp=vp))
}
if (require("grid", quietly = TRUE)) {
grid.newpage()
vp <- viewport(x=1/4, y=1/4, width=1/2, height=1/2)
grid.draw(pp_shape("concave3", 0, 0.1)$shape(gp=gp, vp=vp))
vp <- viewport(x=3/4, y=1/4, width=1/2, height=1/2)
grid.draw(pp_shape("concave4", 90, 0.2)$shape(gp=gp, vp=vp))
vp <- viewport(x=3/4, y=3/4, width=1/2, height=1/2)
grid.draw(pp_shape("concave5", 180, 0.3)$shape(gp=gp, vp=vp))
vp <- viewport(x=1/4, y=3/4, width=1/2, height=1/2)
grid.draw(pp_shape("concave6", 270)$shape(gp=gp, vp=vp))
}
if (require("grid", quietly = TRUE) &&
requireNamespace("gridpattern", quietly = TRUE)) {
grid.newpage()
hex <- pp_shape("convex6")
gp <- gpar(fill = c("blue", "yellow", "red"), col = "black")
grid.draw(hex$pattern("polygon_tiling", gp = gp, spacing = 0.1,
type = "truncated_trihexagonal"))
gp <- gpar(fill = "black", col = NA)
grid.draw(hex$mat(mat_width = 0.025, gp = gp))
}
Run the code above in your browser using DataLab