unctions = s2x_x2s_s2y_y2s();
		const s2x = functions[0];
		const x2s = functions[1];
		const s2y = functions[2];
		const y2s = functions[3];

		// the grid
		const scale = scale_value;
		const step = scale < 16 ? 1 : Math.floor(scale / 8);
		const stepped = function(x) {return Math.floor(x / step) * step;}

		context.beginPath();
		context.setLineDash([2, 3]);
		if(linear_scale_checked) {
			// horizontal
			for(var j = stepped(s2x(0)); j <= stepped(s2x(w)); j += step) {
				if(j != 0) {
					context.moveT