drawing lines on a rectilinear grid (a little code sharing)