rid_size) != pixel_in(j + 0.5 * grid_size, i + 0.5 * grid_size);
            var do_vertical = 
                pixel_in(j - 0.5 * grid_size, i + 0.5 * grid_size) != pixel_in(j + 0.5 * grid_size, i + 0.5 * grid_size);
            if(do_horizontal) {
                context.beginPath();
                var ds = pixel_in(j + 0.5 * grid_size, i - 0.5 * grid_size) < pixel_in(j + 0.5 * grid_size, i + 0.5 * grid_size) ? 1.0 : -1.0;
                var p1x = j + gsx(j, i);
                var p1y = i + gsy(j, i);
