Browse Source

Fix and rename EmptyImage node

CPKreuz 1 year ago
parent
commit
37ad87d07e

+ 18 - 6
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/EmptyImageNode.cs

@@ -1,29 +1,41 @@
 using PixiEditor.ChangeableDocument.Changeables.Animations;
 using PixiEditor.ChangeableDocument.Changeables.Animations;
+using PixiEditor.DrawingApi.Core.ColorsImpl;
 using PixiEditor.DrawingApi.Core.Surface.ImageData;
 using PixiEditor.DrawingApi.Core.Surface.ImageData;
+using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
 using PixiEditor.Numerics;
 using PixiEditor.Numerics;
 
 
 namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
 namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
 
 
-public class EmptyImageNode : Node
+public class CreateImageNode : Node
 {
 {
-    public OutputProperty<ChunkyImage> Output { get; }
+    private Paint _paint = new();
+    
+    public OutputProperty<Image> Output { get; }
 
 
     public InputProperty<VecI> Size { get; }
     public InputProperty<VecI> Size { get; }
+    
+    public InputProperty<Color> Fill { get; }
 
 
-    public EmptyImageNode()
+    public CreateImageNode()
     {
     {
-        Output = CreateOutput<ChunkyImage>(nameof(Output), "EMPTY_IMAGE", null);
+        Output = CreateOutput<Image>(nameof(Output), "EMPTY_IMAGE", null);
         Size = CreateInput(nameof(Size), "SIZE", new VecI(32, 32));
         Size = CreateInput(nameof(Size), "SIZE", new VecI(32, 32));
+        Fill = CreateInput(nameof(Fill), "FILL", new Color(0, 0, 0, 255));
     }
     }
     
     
     protected override Image? OnExecute(KeyFrameTime frameTime)
     protected override Image? OnExecute(KeyFrameTime frameTime)
     {
     {
         using var surface = new Surface(Size.Value);
         using var surface = new Surface(Size.Value);
 
 
-        return surface.DrawingSurface.Snapshot();
+        _paint.Color = Fill.Value;
+        surface.DrawingSurface.Canvas.DrawPaint(_paint);
+
+        Output.Value = surface.DrawingSurface.Snapshot();
+
+        return Output.Value;
     }
     }
 
 
     public override bool Validate() => Size.Value is { X: > 0, Y: > 0 };
     public override bool Validate() => Size.Value is { X: > 0, Y: > 0 };
 
 
-    public override Node CreateCopy() => new EmptyImageNode();
+    public override Node CreateCopy() => new CreateImageNode();
 }
 }