mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Modifiers - Fixed the same issue but at the right place now
Modifiers - Saturate and desaturate modifiers WIP
This commit is contained in:
parent
f2e21bfe37
commit
26daa8e1dd
@ -0,0 +1,19 @@
|
|||||||
|
using SkiaSharp;
|
||||||
|
|
||||||
|
namespace Artemis.Core.DefaultTypes
|
||||||
|
{
|
||||||
|
internal class SKColorDesaturateModifierType : DataBindingModifierType<SKColor, float>
|
||||||
|
{
|
||||||
|
public override string Name => "Desaturate";
|
||||||
|
public override string Icon => "ImageMinus";
|
||||||
|
public override string Description => "Desaturates the color by the amount in percent";
|
||||||
|
|
||||||
|
public override SKColor Apply(SKColor currentValue, float parameterValue)
|
||||||
|
{
|
||||||
|
// TODO: Not so straightforward ^^
|
||||||
|
currentValue.ToHsl(out float h, out float s, out float l);
|
||||||
|
s *= (parameterValue * -1 + 100f) / 100f;
|
||||||
|
return SKColor.FromHsl(h, s, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
using SkiaSharp;
|
||||||
|
|
||||||
|
namespace Artemis.Core.DefaultTypes
|
||||||
|
{
|
||||||
|
internal class SKColorSaturateModifierType : DataBindingModifierType<SKColor, float>
|
||||||
|
{
|
||||||
|
public override string Name => "Saturate";
|
||||||
|
public override string Icon => "ImagePlus";
|
||||||
|
public override string Description => "Saturates the color by the amount in percent";
|
||||||
|
|
||||||
|
public override SKColor Apply(SKColor currentValue, float parameterValue)
|
||||||
|
{
|
||||||
|
// TODO: Not so straightforward ^^
|
||||||
|
currentValue.ToHsl(out float h, out float s, out float l);
|
||||||
|
return SKColor.FromHsl(h, parameterValue, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -109,14 +109,6 @@ namespace Artemis.Core
|
|||||||
$"it does not support this data binding's type {targetType.Name}");
|
$"it does not support this data binding's type {targetType.Name}");
|
||||||
|
|
||||||
ModifierType = modifierType;
|
ModifierType = modifierType;
|
||||||
|
|
||||||
// Ensure the right parameter static value is never null when the parameter type is a value type
|
|
||||||
if (ParameterType == ProfileRightSideType.Static && modifierType.ParameterType != null)
|
|
||||||
{
|
|
||||||
if (modifierType.ParameterType.IsValueType && ParameterStaticValue == null)
|
|
||||||
UpdateParameterStatic(modifierType.ParameterType.GetDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
ValidateParameter();
|
ValidateParameter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,15 +217,8 @@ namespace Artemis.Core
|
|||||||
staticValue = Activator.CreateInstance(parameterType);
|
staticValue = Activator.CreateInstance(parameterType);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
UpdateParameterStatic(staticValue);
|
UpdateParameterStatic(staticValue);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
DeserializationLogger.LogModifierDeserializationFailure(GetType().Name, new JsonSerializationException("The JSON deserialized into a mismatching type", e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@ -72,6 +72,8 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
RegisterModifierType(Constants.CorePluginInfo, new SKColorSumModifierType());
|
RegisterModifierType(Constants.CorePluginInfo, new SKColorSumModifierType());
|
||||||
|
RegisterModifierType(Constants.CorePluginInfo, new SKColorSaturateModifierType());
|
||||||
|
RegisterModifierType(Constants.CorePluginInfo, new SKColorDesaturateModifierType());
|
||||||
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());
|
RegisterModifierType(Constants.CorePluginInfo, new SKColorRotateHueModifierType());
|
||||||
|
|||||||
@ -140,7 +140,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
|||||||
if (DynamicSelectionViewModel != null)
|
if (DynamicSelectionViewModel != null)
|
||||||
DynamicSelectionViewModel.ChangeDataModelPath(Modifier.ParameterPath);
|
DynamicSelectionViewModel.ChangeDataModelPath(Modifier.ParameterPath);
|
||||||
else if (StaticInputViewModel != null)
|
else if (StaticInputViewModel != null)
|
||||||
|
{
|
||||||
|
// Ensure the right static value is never null when the preferred type is a value type
|
||||||
StaticInputViewModel.Value = Modifier.ParameterStaticValue;
|
StaticInputViewModel.Value = Modifier.ParameterStaticValue;
|
||||||
|
if (SelectedModifierType.ParameterType.IsValueType && StaticInputViewModel.Value == null)
|
||||||
|
StaticInputViewModel.Value = SelectedModifierType.ParameterType.GetDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteSelectModifierTypeCommand(object context)
|
private void ExecuteSelectModifierTypeCommand(object context)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user