Browse Source

Fixed path rendering

flabbet 2 years ago
parent
commit
2f1af52249

+ 1 - 0
src/PixiEditor.DrawingApi.Core/Bridge/NativeObjectsImpl/IVectorPathImplementation.cs

@@ -33,4 +33,5 @@ public interface IVectorPathImplementation
     public void AddOval(VectorPath vectorPath, RectI borders);
     public void AddOval(VectorPath vectorPath, RectI borders);
     public VectorPath Op(VectorPath vectorPath, VectorPath ellipsePath, VectorPathOp pathOp);
     public VectorPath Op(VectorPath vectorPath, VectorPath ellipsePath, VectorPathOp pathOp);
     public void Close(VectorPath vectorPath);
     public void Close(VectorPath vectorPath);
+    public string ToSvgPathData(VectorPath vectorPath);
 }
 }

+ 6 - 0
src/PixiEditor.DrawingApi.Core/Surface/Vector/VectorPath.cs

@@ -1,4 +1,5 @@
 using System;
 using System;
+using System.ComponentModel;
 using PixiEditor.DrawingApi.Core.Bridge;
 using PixiEditor.DrawingApi.Core.Bridge;
 using PixiEditor.DrawingApi.Core.Numerics;
 using PixiEditor.DrawingApi.Core.Numerics;
 
 
@@ -116,4 +117,9 @@ public class VectorPath : NativeObject
     {
     {
         DrawingBackendApi.Current.PathImplementation.Close(this);
         DrawingBackendApi.Current.PathImplementation.Close(this);
     }
     }
+
+    public string ToSvgPathData()
+    {
+        return DrawingBackendApi.Current.PathImplementation.ToSvgPathData(this);
+    }
 }
 }

+ 5 - 0
src/PixiEditor.DrawingApi.Skia/Implementations/SkiaPathImplementation.cs

@@ -148,5 +148,10 @@ namespace PixiEditor.DrawingApi.Skia.Implementations
         {
         {
             ManagedInstances[vectorPath.ObjectPointer].Close();
             ManagedInstances[vectorPath.ObjectPointer].Close();
         }
         }
+
+        public string ToSvgPathData(VectorPath vectorPath)
+        {
+            return ManagedInstances[vectorPath.ObjectPointer].ToSvgPathData();
+        }
     }
     }
 }
 }

+ 4 - 3
src/PixiEditor/Views/UserControls/SelectionOverlay.cs

@@ -2,13 +2,14 @@
 using System.Windows.Controls;
 using System.Windows.Controls;
 using System.Windows.Media;
 using System.Windows.Media;
 using System.Windows.Media.Animation;
 using System.Windows.Media.Animation;
+using PixiEditor.DrawingApi.Core.Surface.Vector;
 
 
 namespace PixiEditor.Views.UserControls;
 namespace PixiEditor.Views.UserControls;
 #nullable enable
 #nullable enable
 internal class SelectionOverlay : Control
 internal class SelectionOverlay : Control
 {
 {
     public static readonly DependencyProperty PathProperty =
     public static readonly DependencyProperty PathProperty =
-        DependencyProperty.Register(nameof(Path), typeof(SKPath), typeof(SelectionOverlay),
+        DependencyProperty.Register(nameof(Path), typeof(VectorPath), typeof(SelectionOverlay),
             new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
             new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
 
 
     public static readonly DependencyProperty ZoomboxScaleProperty =
     public static readonly DependencyProperty ZoomboxScaleProperty =
@@ -29,9 +30,9 @@ internal class SelectionOverlay : Control
         set => SetValue(ZoomboxScaleProperty, value);
         set => SetValue(ZoomboxScaleProperty, value);
     }
     }
 
 
-    public SKPath? Path
+    public VectorPath? Path
     {
     {
-        get => (SKPath?)GetValue(PathProperty);
+        get => (VectorPath?)GetValue(PathProperty);
         set => SetValue(PathProperty, value);
         set => SetValue(PathProperty, value);
     }
     }