function rotate(angle) {
	apply_image_transformation({
		name: `${localize("Rotate by angle")} ${angle / TAU * 360} ${localize("Degrees")}`,
		icon: get_help_folder_icon(`p_rotate_${angle >= 0 ? "cw" : "ccw"}.png`),
	}, (original_canvas, _original_ctx, new_canvas, new_ctx) => {
		new_ctx.save();
		switch (angle) {
			case TAU / 4:
			case TAU * -3 / 4:
				new_canvas.width = original_canvas.height;
				new_canvas.height = original_canvas.width;
				new_ctx.disable_image_smoothing();
				new_ctx.translate(new_canvas.width, 0);
				new_ctx.rotate(TAU / 4);
				break;
			case TAU / 2:
			case TAU / -2:
				new_ctx.translate(new_canvas.width, new_canvas.height);
				new_ctx.rotate(TAU / 2);
				break;
			case TAU * 3 / 4:
			case TAU / -4:
				new_canvas.width = original_canvas.height;
				new_canvas.height = original_canvas.width;
				new_ctx.disable_image_smoothing();
				new_ctx.translate(0, new_canvas.height);
				new_ctx.rotate(TAU / -4);
				break;
			default: {
				const w = original_canvas.width;
				const h = original_canvas.height;

				let bb_min_x = +Infinity;
				let bb_max_x = -Infinity;
				let bb_min_y = +Infinity;
				let bb_max_y = -Infinity;
				const corner = (x01, y01) => {
					const x = Math.sin(-angle) * h * x01 + Math.cos(+angle) * w * y01;
					const y = Math.sin(+angle) * w * y01 + Math.cos(-angle) * h * x01;
					bb_min_x = Math.min(bb_min_x, x);
					bb_max_x = Math.max(bb_max_x, x);
					bb_min_y = Math.min(bb_min_y, y);
					bb_max_y = Math.max(bb_max_y, y);
				};

				corner(0, 0);
				corner(0, 1);
				corner(1, 0);
				corner(1, 1);

				const bb_x = bb_min_x;
				const bb_y = bb_min_y;
				const bb_w = bb_max_x - bb_min_x;
				const bb_h = bb_max_y - bb_min_y;

				new_canvas.width = bb_w;
				new_canvas.height = bb_h;
				new_ctx.disable_image_smoothing();

				if (!transparency) {
					new_ctx.fillStyle = selected_colors.background;
					new_ctx.fillRect(0, 0, new_canvas.width, new_canvas.height);
				}

				new_ctx.translate(-bb_x, -bb_y);
				new_ctx.rotate(angle);
				new_ctx.drawImage(original_canvas, 0, 0, w, h);
				break;
			}
		}
		new_ctx.drawImage(original_canvas, 0, 0);
		new_ctx.restore();
	});
}
Rotates the image (or selection) by the specified angle.

@param {number} angle - The angle of rotation in radians.