Helps me keep my pictures a little neater.
ULMLUS5MKUI6OROPBSXEDAD6VYL5UH2SZSEAVCTQBNKGNKCCN6WQC base_for_zoom = function(base)local n = basewhile scale(n) < base/2 doif scale(n*base) < base/2 thenn = n*baseelse -- scale linearlylocal n2 = nwhile scale(n2) < base/2 don2 = n2+nendreturn n2endendreturn nend
floor_to = function(n, base)return math.floor(n/base)*baseend
draw_grid = function()love.graphics.setColor(0.8, 0.8, 0.8)local xlo, xhi = sx(0), sx(Viewport.w)local ylo, yhi = sy(0), sy(Viewport.h)local base = base_for_zoom(100)xlo, xhi = floor_to(xlo, base), floor_to(xhi, base)+baseylo, yhi = floor_to(ylo, base), floor_to(yhi, base)+basefor x = xlo, xhi, base dolove.graphics.line(vx(x), 0, vx(x), Viewport.h)endfor y = ylo, yhi, base dolove.graphics.line(0, vy(y), Viewport.w, vy(y))endend
on.resize = function(w, h)Viewport.w, Viewport.h = w, hend