Added a data binding modifier that rotates the hue of a color

This commit is contained in:
Diogo Trindade committed 2020-10-05 16:57:32 +01:00
1 parent 5b80c1e4fe
commit b0928faccc
2 files changed
+28

No files matched your search

@@ -0,0 +1,27 @@
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 var h, out var s, out var l);
h += (float)parameterValue;
var a = SKColor.FromHsl(h % 360, s, l);
return a;
}
}
}
@@ -74,6 +74,7 @@ namespace Artemis.Core.Services
RegisterModifierType(Constants.CorePluginInfo, new SKColorSumModifierType()); RegisterModifierType(Constants.CorePluginInfo, new SKColorSumModifierType());
RegisterModifierType(Constants.CorePluginInfo, new SKColorBrightenModifierType()); RegisterModifierType(Constants.CorePluginInfo, new SKColorBrightenModifierType());
RegisterModifierType(Constants.CorePluginInfo, new SKColorDarkenModifierType()); RegisterModifierType(Constants.CorePluginInfo, new SKColorDarkenModifierType());
RegisterModifierType(Constants.CorePluginInfo, new SKColorRotateHueModifierType());
} }
} }
} }