Browse Source

Fixed changing size of vector shapes

flabbet 8 months ago
parent
commit
9f24b64231

+ 16 - 2
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/VectorEllipseToolExecutor.cs

@@ -73,8 +73,22 @@ internal class VectorEllipseToolExecutor : DrawableShapeToolExecutor<IVectorElli
     {
         RectD rect = RectD.FromCenterAndSize(data.Center, data.Size);
         RectD firstRect = RectD.FromCenterAndSize(firstCenter, firstRadius * 2);
-        Matrix3X3 matrix = OperationHelper.CreateMatrixFromPoints(corners, firstRadius * 2);
-        matrix = matrix.Concat(Matrix3X3.CreateTranslation(-(float)firstRect.TopLeft.X, -(float)firstRect.TopLeft.Y));
+
+        Matrix3X3 matrix = Matrix3X3.Identity;
+        if (corners.IsRect)
+        {
+            firstCenter = corners.RectCenter;
+            firstRadius = corners.RectSize / 2f;
+            
+            if(corners.RectRotation != 0)
+                matrix = Matrix3X3.CreateRotation((float)corners.RectRotation, (float)firstCenter.X, (float)firstCenter.Y);
+        }
+        else
+        {
+            matrix = OperationHelper.CreateMatrixFromPoints(corners, firstRadius * 2);
+            matrix = matrix.Concat(
+                Matrix3X3.CreateTranslation(-(float)firstRect.TopLeft.X, -(float)firstRect.TopLeft.Y));
+        }
 
         EllipseVectorData ellipseData = new EllipseVectorData(firstCenter, firstRadius)
         {

+ 17 - 3
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/VectorRectangleToolExecutor.cs

@@ -80,9 +80,23 @@ internal class VectorRectangleToolExecutor : DrawableShapeToolExecutor<IVectorRe
             firstSize = data.Size;
         }
 
-        RectD firstRect = RectD.FromCenterAndSize(firstCenter, firstSize);
-        Matrix3X3 matrix = OperationHelper.CreateMatrixFromPoints(corners, firstSize);
-        matrix = matrix.Concat(Matrix3X3.CreateTranslation(-(float)firstRect.TopLeft.X, -(float)firstRect.TopLeft.Y));
+        Matrix3X3 matrix = Matrix3X3.Identity;
+        
+        if (!corners.IsRect)
+        {
+            RectD firstRect = RectD.FromCenterAndSize(firstCenter, firstSize);
+            matrix = OperationHelper.CreateMatrixFromPoints(corners, firstSize);
+            matrix = matrix.Concat(
+                Matrix3X3.CreateTranslation(-(float)firstRect.TopLeft.X, -(float)firstRect.TopLeft.Y));
+        }
+        else
+        {
+            firstCenter = data.Center;
+            firstSize = data.Size;
+            
+            if(corners.RectRotation != 0)
+                matrix = Matrix3X3.CreateRotation((float)corners.RectRotation, (float)firstCenter.X, (float)firstCenter.Y);
+        }
 
         RectangleVectorData newData = new RectangleVectorData(firstCenter, firstSize)
         {