mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Color gradients - Tweaked default rainbow
Events - Hide some properties that shouldn't be visible Events - Added time since last trigger property
This commit is contained in:
1 parent
f4b42e2cf2
commit
a74c81ba9d
9 files changed
+101
-19
No files matched your search
@@ -10,6 +10,19 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public class ColorGradient : CorePropertyChanged
|
||||
{
|
||||
private static readonly SKColor[] FastLedRainbow =
|
||||
{
|
||||
new(0xFFFF0000), // Red
|
||||
new(0xFFFF9900), // Orange
|
||||
new(0xFFFFFF00), // Yellow
|
||||
new(0xFF00FF00), // Green
|
||||
new(0xFF00FF7E), // Aqua
|
||||
new(0xFF0078FF), // Blue
|
||||
new(0xFF9E22FF), // Purple
|
||||
new(0xFFFF34AE), // Pink
|
||||
new(0xFFFF0000) // and back to Red
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ColorGradient" /> class
|
||||
/// </summary>
|
||||
@@ -31,9 +44,9 @@ namespace Artemis.Core
|
||||
public SKColor[] GetColorsArray(int timesToRepeat = 0)
|
||||
{
|
||||
if (timesToRepeat == 0)
|
||||
return Stops.OrderBy(c => c.Position).Select(c => c.Color).ToArray();
|
||||
return Stops.Select(c => c.Color).ToArray();
|
||||
|
||||
List<SKColor> colors = Stops.OrderBy(c => c.Position).Select(c => c.Color).ToList();
|
||||
List<SKColor> colors = Stops.Select(c => c.Color).ToList();
|
||||
List<SKColor> result = new();
|
||||
|
||||
for (int i = 0; i <= timesToRepeat; i++)
|
||||
@@ -53,10 +66,10 @@ namespace Artemis.Core
|
||||
public float[] GetPositionsArray(int timesToRepeat = 0)
|
||||
{
|
||||
if (timesToRepeat == 0)
|
||||
return Stops.OrderBy(c => c.Position).Select(c => c.Position).ToArray();
|
||||
return Stops.Select(c => c.Position).ToArray();
|
||||
|
||||
// Create stops and a list of divided stops
|
||||
List<float> stops = Stops.OrderBy(c => c.Position).Select(c => c.Position / (timesToRepeat + 1)).ToList();
|
||||
List<float> stops = Stops.Select(c => c.Position / (timesToRepeat + 1)).ToList();
|
||||
List<float> result = new();
|
||||
|
||||
// For each repeat cycle, add the base stops to the end result
|
||||
@@ -74,6 +87,7 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public void OnColorValuesUpdated()
|
||||
{
|
||||
Stops.Sort((a, b) => a.Position.CompareTo(b.Position));
|
||||
OnPropertyChanged(nameof(Stops));
|
||||
}
|
||||
|
||||
@@ -86,7 +100,7 @@ namespace Artemis.Core
|
||||
if (!Stops.Any())
|
||||
return SKColor.Empty;
|
||||
|
||||
ColorGradientStop[] stops = Stops.OrderBy(x => x.Position).ToArray();
|
||||
ColorGradientStop[] stops = Stops.ToArray();
|
||||
if (position <= 0) return stops[0].Color;
|
||||
if (position >= 1) return stops[^1].Color;
|
||||
ColorGradientStop left = stops[0];
|
||||
@@ -119,15 +133,14 @@ namespace Artemis.Core
|
||||
/// <returns></returns>
|
||||
public static ColorGradient GetUnicornBarf()
|
||||
{
|
||||
const int amount = 8;
|
||||
ColorGradient gradient = new();
|
||||
|
||||
for (int i = 0; i <= amount; i++)
|
||||
for (int index = 0; index < FastLedRainbow.Length; index++)
|
||||
{
|
||||
float percent = i / (float)amount;
|
||||
gradient.Stops.Add(new ColorGradientStop(SKColor.FromHsv(360f * percent, 100, 100), percent));
|
||||
SKColor skColor = FastLedRainbow[index];
|
||||
float position = 1f / (FastLedRainbow.Length - 1f) * index;
|
||||
gradient.Stops.Add(new ColorGradientStop(skColor, position));
|
||||
}
|
||||
|
||||
|
||||
return gradient;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,13 @@ namespace Artemis.Core
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataModelProperty(Name = "Last event trigger", Description = "The time at which the event last triggered")]
|
||||
[DataModelProperty(Name = "Last trigger", Description = "The time at which the event last triggered")]
|
||||
public DateTime LastTrigger { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")]
|
||||
public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the event arguments of the last time the event was triggered
|
||||
/// </summary>
|
||||
@@ -85,6 +89,7 @@ namespace Artemis.Core
|
||||
public Type ArgumentsType => typeof(T);
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataModelIgnore]
|
||||
public string TriggerPastParticiple => "triggered";
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -147,14 +152,18 @@ namespace Artemis.Core
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataModelProperty(Name = "Last event trigger", Description = "The time at which the event last triggered")]
|
||||
[DataModelProperty(Name = "Last trigger", Description = "The time at which the event last triggered")]
|
||||
public DateTime LastTrigger { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")]
|
||||
public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the event arguments of the last time the event was triggered
|
||||
/// </summary>
|
||||
[DataModelProperty(Description = "The arguments of the last time this event triggered")]
|
||||
public DataModelEventArgs? LastEventArguments { get; private set; }
|
||||
public DataModelEventArgs? LastTriggerArguments { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataModelProperty(Description = "The total amount of times this event has triggered since the module was activated")]
|
||||
@@ -174,7 +183,7 @@ namespace Artemis.Core
|
||||
{
|
||||
DataModelEventArgs eventArgs = new() {TriggerTime = DateTime.Now};
|
||||
|
||||
LastEventArguments = eventArgs;
|
||||
LastTriggerArguments = eventArgs;
|
||||
LastTrigger = DateTime.Now;
|
||||
TriggerCount++;
|
||||
|
||||
@@ -201,6 +210,7 @@ namespace Artemis.Core
|
||||
public Type ArgumentsType => typeof(DataModelEventArgs);
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataModelIgnore]
|
||||
public string TriggerPastParticiple => "triggered";
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -217,7 +227,7 @@ namespace Artemis.Core
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataModelIgnore]
|
||||
public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments;
|
||||
public DataModelEventArgs? LastEventArgumentsUntyped => LastTriggerArguments;
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataModelIgnore]
|
||||
|
||||
@@ -13,6 +13,11 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
DateTime LastTrigger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the time that has passed since the last trigger
|
||||
/// </summary>
|
||||
TimeSpan TimeSinceLastTrigger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of times the event was triggered
|
||||
/// </summary>
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ namespace Artemis.Core
|
||||
public T? LastValue { get; private set; }
|
||||
public T? CurrentValue { get; private set; }
|
||||
public DateTime LastTrigger { get; private set; }
|
||||
public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
|
||||
public int TriggerCount { get; private set; }
|
||||
public Type ArgumentsType { get; } = typeof(DataModelValueChangedEventArgs<T>);
|
||||
public string TriggerPastParticiple => "changed";
|
||||
|
||||
Reference in new issue
Block a user