1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Merge pull request #475 from diogotr7/feature/modifier-hue

Added a data binding modifier that rotates the hue of a color
This commit is contained in:
Robert Beekman 2020-10-05 23:14:05 +02:00 committed by GitHub
commit 9e39a849e9
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using SkiaSharp;
namespace Artemis.Core.DefaultTypes
{
internal class SKColorRotateHueModifierType : DataBindingModifierType
{
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> {typeof(SKColor)};
public override Type ParameterType => typeof(float);
public override string Name => "Rotate Hue by";
public override string Icon => "RotateRight";
public override string Description => "Rotates the hue of the color by the amount in degrees";
public override object Apply(object currentValue, object parameterValue)
{
((SKColor) currentValue).ToHsl(out float h, out float s, out float l);
h += (float)parameterValue;
return SKColor.FromHsl(h % 360, s, l);
}
}
}

View File

@ -74,6 +74,7 @@ namespace Artemis.Core.Services
RegisterModifierType(Constants.CorePluginInfo, new SKColorSumModifierType());
RegisterModifierType(Constants.CorePluginInfo, new SKColorBrightenModifierType());
RegisterModifierType(Constants.CorePluginInfo, new SKColorDarkenModifierType());
RegisterModifierType(Constants.CorePluginInfo, new SKColorRotateHueModifierType());
}
}
}