flabbet 8 months ago
parent
commit
5411fbd0ed
2 changed files with 35 additions and 8 deletions
  1. 1 1
      src/Drawie
  2. 34 7
      src/PixiEditor/Views/Overlays/PathOverlay/VectorPathOverlay.cs

+ 1 - 1
src/Drawie

@@ -1 +1 @@
-Subproject commit fb6db35ce1214ea16d0dcc0391e6a422ccb4bf0a
+Subproject commit 96dfe25513f74a09b88341dd1d06991520466d47

+ 34 - 7
src/PixiEditor/Views/Overlays/PathOverlay/VectorPathOverlay.cs

@@ -478,14 +478,14 @@ public class VectorPathOverlay : Overlay
 
 
             if (!args.Modifiers.HasFlag(KeyModifiers.Control)) return;
             if (!args.Modifiers.HasFlag(KeyModifiers.Control)) return;
 
 
-            var newPath = ConvertTouchingLineVerbsToCubic(anchorHandle);
+            var newPath = ConvertTouchingVerbsToCubic(anchorHandle);
 
 
             Path = newPath;
             Path = newPath;
         }
         }
     }
     }
 
 
     // To have continous spline, verb before and after a point must be a cubic with proper control points
     // To have continous spline, verb before and after a point must be a cubic with proper control points
-    private VectorPath ConvertTouchingLineVerbsToCubic(AnchorHandle anchorHandle)
+    private VectorPath ConvertTouchingVerbsToCubic(AnchorHandle anchorHandle)
     {
     {
         VectorPath newPath = new VectorPath();
         VectorPath newPath = new VectorPath();
         int index = anchorHandles.IndexOf(anchorHandle);
         int index = anchorHandles.IndexOf(anchorHandle);
@@ -523,6 +523,10 @@ public class VectorPathOverlay : Overlay
                     {
                     {
                         newPath.CubicTo(data.points[0], data.points[1], data.points[1]);
                         newPath.CubicTo(data.points[0], data.points[1], data.points[1]);
                     }
                     }
+                    else if (data.verb is PathVerb.Conic or PathVerb.Quad)
+                    {
+                        newPath.CubicTo(data.points[0], data.points[1], data.points[2]);
+                    }
                     else
                     else
                     {
                     {
                         DefaultPathVerb(data, newPath);
                         DefaultPathVerb(data, newPath);
@@ -553,7 +557,7 @@ public class VectorPathOverlay : Overlay
             if (data.verb == PathVerb.Close)
             if (data.verb == PathVerb.Close)
             {
             {
                 subPath++;
                 subPath++;
-                anchor--;
+                //anchor--;
             }
             }
             else
             else
             {
             {
@@ -654,7 +658,30 @@ public class VectorPathOverlay : Overlay
 
 
                         previousDelta = mid2Delta;
                         previousDelta = mid2Delta;
                     }
                     }
+                    break;
+                case PathVerb.Quad:
+                    if (ctrlPressed)
+                    {
+                        DefaultPathVerb(data, newPath);
+                        break;
+                    }
+
+                    point = data.points[2];
+                    point = TryApplyNewPos(args, i, index, point, isSubPathClosed, firstSubPathPoint, lastAnchorAt);
+
+                    newPath.QuadTo(data.points[1], point);
+                    break;
+                case PathVerb.Conic:
+                    if (ctrlPressed)
+                    {
+                        DefaultPathVerb(data, newPath);
+                        break;
+                    }
+
+                    point = data.points[2];
+                    point = TryApplyNewPos(args, i, index, point, isSubPathClosed, firstSubPathPoint, lastAnchorAt);
 
 
+                    newPath.ConicTo(data.points[1], point, data.conicWeight);
                     break;
                     break;
                 default:
                 default:
                     DefaultPathVerb(data, newPath);
                     DefaultPathVerb(data, newPath);
@@ -754,7 +781,7 @@ public class VectorPathOverlay : Overlay
 
 
     private void HandleCubicControlContinousDrag(int i, int targetIndex, int symmetricIndex,
     private void HandleCubicControlContinousDrag(int i, int targetIndex, int symmetricIndex,
         VecD targetPos, VecD targetSymmetryPos,
         VecD targetPos, VecD targetSymmetryPos,
-        (PathVerb verb, VecF[] points) data,
+        (PathVerb verb, VecF[] points, float conicWeight) data,
         VectorPath newPath)
         VectorPath newPath)
     {
     {
         bool isFirstControlPoint = i == targetIndex;
         bool isFirstControlPoint = i == targetIndex;
@@ -812,7 +839,7 @@ public class VectorPathOverlay : Overlay
         return new VecD(2 * anchor.X - controlPoint.X, 2 * anchor.Y - controlPoint.Y);
         return new VecD(2 * anchor.X - controlPoint.X, 2 * anchor.Y - controlPoint.Y);
     }
     }
 
 
-    private VecF GetVerbPointPos((PathVerb verb, VecF[] points) data)
+    private VecF GetVerbPointPos((PathVerb verb, VecF[] points, float conicWeight) data)
     {
     {
         switch (data.verb)
         switch (data.verb)
         {
         {
@@ -956,7 +983,7 @@ public class VectorPathOverlay : Overlay
         AdjustHandles(newPath);
         AdjustHandles(newPath);
     }
     }
 
 
-    private static void DefaultPathVerb((PathVerb verb, VecF[] points) data, VectorPath newPath)
+    private static void DefaultPathVerb((PathVerb verb, VecF[] points, float conicWeight) data, VectorPath newPath)
     {
     {
         switch (data.verb)
         switch (data.verb)
         {
         {
@@ -970,7 +997,7 @@ public class VectorPathOverlay : Overlay
                 newPath.QuadTo(data.points[1], data.points[2]);
                 newPath.QuadTo(data.points[1], data.points[2]);
                 break;
                 break;
             case PathVerb.Conic:
             case PathVerb.Conic:
-                newPath.ConicTo(data.points[1], data.points[2], data.points[3].X);
+                newPath.ConicTo(data.points[1], data.points[2], data.conicWeight);
                 break;
                 break;
             case PathVerb.Cubic:
             case PathVerb.Cubic:
                 newPath.CubicTo(data.points[1], data.points[2], data.points[3]);
                 newPath.CubicTo(data.points[1], data.points[2], data.points[3]);