瀏覽代碼

BoolOpNode checks

Krzysztof Krysiński 3 月之前
父節點
當前提交
391088461e
共有 1 個文件被更改,包括 36 次插入1 次删除
  1. 36 1
      src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Shapes/BoolOperationNode.cs

+ 36 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Shapes/BoolOperationNode.cs

@@ -61,7 +61,42 @@ public class BoolOperationNode : Node
             join = pathB.StrokeLineJoin;
         }
 
-        Result.Value = new PathVectorData(shapeA.ToPath(true).Op(shapeB.ToPath(true), Operation.Value))
+        var firstPath = shapeA.ToPath(true);
+        var secondPath = shapeB.ToPath(true);
+
+        if (firstPath == null)
+        {
+            if (secondPath == null)
+            {
+                Result.Value = null;
+                return;
+            }
+
+            Result.Value = new PathVectorData(secondPath)
+            {
+                Fill = shapeB.Fill,
+                Stroke = shapeB.Stroke,
+                StrokeWidth = shapeB.StrokeWidth,
+                FillPaintable = shapeB.FillPaintable,
+                StrokeLineCap = cap,
+                StrokeLineJoin = join,
+            };
+        }
+        else if (secondPath == null)
+        {
+            Result.Value = new PathVectorData(firstPath)
+            {
+                Fill = shapeA.Fill,
+                Stroke = shapeA.Stroke,
+                StrokeWidth = shapeA.StrokeWidth,
+                FillPaintable = shapeA.FillPaintable,
+                StrokeLineCap = cap,
+                StrokeLineJoin = join,
+            };
+            return;
+        }
+
+        Result.Value = new PathVectorData(firstPath.Op(secondPath, Operation.Value))
         {
             Fill = shapeA.Fill,
             Stroke = shapeA.Stroke,