2023-05-06 16:37:48 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <tuple>
|
|
|
|
|
|
|
|
typedef uint8_t Transformation;
|
|
|
|
|
|
|
|
const Transformation TRANSFORM_MIRROR_X = 1 << 0;
|
|
|
|
const Transformation TRANSFORM_MIRROR_Y = 1 << 1;
|
|
|
|
const Transformation TRANSFORM_ROTATE_CW = 1 << 2;
|
|
|
|
const Transformation TRANSFORM_ROTATE_CCW = 1 << 3;
|
|
|
|
|
|
|
|
// Applies the provided transformation to the point, mutating it in place.
|
|
|
|
// Rotation is done before mirroring.
|
|
|
|
void transform_mut(Transformation transformation, int &x, int &y);
|
|
|
|
// Applies the provided transformation to the point,
|
|
|
|
// returning the transformed point.
|
|
|
|
// Rotation is done before mirroring.
|
|
|
|
std::pair<int, int> transform(Transformation transformation, int x, int y);
|
|
|
|
|
|
|
|
// Applies the inverse transformation to the point, mutating it in place.
|
|
|
|
// Composition of this with the transformation is the identity function.
|
|
|
|
void transform_inv_mut(Transformation transformation, int &x, int &y);
|
|
|
|
// Applies the inverse transformation to the point,
|
|
|
|
// returning the transformed point.
|
|
|
|
// Composition of this with the transformation is the identity function.
|
|
|
|
std::pair<int, int> transform_inv(Transformation transformation, int x, int y);
|
2023-05-06 16:40:17 +02:00
|
|
|
|
|
|
|
// Returns the transformation required
|
|
|
|
// to make the given endpoints of a line conform
|
|
|
|
// to the standard case for rasterization.
|
|
|
|
Transformation transformation_to_standard_case(int x0, int y0, int x1, int y1);
|