From 180d233202613329e175f002dfccbaf2f8a39b2a Mon Sep 17 00:00:00 2001 From: Andrea Gottsponer <ago@attr.ch> Date: Fri, 9 Sep 2022 13:55:43 +0200 Subject: [PATCH] - fix rotation (only integer possible) --- src/lib/elements/controls/SelectItemElement.ts | 2 ++ src/lib/elements/images/Image.ts | 4 ++++ src/lib/elements/primitives/ArrowPrimitive.ts | 4 ++++ src/lib/elements/primitives/BackgroundRectanglePrimitive.ts | 4 ++++ src/lib/elements/primitives/EllipsePrimitive.ts | 4 ++++ src/lib/elements/primitives/RectanglePrimitive.ts | 4 ++++ src/lib/elements/primitives/TextPrimitive.ts | 4 ++++ src/lib/elements/rotatings/RotateScaleElement.ts | 2 +- 8 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/lib/elements/controls/SelectItemElement.ts b/src/lib/elements/controls/SelectItemElement.ts index df1d0ed9..342a959e 100644 --- a/src/lib/elements/controls/SelectItemElement.ts +++ b/src/lib/elements/controls/SelectItemElement.ts @@ -626,6 +626,8 @@ export class SelectItemElement extends BaseContainer<SelectImageObjectElementMod * On start rotate */ public startRotate(): void { + (this.displayObject as MedsurfDraw.ArrowPrimitive | MedsurfDraw.EllipsePrimitive | MedsurfDraw.RectanglePrimitive | MedsurfDraw.TextPrimitive).startRotate(); + // Elements // -- Scale element this._scaleElement.hideItem(); diff --git a/src/lib/elements/images/Image.ts b/src/lib/elements/images/Image.ts index 321a72c7..fb907c1f 100644 --- a/src/lib/elements/images/Image.ts +++ b/src/lib/elements/images/Image.ts @@ -202,6 +202,10 @@ export class Image extends BaseContainer<ImageModel> { //<editor-fold desc="Events"> // -- Added this.on("added", (parent: PIXI.Container) => { + // TODO remove + console.log("test remove test"); + this.parent.interactive = true; + // Events // -- Resize parent.on("resize", this.onResize, this); diff --git a/src/lib/elements/primitives/ArrowPrimitive.ts b/src/lib/elements/primitives/ArrowPrimitive.ts index 4c6f83c0..188d9683 100644 --- a/src/lib/elements/primitives/ArrowPrimitive.ts +++ b/src/lib/elements/primitives/ArrowPrimitive.ts @@ -1652,6 +1652,10 @@ export class ArrowPrimitive extends BaseElementContainer<Models.ArrowPrimitive, //</editor-fold> //<editor-fold desc="Rotate"> + public startRotate(): void { + this.rotation = (Math.round(this.rotation / Math.PI * 180) * Math.PI / 180); + } + /** * On rotate * @param degree diff --git a/src/lib/elements/primitives/BackgroundRectanglePrimitive.ts b/src/lib/elements/primitives/BackgroundRectanglePrimitive.ts index 387cfb80..195adc67 100644 --- a/src/lib/elements/primitives/BackgroundRectanglePrimitive.ts +++ b/src/lib/elements/primitives/BackgroundRectanglePrimitive.ts @@ -1376,6 +1376,10 @@ export class BackgroundRectanglePrimitive extends BaseElementContainer<Models.Ba //</editor-fold> //<editor-fold desc="Rotate"> + public startRotate(): void { + this.rotation = (Math.round(this.rotation / Math.PI * 180) * Math.PI / 180); + } + /** * On rotate * @param degree diff --git a/src/lib/elements/primitives/EllipsePrimitive.ts b/src/lib/elements/primitives/EllipsePrimitive.ts index 19d7ab7c..517cadf8 100644 --- a/src/lib/elements/primitives/EllipsePrimitive.ts +++ b/src/lib/elements/primitives/EllipsePrimitive.ts @@ -1531,6 +1531,10 @@ export class EllipsePrimitive extends BaseElementContainer<Models.EllipsePrimiti //</editor-fold> //<editor-fold desc="Rotate"> + public startRotate(): void { + this.rotation = (Math.round(this.rotation / Math.PI * 180) * Math.PI / 180); + } + /** * On rotate * @param degree diff --git a/src/lib/elements/primitives/RectanglePrimitive.ts b/src/lib/elements/primitives/RectanglePrimitive.ts index be1ecfd8..36256f62 100644 --- a/src/lib/elements/primitives/RectanglePrimitive.ts +++ b/src/lib/elements/primitives/RectanglePrimitive.ts @@ -1532,6 +1532,10 @@ export class RectanglePrimitive extends BaseElementContainer<Models.RectanglePri //</editor-fold> //<editor-fold desc="Rotate"> + public startRotate(): void { + this.rotation = (Math.round(this.rotation / Math.PI * 180) * Math.PI / 180); + } + /** * On rotate * @param degree diff --git a/src/lib/elements/primitives/TextPrimitive.ts b/src/lib/elements/primitives/TextPrimitive.ts index 930ae53d..9c7cee4f 100644 --- a/src/lib/elements/primitives/TextPrimitive.ts +++ b/src/lib/elements/primitives/TextPrimitive.ts @@ -1748,6 +1748,10 @@ export class TextPrimitive extends BaseElementContainer<Models.TextPrimitive, Ba //</editor-fold> //<editor-fold desc="Rotate"> + public startRotate(): void { + this.rotation = (Math.round(this.rotation / Math.PI * 180) * Math.PI / 180); + } + /** * On rotate * @param degree diff --git a/src/lib/elements/rotatings/RotateScaleElement.ts b/src/lib/elements/rotatings/RotateScaleElement.ts index 14a560f4..356d54dd 100644 --- a/src/lib/elements/rotatings/RotateScaleElement.ts +++ b/src/lib/elements/rotatings/RotateScaleElement.ts @@ -178,7 +178,7 @@ export class RotateScaleElement extends BaseContainer<RotateScaleElementModel> { //<editor-fold desc="Private functions"> protected _formatDegree(): string { - let rotation = (Math.round((this.rotateElement.rotation / Math.PI * 180) * 100) / 100) % 360; + let rotation = (Math.round((this.rotateElement.rotation / Math.PI * 180))) % 360; if (rotation < 0) { rotation = 360 + rotation; } -- GitLab