mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Nodes - Added numeric subtract node
This commit is contained in:
1 parent
ff633f7e8e
commit
0a3e822d03
3 files changed
+61
No files matched your search
@@ -432,5 +432,30 @@ public static class NumericExtensions
|
||||
return new Numeric(sum);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts the numerics in the provided collection
|
||||
/// </summary>
|
||||
/// <returns>The remainder of all numerics subtracted from one another in the collection</returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static Numeric Subtract(this IEnumerable<Numeric> source)
|
||||
{
|
||||
if (source == null) throw new ArgumentNullException(nameof(source));
|
||||
|
||||
float subtraction = 0f;
|
||||
bool first = true;
|
||||
foreach (float v in source)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
subtraction = v;
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
subtraction -= v;
|
||||
}
|
||||
|
||||
return new Numeric(subtraction);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -26,6 +26,8 @@ public sealed class InputPin<T> : Pin
|
||||
{
|
||||
if (ConnectedTo.Count > 0 && ConnectedTo[0].PinValue is T value)
|
||||
Value = value;
|
||||
else
|
||||
Value = default;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user