Skip to content

Commit

Permalink
fix bug regarding clockwise rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
creme332 committed Aug 10, 2024
1 parent 8b85150 commit 5a148cd
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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() {
Expand Down

0 comments on commit 5a148cd

Please sign in to comment.