Bläddra i källkod

Added possibility to rotate ellipses in ellipse tool

flabbet 1 år sedan
förälder
incheckning
77bee2b0cc

+ 6 - 3
src/PixiEditor.ChangeableDocument/Changes/Drawing/DrawEllipse_UpdateableChange.cs

@@ -7,6 +7,7 @@ internal class DrawEllipse_UpdateableChange : UpdateableChange
 {
     private readonly Guid memberGuid;
     private RectI location;
+    private double rotation;
     private readonly Color strokeColor;
     private readonly Color fillColor;
     private readonly int strokeWidth;
@@ -16,10 +17,11 @@ internal class DrawEllipse_UpdateableChange : UpdateableChange
     private CommittedChunkStorage? storedChunks;
 
     [GenerateUpdateableChangeActions]
-    public DrawEllipse_UpdateableChange(Guid memberGuid, RectI location, Color strokeColor, Color fillColor, int strokeWidth, bool drawOnMask, int frame)
+    public DrawEllipse_UpdateableChange(Guid memberGuid, RectI location, double rotationRad, Color strokeColor, Color fillColor, int strokeWidth, bool drawOnMask, int frame)
     {
         this.memberGuid = memberGuid;
         this.location = location;
+        this.rotation = rotationRad;
         this.strokeColor = strokeColor;
         this.fillColor = fillColor;
         this.strokeWidth = strokeWidth;
@@ -28,9 +30,10 @@ internal class DrawEllipse_UpdateableChange : UpdateableChange
     }
 
     [UpdateChangeMethod]
-    public void Update(RectI location)
+    public void Update(RectI location, double rotationRad)
     {
         this.location = location;
+        rotation = rotationRad;
     }
 
     public override bool InitializeAndValidate(Document target)
@@ -47,7 +50,7 @@ internal class DrawEllipse_UpdateableChange : UpdateableChange
         if (!location.IsZeroOrNegativeArea)
         {
             DrawingChangeHelper.ApplyClipsSymmetriesEtc(target, targetImage, memberGuid, drawOnMask);
-            targetImage.EnqueueDrawEllipse(location, strokeColor, fillColor, strokeWidth);
+            targetImage.EnqueueDrawEllipse(location, strokeColor, fillColor, strokeWidth, rotation);
         }
 
         var affectedArea = targetImage.FindAffectedArea();

+ 3 - 3
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/EllipseToolExecutor.cs

@@ -22,15 +22,15 @@ internal class EllipseToolExecutor : ShapeToolExecutor<IEllipseToolHandler>
 
         lastRect = rect;
 
-        internals!.ActionAccumulator.AddActions(new DrawEllipse_Action(memberGuid, rect, strokeColor, fillColor, strokeWidth, drawOnMask, document!.AnimationHandler.ActiveFrameBindable));
+        internals!.ActionAccumulator.AddActions(new DrawEllipse_Action(memberGuid, rect, 0, strokeColor, fillColor, strokeWidth, drawOnMask, document!.AnimationHandler.ActiveFrameBindable));
     }
 
     public override ExecutorType Type => ExecutorType.ToolLinked;
-    protected override DocumentTransformMode TransformMode => DocumentTransformMode.Scale_NoRotate_NoShear_NoPerspective;
+    protected override DocumentTransformMode TransformMode => DocumentTransformMode.Scale_Rotate_Shear_NoPerspective;
     protected override void DrawShape(VecI currentPos, bool firstDraw) => DrawEllipseOrCircle(currentPos, firstDraw);
 
     protected override IAction TransformMovedAction(ShapeData data, ShapeCorners corners) =>
-        new DrawEllipse_Action(memberGuid, (RectI)RectD.FromCenterAndSize(data.Center, data.Size), strokeColor,
+        new DrawEllipse_Action(memberGuid, (RectI)RectD.FromCenterAndSize(data.Center, data.Size), corners.RectRotation, strokeColor,
             fillColor, strokeWidth, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
 
     protected override IAction EndDrawAction() => new EndDrawEllipse_Action();