mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
41 lines
849 B
C#
41 lines
849 B
C#
using Artemis.Core;
|
|
|
|
namespace Artemis.VisualScripting.Nodes.Timing;
|
|
|
|
[Node("Edge", "Outputs true on each edge when the input changes", "Timing", InputType = typeof(bool), OutputType = typeof(bool))]
|
|
public class EdgeNode : Node
|
|
{
|
|
#region Properties & Fields
|
|
|
|
private bool _lastInput;
|
|
|
|
public InputPin<bool> Input { get; }
|
|
public OutputPin<bool> Output { get; }
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
public EdgeNode()
|
|
: base("Edge", "Outputs true on each edge when the input changes")
|
|
{
|
|
Input = CreateInputPin<bool>();
|
|
Output = CreateOutputPin<bool>();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <inheritdoc />
|
|
public override void Evaluate()
|
|
{
|
|
bool input = Input.Value;
|
|
|
|
Output.Value = input != _lastInput;
|
|
|
|
_lastInput = input;
|
|
}
|
|
|
|
#endregion
|
|
} |