An implementation of layers in R's pdf() graphics device