Layers - Finished effects on layers, groups still missing

Effects - Added filter effect with different SkiaSharp image filters
This commit is contained in:
SpoinkyNL committed 2020-06-16 00:25:04 +02:00
1 parent 58a964b872
commit a62d5544cf
18 files changed
+264 -55

No files matched your search

@@ -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&#xD;&#xA;XCOPY &quot;$(ProjectDir)Images&quot; &quot;$(TargetDir)Images&quot; /s /q /i /y&#xD;&#xA;XCOPY &quot;$(ProjectDir)Layouts&quot; &quot;$(TargetDir)Layouts&quot; /s /q /i /y&#xD;&#xA;echo Copying plugin to Artemis.UI output directory&#xD;&#xA;XCOPY &quot;$(TargetDir.TrimEnd('\'))&quot; &quot;$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)&quot; /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,
}
}