Skip to content

Commit

Permalink
Resizing images might work this time
Browse files Browse the repository at this point in the history
  • Loading branch information
Crazydiamonde committed May 23, 2024
1 parent cef144d commit 53b975b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ public static void resizeFromMouse(double mouseX, double mouseY,

Point2D center = new Point2D((mouseX + resizeDragAnchorX) / 2, (mouseY + resizeDragAnchorY) / 2);

Point2D rotatedSource = ObjectUtil.rotate(new Point2D(resizeDragSourceX, resizeDragSourceY), -rotation, center);
Point2D rotatedReal = ObjectUtil.rotate(new Point2D(mouseX, mouseY), -rotation, center);
Point2D rotatedAnchor = ObjectUtil.rotate(new Point2D(resizeDragAnchorX, resizeDragAnchorY), -rotation, center);

double deltaX = rotatedReal.getX() - rotatedAnchor.getX();
double deltaY = rotatedReal.getY() - rotatedAnchor.getY();

deltaX *= Math.signum(resizeInitialScaleX);
deltaX *= Math.signum(resizeDragSourceX - resizeDragAnchorX);
deltaX *= Math.signum(rotatedSource.getX() - rotatedAnchor.getX());

deltaY *= Math.signum(resizeInitialScaleY);
deltaY *= Math.signum(resizeDragSourceY - resizeDragAnchorY);
deltaY *= Math.signum(rotatedSource.getY() - rotatedAnchor.getY());

if (objectComponent instanceof RectangleComponent rectangleComponent) {
rectangleComponent.setWidth(Math.abs(deltaX));
Expand Down

0 comments on commit 53b975b

Please sign in to comment.