|
@@ -1,7 +1,9 @@
|
|
using ChunkyImageLib.DataHolders;
|
|
using ChunkyImageLib.DataHolders;
|
|
|
|
+using ChunkyImageLib.Operations;
|
|
using PixiEditor.ChangeableDocument.Actions;
|
|
using PixiEditor.ChangeableDocument.Actions;
|
|
using PixiEditor.ChangeableDocument.Actions.Generated;
|
|
using PixiEditor.ChangeableDocument.Actions.Generated;
|
|
using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.Shapes.Data;
|
|
using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.Shapes.Data;
|
|
|
|
+using PixiEditor.DrawingApi.Core.Numerics;
|
|
using PixiEditor.Models.Handlers.Tools;
|
|
using PixiEditor.Models.Handlers.Tools;
|
|
using PixiEditor.Models.Tools;
|
|
using PixiEditor.Models.Tools;
|
|
using PixiEditor.Numerics;
|
|
using PixiEditor.Numerics;
|
|
@@ -13,6 +15,9 @@ internal class VectorEllipseToolExecutor : ShapeToolExecutor<IVectorEllipseToolH
|
|
public override ExecutorType Type => ExecutorType.ToolLinked;
|
|
public override ExecutorType Type => ExecutorType.ToolLinked;
|
|
protected override DocumentTransformMode TransformMode => DocumentTransformMode.Scale_Rotate_Shear_NoPerspective;
|
|
protected override DocumentTransformMode TransformMode => DocumentTransformMode.Scale_Rotate_Shear_NoPerspective;
|
|
|
|
|
|
|
|
+ private VecD firstRadius;
|
|
|
|
+ private VecD firstCenter;
|
|
|
|
+
|
|
protected override void DrawShape(VecI curPos, double rotationRad, bool firstDraw)
|
|
protected override void DrawShape(VecI curPos, double rotationRad, bool firstDraw)
|
|
{
|
|
{
|
|
RectI rect;
|
|
RectI rect;
|
|
@@ -22,48 +27,46 @@ internal class VectorEllipseToolExecutor : ShapeToolExecutor<IVectorEllipseToolH
|
|
rect = GetSquaredCoordinates(startPos, curPos);
|
|
rect = GetSquaredCoordinates(startPos, curPos);
|
|
else
|
|
else
|
|
rect = RectI.FromTwoPixels(startPos, curPos);
|
|
rect = RectI.FromTwoPixels(startPos, curPos);
|
|
-
|
|
|
|
- EllipseVectorData data = new EllipseVectorData(rect.Center, rect.Size / 2f)
|
|
|
|
|
|
+
|
|
|
|
+ firstCenter = rect.Center;
|
|
|
|
+ firstRadius = rect.Size / 2f;
|
|
|
|
+
|
|
|
|
+ EllipseVectorData data = new EllipseVectorData(firstCenter, firstRadius)
|
|
{
|
|
{
|
|
- RotationRadians = rotationRad,
|
|
|
|
- StrokeColor = StrokeColor,
|
|
|
|
- FillColor = FillColor,
|
|
|
|
- StrokeWidth = StrokeWidth
|
|
|
|
|
|
+ StrokeColor = StrokeColor, FillColor = FillColor, StrokeWidth = StrokeWidth,
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
lastRect = rect;
|
|
lastRect = rect;
|
|
- lastRadians = rotationRad;
|
|
|
|
-
|
|
|
|
|
|
+
|
|
internals!.ActionAccumulator.AddActions(new SetShapeGeometry_Action(memberGuid, data));
|
|
internals!.ActionAccumulator.AddActions(new SetShapeGeometry_Action(memberGuid, data));
|
|
}
|
|
}
|
|
|
|
|
|
protected override IAction SettingsChangedAction()
|
|
protected override IAction SettingsChangedAction()
|
|
{
|
|
{
|
|
- return new SetShapeGeometry_Action(memberGuid, new EllipseVectorData(lastRect.Center, lastRect.Size / 2f)
|
|
|
|
- {
|
|
|
|
- RotationRadians = lastRadians,
|
|
|
|
- StrokeColor = StrokeColor,
|
|
|
|
- FillColor = FillColor,
|
|
|
|
- StrokeWidth = StrokeWidth
|
|
|
|
- });
|
|
|
|
|
|
+ return new SetShapeGeometry_Action(memberGuid,
|
|
|
|
+ new EllipseVectorData(firstCenter, firstRadius)
|
|
|
|
+ {
|
|
|
|
+ StrokeColor = StrokeColor, FillColor = FillColor, StrokeWidth = StrokeWidth
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
protected override IAction TransformMovedAction(ShapeData data, ShapeCorners corners)
|
|
protected override IAction TransformMovedAction(ShapeData data, ShapeCorners corners)
|
|
{
|
|
{
|
|
RectI rect = (RectI)RectD.FromCenterAndSize(data.Center, data.Size);
|
|
RectI rect = (RectI)RectD.FromCenterAndSize(data.Center, data.Size);
|
|
- double radians = corners.RectRotation;
|
|
|
|
-
|
|
|
|
- EllipseVectorData ellipseData = new EllipseVectorData(rect.Center, rect.Size / 2f)
|
|
|
|
|
|
+ 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));
|
|
|
|
+
|
|
|
|
+ EllipseVectorData ellipseData = new EllipseVectorData(firstCenter, firstRadius)
|
|
{
|
|
{
|
|
- RotationRadians = radians,
|
|
|
|
- StrokeColor = StrokeColor,
|
|
|
|
- FillColor = FillColor,
|
|
|
|
- StrokeWidth = StrokeWidth
|
|
|
|
|
|
+ StrokeColor = StrokeColor,
|
|
|
|
+ FillColor = FillColor,
|
|
|
|
+ StrokeWidth = StrokeWidth,
|
|
|
|
+ TransformationMatrix = matrix
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
lastRect = rect;
|
|
lastRect = rect;
|
|
- lastRadians = radians;
|
|
|
|
-
|
|
|
|
|
|
+
|
|
return new SetShapeGeometry_Action(memberGuid, ellipseData);
|
|
return new SetShapeGeometry_Action(memberGuid, ellipseData);
|
|
}
|
|
}
|
|
|
|
|