// SPDX-License-Identifier: LGPL-3.0-or-later #include "util.h" #include void transform_mut(Transformation transformation, int &x, int &y) { if ((transformation & TRANSFORM_ROTATE_CW) != 0) { std::swap(x, y); x = -x; } if ((transformation & TRANSFORM_ROTATE_CCW) != 0) { std::swap(x, y); y = -y; } if ((transformation & TRANSFORM_MIRROR_X) != 0) { y = -y; } if ((transformation & TRANSFORM_MIRROR_Y) != 0) { x = -x; } } std::pair transform(Transformation transformation, int x, int y) { transform_mut(transformation, x, y); return std::make_pair(x, y); } void transform_inv_mut(Transformation transformation, int &x, int &y) { if ((transformation & TRANSFORM_MIRROR_Y) != 0) { x = -x; } if ((transformation & TRANSFORM_MIRROR_X) != 0) { y = -y; } if (transformation & TRANSFORM_ROTATE_CCW) { // does clockwise rotation std::swap(x, y); x = -x; } if (transformation & TRANSFORM_ROTATE_CW) { // does counterclockwise rotation std::swap(x, y); y = -y; } } std::pair transform_inv(Transformation transformation, int x, int y) { transform_inv_mut(transformation, x, y); return std::make_pair(x, y); }