mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Layers - Finished effects on layers, groups still missing
Effects - Added filter effect with different SkiaSharp image filters
This commit is contained in:
1 parent
58a964b872
commit
a62d5544cf
18 files changed
+264
-55
No files matched your search
+1
@@ -33,6 +33,7 @@
|
||||
<ProjectReference Include="..\..\Artemis.Core\Artemis.Core.csproj">
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Artemis.UI.Shared\Artemis.UI.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<Exec Command="echo Copying resources to plugin output directory
XCOPY "$(ProjectDir)Images" "$(TargetDir)Images" /s /q /i /y
XCOPY "$(ProjectDir)Layouts" "$(TargetDir)Layouts" /s /q /i /y
echo Copying plugin to Artemis.UI output directory
XCOPY "$(TargetDir.TrimEnd('\'))" "$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)" /s /q /i /y" />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Artemis.Core.Plugins.LayerEffect.Abstract;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerEffects.Filter
|
||||
@@ -8,13 +9,17 @@ namespace Artemis.Plugins.LayerEffects.Filter
|
||||
{
|
||||
public override void EnableLayerEffect()
|
||||
{
|
||||
Properties.BlurAmount.BaseValueChanged += BlurAmountOnBaseValueChanged;
|
||||
Properties.FilterType.BaseValueChanged += (sender, args) => UpdateFilterType();
|
||||
|
||||
UpdateFilterType();
|
||||
}
|
||||
|
||||
private void BlurAmountOnBaseValueChanged(object? sender, EventArgs e)
|
||||
private void UpdateFilterType()
|
||||
{
|
||||
if (!HasBeenRenamed)
|
||||
Name = "Blur";
|
||||
if (HasBeenRenamed)
|
||||
return;
|
||||
|
||||
Name = EnumUtilities.HumanizeValue(Properties.FilterType);
|
||||
}
|
||||
|
||||
public override void DisableLayerEffect()
|
||||
@@ -27,8 +32,49 @@ namespace Artemis.Plugins.LayerEffects.Filter
|
||||
|
||||
public override void PreProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
{
|
||||
|
||||
paint.ImageFilter = SKImageFilter.CreateBlur(Properties.BlurAmount.CurrentValue.Width, Properties.BlurAmount.CurrentValue.Height, paint.ImageFilter);
|
||||
if (Properties.FilterType == FilterType.Blur)
|
||||
{
|
||||
paint.ImageFilter = SKImageFilter.CreateBlur(
|
||||
Properties.BlurAmount.CurrentValue.Width,
|
||||
Properties.BlurAmount.CurrentValue.Height,
|
||||
paint.ImageFilter
|
||||
);
|
||||
}
|
||||
else if (Properties.FilterType == FilterType.Dilate)
|
||||
{
|
||||
paint.ImageFilter = SKImageFilter.CreateDilate(
|
||||
(int) Properties.DilateRadius.CurrentValue.Width,
|
||||
(int) Properties.DilateRadius.CurrentValue.Height,
|
||||
paint.ImageFilter
|
||||
);
|
||||
}
|
||||
else if (Properties.FilterType == FilterType.Erode)
|
||||
{
|
||||
paint.ImageFilter = SKImageFilter.CreateErode(
|
||||
(int) Properties.ErodeRadius.CurrentValue.Width,
|
||||
(int) Properties.ErodeRadius.CurrentValue.Height,
|
||||
paint.ImageFilter
|
||||
);
|
||||
}
|
||||
else if (Properties.FilterType == FilterType.Erode)
|
||||
{
|
||||
paint.ImageFilter = SKImageFilter.CreateErode(
|
||||
(int) Properties.ErodeRadius.CurrentValue.Width,
|
||||
(int) Properties.ErodeRadius.CurrentValue.Height,
|
||||
paint.ImageFilter
|
||||
);
|
||||
}
|
||||
else if (Properties.FilterType == FilterType.DropShadow)
|
||||
{
|
||||
paint.ImageFilter = SKImageFilter.CreateDropShadow(
|
||||
Properties.ShadowOffset.CurrentValue.X,
|
||||
Properties.ShadowOffset.CurrentValue.Y,
|
||||
Properties.ShadowBlurAmount.CurrentValue.Width,
|
||||
Properties.ShadowBlurAmount.CurrentValue.Height, Properties.ShadowColor,
|
||||
SKDropShadowImageFilterShadowMode.DrawShadowAndForeground,
|
||||
paint.ImageFilter
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
|
||||
@@ -1,20 +1,62 @@
|
||||
using Artemis.Core.Models.Profile;
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Types;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerEffects.Filter
|
||||
{
|
||||
public class FilterEffectProperties : LayerPropertyGroup
|
||||
{
|
||||
[PropertyDescription]
|
||||
public EnumLayerProperty<FilterType> FilterType { get; set; }
|
||||
|
||||
[PropertyDescription(Description = "The amount of blur to apply")]
|
||||
public SKSizeLayerProperty BlurAmount { get; set; }
|
||||
|
||||
[PropertyDescription(Description = "The amount of dilation to apply")]
|
||||
public SKSizeLayerProperty DilateRadius { get; set; }
|
||||
|
||||
[PropertyDescription(Description = "The amount of erode to apply")]
|
||||
public SKSizeLayerProperty ErodeRadius { get; set; }
|
||||
|
||||
[PropertyDescription(Description = "The offset of the shadow")]
|
||||
public SKPointLayerProperty ShadowOffset { get; set; }
|
||||
|
||||
[PropertyDescription(Description = "The amount of blur to apply to the shadow")]
|
||||
public SKSizeLayerProperty ShadowBlurAmount { get; set; }
|
||||
|
||||
[PropertyDescription(Description = "The color of the shadow")]
|
||||
public SKColorLayerProperty ShadowColor { get; set; }
|
||||
|
||||
protected override void PopulateDefaults()
|
||||
{
|
||||
ShadowBlurAmount.DefaultValue = new SKSize(5, 5);
|
||||
ShadowColor.DefaultValue = new SKColor(50, 50, 50);
|
||||
}
|
||||
|
||||
protected override void OnPropertiesInitialized()
|
||||
{
|
||||
FilterType.BaseValueChanged += (sender, args) => UpdateVisibility();
|
||||
UpdateVisibility();
|
||||
}
|
||||
|
||||
private void UpdateVisibility()
|
||||
{
|
||||
BlurAmount.IsHidden = FilterType != Filter.FilterType.Blur;
|
||||
DilateRadius.IsHidden = FilterType != Filter.FilterType.Dilate;
|
||||
ErodeRadius.IsHidden = FilterType != Filter.FilterType.Erode;
|
||||
ShadowOffset.IsHidden = FilterType != Filter.FilterType.DropShadow;
|
||||
ShadowBlurAmount.IsHidden = FilterType != Filter.FilterType.DropShadow;
|
||||
ShadowColor.IsHidden = FilterType != Filter.FilterType.DropShadow;
|
||||
}
|
||||
}
|
||||
|
||||
public enum FilterType
|
||||
{
|
||||
Blur,
|
||||
Dilate,
|
||||
Erode,
|
||||
DropShadow,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user