From 014552e591cce88cbb61ca006ea50c1562bf6399 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Thu, 13 Feb 2020 23:34:50 +0100 Subject: [PATCH] Noise brush - Fixed noise algorithm usage --- src/Artemis.Core/Artemis.Core.csproj | 6 +++--- src/Artemis.Core/packages.config | 2 +- .../Artemis.Plugins.LayerBrushes.Color.csproj | 6 +++--- .../packages.config | 2 +- .../Artemis.Plugins.LayerBrushes.Noise.csproj | 6 +++--- .../NoiseBrush.cs | 16 +++++++++------- .../packages.config | 2 +- .../Artemis.Plugins.Modules.General.csproj | 6 +++--- .../packages.config | 2 +- src/Artemis.UI.Shared/Artemis.UI.Shared.csproj | 6 +++--- src/Artemis.UI.Shared/packages.config | 2 +- src/Artemis.UI/Artemis.UI.csproj | 10 +++++----- src/Artemis.UI/packages.config | 6 +++--- 13 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj index 245972cc7..cdc21cdbd 100644 --- a/src/Artemis.Core/Artemis.Core.csproj +++ b/src/Artemis.Core/Artemis.Core.csproj @@ -94,7 +94,7 @@ ..\packages\Serilog.Sinks.File.4.0.0\lib\net45\Serilog.Sinks.File.dll - ..\packages\SkiaSharp.1.68.1.1\lib\net45\SkiaSharp.dll + ..\packages\SkiaSharp.1.68.2-preview.29\lib\net45\SkiaSharp.dll ..\packages\Stylet.1.3.0\lib\net45\Stylet.dll @@ -232,7 +232,7 @@ - + - + \ No newline at end of file diff --git a/src/Artemis.Core/packages.config b/src/Artemis.Core/packages.config index 65d99c5ab..c4150aa45 100644 --- a/src/Artemis.Core/packages.config +++ b/src/Artemis.Core/packages.config @@ -14,7 +14,7 @@ - + diff --git a/src/Artemis.Plugins.LayerBrushes.Color/Artemis.Plugins.LayerBrushes.Color.csproj b/src/Artemis.Plugins.LayerBrushes.Color/Artemis.Plugins.LayerBrushes.Color.csproj index e89cad702..897d25e53 100644 --- a/src/Artemis.Plugins.LayerBrushes.Color/Artemis.Plugins.LayerBrushes.Color.csproj +++ b/src/Artemis.Plugins.LayerBrushes.Color/Artemis.Plugins.LayerBrushes.Color.csproj @@ -54,7 +54,7 @@ False - ..\packages\SkiaSharp.1.68.1.1\lib\net45\SkiaSharp.dll + ..\packages\SkiaSharp.1.68.2-preview.29\lib\net45\SkiaSharp.dll ..\packages\Stylet.1.3.0\lib\net45\Stylet.dll @@ -117,11 +117,11 @@ echo Copying plugin to Artemis.UI output directory XCOPY "$(TargetDir.TrimEnd('\'))" "$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)" /s /q /i /y - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/Artemis.Plugins.LayerBrushes.Color/packages.config b/src/Artemis.Plugins.LayerBrushes.Color/packages.config index 07e19569f..b4c597d80 100644 --- a/src/Artemis.Plugins.LayerBrushes.Color/packages.config +++ b/src/Artemis.Plugins.LayerBrushes.Color/packages.config @@ -1,7 +1,7 @@  - + diff --git a/src/Artemis.Plugins.LayerBrushes.Noise/Artemis.Plugins.LayerBrushes.Noise.csproj b/src/Artemis.Plugins.LayerBrushes.Noise/Artemis.Plugins.LayerBrushes.Noise.csproj index 733029010..a0d80ec0b 100644 --- a/src/Artemis.Plugins.LayerBrushes.Noise/Artemis.Plugins.LayerBrushes.Noise.csproj +++ b/src/Artemis.Plugins.LayerBrushes.Noise/Artemis.Plugins.LayerBrushes.Noise.csproj @@ -54,7 +54,7 @@ False - ..\packages\SkiaSharp.1.68.1.1\lib\net45\SkiaSharp.dll + ..\packages\SkiaSharp.1.68.2-preview.29\lib\net45\SkiaSharp.dll ..\packages\Stylet.1.3.0\lib\net45\Stylet.dll @@ -118,11 +118,11 @@ echo Copying plugin to Artemis.UI output directory XCOPY "$(TargetDir.TrimEnd('\'))" "$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)" /s /q /i /y - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs b/src/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs index 01f9c3e98..4ede8f1c7 100644 --- a/src/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs +++ b/src/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs @@ -48,19 +48,21 @@ namespace Artemis.Plugins.LayerBrushes.Noise var verticalScale = ScaleProperty.CurrentValue.Height / 400f; // Scale down the render path to avoid computing a value for every pixel - var width = (int) (path.Bounds.Width * horizontalScale); - var height = (int) (path.Bounds.Height * verticalScale); + var width = Math.Floor(path.Bounds.Width * horizontalScale); + var height = Math.Floor(path.Bounds.Height * verticalScale); var opacity = (float) Math.Round(mainColor.Alpha / 255.0, 2, MidpointRounding.AwayFromZero); - using (var bitmap = new SKBitmap(new SKImageInfo(width, height))) + using (var bitmap = new SKBitmap(new SKImageInfo((int) width, (int) height))) { bitmap.Erase(SKColor.Empty); for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { - var v = _noise.Evaluate(1f / horizontalScale * x, 1f / verticalScale * y, _z); - var alpha = (byte) ((v + 1) * 127 * opacity); + var v = _noise.Evaluate(5 * x / width, 5 * y / height, _z); + var alpha = (byte) Math.Max(0, Math.Min(255, v * 2000)); + +// var alpha = (byte) ((v + 1) * 127 * opacity); // There's some fun stuff we can do here, like creating hard lines // if (alpha > 128) // alpha = 255; @@ -71,12 +73,12 @@ namespace Artemis.Plugins.LayerBrushes.Noise } - var makeTranslation = SKMatrix.MakeTranslation(path.Bounds.Left, path.Bounds.Top); + var makeTranslation = SKMatrix.MakeTranslation(path.Bounds.Left , path.Bounds.Top ); SKMatrix.Concat(ref makeTranslation, makeTranslation, SKMatrix.MakeScale(1f / horizontalScale, 1f / verticalScale)); using (var sh = SKShader.CreateBitmap(bitmap, SKShaderTileMode.Mirror, SKShaderTileMode.Mirror, makeTranslation)) { paint.FilterQuality = SKFilterQuality.Low; - + paint.ImageFilter = SKImageFilter.CreateBlur(2,2); paint.Shader = SKShader.CreateColor(SecondaryColorProperty.CurrentValue); canvas.DrawPath(path, paint); paint.Shader = sh; diff --git a/src/Artemis.Plugins.LayerBrushes.Noise/packages.config b/src/Artemis.Plugins.LayerBrushes.Noise/packages.config index 78451dca9..396ce6a6f 100644 --- a/src/Artemis.Plugins.LayerBrushes.Noise/packages.config +++ b/src/Artemis.Plugins.LayerBrushes.Noise/packages.config @@ -1,6 +1,6 @@  - + diff --git a/src/Artemis.Plugins.Modules.General/Artemis.Plugins.Modules.General.csproj b/src/Artemis.Plugins.Modules.General/Artemis.Plugins.Modules.General.csproj index 96f2e0176..9e8c79b26 100644 --- a/src/Artemis.Plugins.Modules.General/Artemis.Plugins.Modules.General.csproj +++ b/src/Artemis.Plugins.Modules.General/Artemis.Plugins.Modules.General.csproj @@ -48,7 +48,7 @@ ..\..\..\RGB.NET\bin\net45\RGB.NET.Core.dll - ..\packages\SkiaSharp.1.68.1.1\lib\net45\SkiaSharp.dll + ..\packages\SkiaSharp.1.68.2-preview.29\lib\net45\SkiaSharp.dll ..\packages\Stylet.1.3.0\lib\net45\Stylet.dll @@ -112,11 +112,11 @@ echo Copying plugin to Artemis.UI output directory XCOPY "$(TargetDir.TrimEnd('\'))" "$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)" /s /q /i /y - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/Artemis.Plugins.Modules.General/packages.config b/src/Artemis.Plugins.Modules.General/packages.config index 867f5dc4a..5c812bd07 100644 --- a/src/Artemis.Plugins.Modules.General/packages.config +++ b/src/Artemis.Plugins.Modules.General/packages.config @@ -1,7 +1,7 @@  - + diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj index 91c1bf71b..f321492c3 100644 --- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj +++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj @@ -48,7 +48,7 @@ ..\packages\MaterialDesignThemes.2.6.0\lib\net45\MaterialDesignThemes.Wpf.dll - ..\packages\SkiaSharp.1.68.1.1\lib\net45\SkiaSharp.dll + ..\packages\SkiaSharp.1.68.2-preview.29\lib\net45\SkiaSharp.dll @@ -125,11 +125,11 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/Artemis.UI.Shared/packages.config b/src/Artemis.UI.Shared/packages.config index dcd74b19b..71f5e1b73 100644 --- a/src/Artemis.UI.Shared/packages.config +++ b/src/Artemis.UI.Shared/packages.config @@ -3,7 +3,7 @@ - + diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index 181b07202..d91192cac 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -92,13 +92,13 @@ ..\packages\Serilog.2.8.0\lib\net46\Serilog.dll - ..\packages\SkiaSharp.1.68.1.1\lib\net45\SkiaSharp.dll + ..\packages\SkiaSharp.1.68.2-preview.29\lib\net45\SkiaSharp.dll - ..\packages\SkiaSharp.Views.Desktop.Common.1.68.1.1\lib\net45\SkiaSharp.Views.Desktop.Common.dll + ..\packages\SkiaSharp.Views.Desktop.Common.1.68.2-preview.29\lib\net45\SkiaSharp.Views.Desktop.Common.dll - ..\packages\SkiaSharp.Views.WPF.1.68.1.1\lib\net45\SkiaSharp.Views.WPF.dll + ..\packages\SkiaSharp.Views.WPF.1.68.2-preview.29\lib\net45\SkiaSharp.Views.WPF.dll ..\packages\Stylet.1.3.0\lib\net45\Stylet.dll @@ -580,7 +580,7 @@ - + @@ -590,5 +590,5 @@ - + \ No newline at end of file diff --git a/src/Artemis.UI/packages.config b/src/Artemis.UI/packages.config index 7a86da627..3650dda36 100644 --- a/src/Artemis.UI/packages.config +++ b/src/Artemis.UI/packages.config @@ -13,9 +13,9 @@ - - - + + +