From 5a148cdadc1180ae2efcfd27098be7bc19d83282 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Sat, 10 Aug 2024 16:59:15 +0400 Subject: [PATCH] fix bug regarding clockwise rotation --- .../creme332/controller/canvas/transform/Rotator.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/creme332/controller/canvas/transform/Rotator.java b/src/main/java/com/github/creme332/controller/canvas/transform/Rotator.java index c816145..9dc85da 100644 --- a/src/main/java/com/github/creme332/controller/canvas/transform/Rotator.java +++ b/src/main/java/com/github/creme332/controller/canvas/transform/Rotator.java @@ -34,9 +34,6 @@ public void handleShapeSelection(int shapeIndex) { double radAngle = Math.toRadians(rotationDetails.angle * (rotationDetails.isClockwise ? -1 : 1)); startRotationAnimation(selectedWrapperCopy, shapeIndex, radAngle, rotationDetails.pivot); - - // Repaint canvas - canvas.repaint(); } /** @@ -52,9 +49,10 @@ public void startRotationAnimation(final ShapeWrapper selectedWrapperCopy, final final Point2D pivot) { if (radAngle == 0) return; + final int animationDelay = 10; // Delay in milliseconds between updates - final double stepAngle = Math.toRadians(1); // Step size for each update (1 degree) - final double totalSteps = Math.abs(radAngle) / stepAngle; // Total number of steps + final double stepAngle = Math.toRadians(1.0) * Math.signum(radAngle); // Step size for each update (1 degree) + final double totalSteps = Math.abs(radAngle) / Math.abs(stepAngle); // Total number of steps // Timer to handle the animation Timer timer = new Timer(animationDelay, new ActionListener() {