# create plotting window
plot.new(); plot.window(c(-1,1), c(-1,1), asp=1); axis(1); axis(2)
# create raster image, alpha is convenient when overplotting
img = matrix(adjustcolor("black", alpha.f=0.3), 3, 3)
img[2, 2] = adjustcolor("white", alpha.f=0.3)
img = as.raster(img)
rasters(0, 0, img)
# interpolate=FALSE makes quite a difference
rasters(0, 0, img, interpolate=FALSE)
# arguments are vectorized, standard recycling rules apply
rasters(0, 0, img, interpolate=FALSE, rotate=c(30, 60, 90))
rasters(c(-1, -0.5, 0.5, 1), c(1, 0.5, -0.5, -1), img, interpolate=FALSE)
Run the code above in your browser using DataLab