fix: angles not flipping vertically when resizing

This commit is contained in:
Alex Kim 2022-12-19 15:54:47 +03:00
parent aa289a63fb
commit b9a185d098
No known key found for this signature in database
GPG key ID: CEE74CFA44D238D7

View file

@ -52,6 +52,9 @@ import {
import { getMaxContainerWidth } from "./newElement"; import { getMaxContainerWidth } from "./newElement";
export const normalizeAngle = (angle: number): number => { export const normalizeAngle = (angle: number): number => {
if (angle < 0) {
return angle + 2 * Math.PI;
}
if (angle >= 2 * Math.PI) { if (angle >= 2 * Math.PI) {
return angle - 2 * Math.PI; return angle - 2 * Math.PI;
} }
@ -667,7 +670,10 @@ const resizeMultipleElements = (
targetElements.forEach((element) => { targetElements.forEach((element) => {
const width = element.orig.width * scale; const width = element.orig.width * scale;
const height = element.orig.height * scale; const height = element.orig.height * scale;
const angle = element.orig.angle * flipFactorX * flipFactorY; const angle = normalizeAngle(
(isFlippedByY ? Math.PI - element.orig.angle : element.orig.angle) *
flipFactorX,
);
const hasPoints = const hasPoints =
isLinearElement(element.orig) || isFreeDrawElement(element.orig); isLinearElement(element.orig) || isFreeDrawElement(element.orig);