Browse Source

Added CombineVecD, CombineVecI and SeparateVecI nodes

CPKreuz 1 year ago
parent
commit
0400ed4ccd

+ 40 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/CombineSeparate/CombineVecD.cs

@@ -0,0 +1,40 @@
+using PixiEditor.ChangeableDocument.Changeables.Graph.Context;
+using PixiEditor.ChangeableDocument.Rendering;
+using PixiEditor.DrawingApi.Core.ColorsImpl;
+using PixiEditor.Numerics;
+
+namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.CombineSeparate;
+
+public class CombineVecD : Node
+{
+    public FieldOutputProperty<VecD> Vector { get; }
+    
+    public FieldInputProperty<double> X { get; }
+    
+    public FieldInputProperty<double> Y { get; }
+
+    public CombineVecD()
+    {
+        Vector = CreateFieldOutput(nameof(Vector), "VECTOR", GetVector);
+
+        X = CreateFieldInput(nameof(X), "X", 0d);
+        Y = CreateFieldInput(nameof(Y), "Y", 0d);
+    }
+    
+    private VecD GetVector(FieldContext ctx)
+    {
+        var r = X.Value(ctx);
+        var g = Y.Value(ctx);
+
+        return new VecD(r, g);
+    }
+
+    protected override Surface? OnExecute(RenderingContext context)
+    {
+        return null;
+    }
+
+    public override bool Validate() => true;
+
+    public override Node CreateCopy() => new CombineVecD();
+}

+ 39 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/CombineSeparate/CombineVecI.cs

@@ -0,0 +1,39 @@
+using PixiEditor.ChangeableDocument.Changeables.Graph.Context;
+using PixiEditor.ChangeableDocument.Rendering;
+using PixiEditor.Numerics;
+
+namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.CombineSeparate;
+
+public class CombineVecI : Node
+{
+    public FieldOutputProperty<VecI> Vector { get; }
+    
+    public FieldInputProperty<int> X { get; }
+    
+    public FieldInputProperty<int> Y { get; }
+
+    public CombineVecI()
+    {
+        Vector = CreateFieldOutput(nameof(Vector), "VECTOR", GetVector);
+
+        X = CreateFieldInput(nameof(X), "X", 0);
+        Y = CreateFieldInput(nameof(Y), "Y", 0);
+    }
+
+    private VecI GetVector(FieldContext ctx)
+    {
+        var r = X.Value(ctx);
+        var g = Y.Value(ctx);
+
+        return new VecI(r, g);
+    }
+
+    protected override Surface? OnExecute(RenderingContext context)
+    {
+        return null;
+    }
+
+    public override bool Validate() => true;
+
+    public override Node CreateCopy() => new CombineVecI();
+}

+ 29 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/CombineSeparate/SeparateVecINode.cs

@@ -0,0 +1,29 @@
+using PixiEditor.ChangeableDocument.Rendering;
+using PixiEditor.Numerics;
+
+namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes.CombineSeparate;
+
+public class SeparateVecINode : Node
+{
+    public FieldInputProperty<VecI> Vector { get; }
+    
+    public FieldOutputProperty<int> X { get; }
+    
+    public FieldOutputProperty<int> Y { get; }
+
+    public SeparateVecINode()
+    {
+        X = CreateFieldOutput("X", "X", ctx => Vector.Value(ctx).X);
+        Y = CreateFieldOutput("Y", "Y", ctx => Vector.Value(ctx).Y);
+        Vector = CreateFieldInput("Vector", "VECTOR", new VecI(0, 0));
+    }
+
+    protected override Surface? OnExecute(RenderingContext context)
+    {
+        return null;
+    }
+
+    public override bool Validate() => true;
+
+    public override Node CreateCopy() => new SeparateVecINode();
+}