Generalized the grid-drawing mechanism, and added a sample that makes use of the generalization.