using NodePipeline.Abstractions.Attributes;
using NodePipeline.Abstractions.Attributes.Validation.NodeField;
using NodePipeline.Abstractions.Interfaces.Nodes;
using NodePipeline.Abstractions.Models;
using NodePipeline.Application.ImageProcessing;

namespace NodePipeline.Application.Nodes;

public class GaussianBlurNode : INode
{
    [NodeField(FieldDirection.Input)] public NodeField<ImageBuffer> Input { get; set; } = null!;

    [NodeField(FieldDirection.Parameter)]
    [HasValueBetween(0, 300)]
    public NodeField<int> Radius { get; set; } = null!;

    [NodeField(FieldDirection.Output)] public NodeField<ImageBuffer> Output { get; set; } = null!;

    public void Execute()
    {
        var src = Input.Value;
        var dst = new ImageBuffer(src.Width, src.Height);
        var kernel = GaussianKernel.Create(Radius.Value);
        Convolution.Apply(src, dst, kernel);
        Output.Value = dst;
    }
}