|
@@ -18,6 +18,8 @@ public class CreateImageNode : Node
|
|
|
public InputProperty<Color> Fill { get; }
|
|
|
|
|
|
public RenderInputProperty Content { get; }
|
|
|
+
|
|
|
+ public RenderOutputProperty RenderOutput { get; }
|
|
|
|
|
|
public CreateImageNode()
|
|
|
{
|
|
@@ -25,6 +27,7 @@ public class CreateImageNode : Node
|
|
|
Size = CreateInput(nameof(Size), "SIZE", new VecI(32, 32)).WithRules(v => v.Min(VecI.One));
|
|
|
Fill = CreateInput(nameof(Fill), "FILL", Colors.Transparent);
|
|
|
Content = CreateRenderInput(nameof(Content), "CONTENT");
|
|
|
+ RenderOutput = CreateRenderOutput("RenderOutput", "RENDER_OUTPUT", () => new Painter(OnPaint));
|
|
|
}
|
|
|
|
|
|
protected override void OnExecute(RenderContext context)
|
|
@@ -37,10 +40,20 @@ public class CreateImageNode : Node
|
|
|
var surface = RequestTexture(0, Size.Value, false);
|
|
|
|
|
|
surface.DrawingSurface.Canvas.Clear(Fill.Value);
|
|
|
+
|
|
|
+ int saved = surface.DrawingSurface.Canvas.Save();
|
|
|
|
|
|
Content.Value?.Paint(context, surface.DrawingSurface);
|
|
|
|
|
|
+ surface.DrawingSurface.Canvas.RestoreToCount(saved);
|
|
|
Output.Value = surface;
|
|
|
+
|
|
|
+ RenderOutput.ChainToPainterValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnPaint(RenderContext context, DrawingSurface surface)
|
|
|
+ {
|
|
|
+ surface.Canvas.DrawSurface(Output.Value.DrawingSurface, 0, 0);
|
|
|
}
|
|
|
|
|
|
public override Node CreateCopy() => new CreateImageNode();
|