UI - Many misc fixes I can't remember

Profile editor - Removed layer outline, increasing performance by a lot
Device visualizer - Streamlined custom
Device providers - Added debug device provider
ASUS - Added Maximus X Hero thanks @copystring
Plugin core - Added PerLedLayerBrush
Noise layer - Converted to PerLedLayerBrush, increasing performance and quality
This commit is contained in:
SpoinkyNL committed 2020-08-02 00:20:25 +02:00
1 parent 3000d4607a
commit aa7c914b92
29 files changed
+767 -277

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 MiB

@@ -0,0 +1,76 @@
<?xml version="1.0"?>
<Device xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Asus Maximus X Hero</Name>
<Description>Asus Maximus X Hero</Description>
<Type>None</Type>
<Lighting>Device</Lighting>
<Vendor>Asus</Vendor>
<Model>Maximus X Hero</Model>
<Width>555</Width>
<Height>690</Height>
<LedUnitWidth>150</LedUnitWidth>
<LedUnitHeight>150</LedUnitHeight>
<ImageBasePath>Images\Asus\Mainboards</ImageBasePath>
<DeviceImage>MAXIMUS-X-HERO.png</DeviceImage>
<Leds>
<Led Id="Logo">
<Shape> M0.241,0.804 L0.276,0.871 L0.285,0.861 L0.264,0.824 L0.273,0.812 L0.269,0.797 L0.273,0.788 L0.29,0.818 L0.295,0.802 L0.258,0.734 L0.264,0.796z M0.312,0.736 L0.272,0.668 L0.258,0.718 L0.298,0.798 L0.301,0.778 L0.283,0.747 L0.293,0.723 L0.307,0.748z M0.328,0.66 L0.303,0.648 L0.288,0.589 L0.287,0.613 L0.294,0.641 L0.278,0.636 L0.275,0.652 L0.3,0.668 L0.313,0.723 L0.318,0.709 L0.31,0.673 L0.317,0.672 L0.324,0.679z M0.296,0.564 L0.292,0.584 L0.33,0.651 L0.334,0.633z M0.318,0.494 L0.321,0.545 L0.3,0.553 L0.336,0.623 L0.339,0.607 L0.319,0.57 L0.331,0.563 L0.327,0.534 L0.347,0.569 L0.351,0.555z M0.331,0.416 L0.367,0.481 L0.358,0.535 L0.351,0.542 L0.315,0.472 L0.318,0.462 L0.354,0.521 L0.362,0.493 L0.327,0.427z M0.347,0.349 L0.334,0.394 L0.334,0.405 L0.354,0.446 L0.366,0.401 L0.378,0.42 L0.367,0.466 L0.372,0.467 L0.383,0.423 L0.382,0.409 L0.364,0.376 L0.351,0.419 L0.34,0.397 L0.347,0.364z M0.398,0.354 L0.4,0.322 L0.395,0.307 L0.409,0.311 L0.415,0.296 L0.39,0.282 L0.381,0.249 L0.374,0.237 L0.378,0.275 L0.363,0.27 L0.361,0.289 L0.385,0.301 L0.387,0.303z </Shape>
<X>16.6</X>
<Y>94</Y>
<Height>1</Height>
</Led>
<Led Id="Mainboard1">
<Shape> M0.56,0.404 L0.269,0.854 L0.283,0.857 L0.573,0.407z</Shape>
<X>7.5</X>
<Y>44</Y>
<Height>2</Height>
</Led>
<Led Id="Mainboard2">
<Shape> M0.166,0.341 L0.144,0.459 L0.145,0.657 L0.712,0.657 L0.809,0.502 L0.81,0.391 L0.775,0.337 L0.167,0.334z</Shape>
<X>133.8</X>
<Y>273.6</Y>
<Width>2</Width>
</Led>
<Led Id="Mainboard3">
<Shape> M0.305,0.581 L0.321,0.621 L0.342,0.632 L0.369,0.642 L0.372,0.635 L0.324,0.594z M0.358,0.595 L0.398,0.658 L0.418,0.675 L0.435,0.683 L0.436,0.679 L0.409,0.645 L0.423,0.629 L0.438,0.614 L0.461,0.597 L0.502,0.567 L0.552,0.534 L0.573,0.521 L0.61,0.504 L0.647,0.491 L0.648,0.486 L0.615,0.487 L0.608,0.49 L0.577,0.492 L0.564,0.498 L0.552,0.498 L0.544,0.503 L0.535,0.505 L0.52,0.514 L0.493,0.535 L0.415,0.61 L0.409,0.612 L0.361,0.592z M0.517,0.624 L0.65,0.559 L0.656,0.562 L0.639,0.6 L0.619,0.634 L0.607,0.651 L0.584,0.674 L0.564,0.684 L0.525,0.682 L0.488,0.671 L0.448,0.658 L0.429,0.647 L0.433,0.64 L0.53,0.576 L0.585,0.547 L0.617,0.534 L0.658,0.523 L0.67,0.522 L0.67,0.53 L0.667,0.535 L0.603,0.565 L0.526,0.601 L0.458,0.643 L0.49,0.654 L0.53,0.662 L0.543,0.662 L0.571,0.652 L0.604,0.597z</Shape>
<X>334.3</X>
<Y>423.4</Y>
</Led>
</Leds>
<LedImageLayouts>
<LedImageLayout>
<LedImages />
</LedImageLayout>
<LedImageLayout>
<LedImages />
</LedImageLayout>
<LedImageLayout>
<LedImages />
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="Logo" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="Logo" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="Mainboard2" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="Mainboard3" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="Mainboard1" />
</LedImages>
</LedImageLayout>
</LedImageLayouts>
</Device>
@@ -0,0 +1,53 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyTitle>Artemis.Plugins.Devices.Wooting</AssemblyTitle>
<Product>Artemis.Plugins.Devices.Wooting</Product>
<Copyright>Copyright © 2019</Copyright>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>7.3</LangVersion>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<UseWPF>true</UseWPF>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<None Remove="Views\DebugConfigurationView.xaml" />
</ItemGroup>
<ItemGroup>
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MaterialDesignThemes" Version="3.1.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Artemis.Core\Artemis.Core.csproj">
<Private>false</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="RGB.NET.Core">
<HintPath>..\..\..\..\RGB.NET\bin\netstandard2.0\RGB.NET.Core.dll</HintPath>
</Reference>
<Reference Include="RGB.NET.Devices.Debug">
<HintPath>..\..\..\..\RGB.NET\bin\netstandard2.0\RGB.NET.Devices.Debug.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Update="Images\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Layouts\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</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" />
</Target>
</Project>
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.IO;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Devices.Debug.Settings;
using Artemis.Plugins.Devices.Debug.ViewModels;
using RGB.NET.Core;
using RGB.NET.Devices.Debug;
namespace Artemis.Plugins.Devices.Debug
{
// ReSharper disable once UnusedMember.Global
public class DebugDeviceProvider : DeviceProvider
{
private readonly IRgbService _rgbService;
private readonly PluginSettings _settings;
public DebugDeviceProvider(IRgbService rgbService, PluginSettings settings) : base(RGB.NET.Devices.Debug.DebugDeviceProvider.Instance)
{
_settings = settings;
_rgbService = rgbService;
}
public override void EnablePlugin()
{
HasConfigurationViewModel = true;
PathHelper.ResolvingAbsolutePath += PathHelperOnResolvingAbsolutePath;
var definitions = _settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
if (definitions.Value == null)
definitions.Value = new List<DeviceDefinition>();
foreach (var deviceDefinition in definitions.Value)
RGB.NET.Devices.Debug.DebugDeviceProvider.Instance.AddFakeDeviceDefinition(deviceDefinition.Layout, deviceDefinition.ImageLayout);
_rgbService.AddDeviceProvider(RgbDeviceProvider);
}
private void PathHelperOnResolvingAbsolutePath(object sender, ResolvePathEventArgs e)
{
if (sender is DebugRGBDevice debugRgbDevice)
{
if (debugRgbDevice.LayoutPath.Contains("\\Layouts\\"))
{
var rootDirectory = debugRgbDevice.LayoutPath.Split("\\Layouts")[0];
e.FinalPath = Path.Combine(rootDirectory, e.RelativePath);
}
var test =debugRgbDevice.LayoutPath;
}
}
public override void DisablePlugin()
{
// TODO: Remove the device provider from the surface
}
public override PluginConfigurationViewModel GetConfigurationViewModel()
{
return new DebugConfigurationViewModel(this, _settings);
}
}
}
@@ -0,0 +1,9 @@
using System.Runtime.InteropServices;
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c6bdb6d9-062d-4c28-a280-f3bd6197f07f")]
@@ -0,0 +1,8 @@
namespace Artemis.Plugins.Devices.Debug.Settings
{
public class DeviceDefinition
{
public string Layout { get; set; }
public string ImageLayout { get; set; }
}
}
@@ -0,0 +1,39 @@
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Models;
using Artemis.Plugins.Devices.Debug.Settings;
using Stylet;
namespace Artemis.Plugins.Devices.Debug.ViewModels
{
public class DebugConfigurationViewModel : PluginConfigurationViewModel
{
private PluginSetting<List<DeviceDefinition>> _definitions;
public DebugConfigurationViewModel(Plugin plugin, PluginSettings settings) : base(plugin)
{
_definitions = settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
Definitions = new BindableCollection<DeviceDefinition>(_definitions.Value);
}
public BindableCollection<DeviceDefinition> Definitions { get; }
public void SaveChanges()
{
// Ignore empty definitions
_definitions.Value.Clear();
_definitions.Value.AddRange(Definitions.Where(d => !string.IsNullOrWhiteSpace(d.Layout) || !string.IsNullOrWhiteSpace(d.ImageLayout)));
_definitions.Save();
RequestClose();
}
public void Cancel()
{
_definitions.RejectChanges();
RequestClose();
}
}
}
@@ -0,0 +1,49 @@
<UserControl x:Class="Artemis.Plugins.Devices.Debug.Views.DebugConfigurationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.Plugins.Devices.Debug.Views"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid Margin="15">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock>
Enter absolute paths to the device layout and choose the image layout you wish to test. <LineBreak/>
Please note that currently RGB.NET does not support changing devices on runtime and so any changes below won't be applied until you restart Artemis.
</TextBlock>
<DataGrid Grid.Row="1"
ItemsSource="{Binding Definitions}"
AutoGenerateColumns="False"
CanUserSortColumns="True"
CanUserAddRows="True"
materialDesign:DataGridAssist.CellPadding="13 8 8 8"
materialDesign:DataGridAssist.ColumnHeaderPadding="8"
HeadersVisibility="All">
<DataGrid.Columns>
<materialDesign:DataGridTextColumn Width="*"
Binding="{Binding Layout}"
Header="Layout path"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" />
<materialDesign:DataGridTextColumn Width="*"
Binding="{Binding ImageLayout}"
Header="Image layout (optional)"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" />
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Margin="0 0 5 0" Command="{s:Action Cancel}">
CANCEL
</Button>
<Button Style="{StaticResource MaterialDesignFlatMidBgButton}" Command="{s:Action SaveChanges}">
SAVE CHANGES
</Button>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.4.5.0" newVersion="1.4.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.5.0" newVersion="1.2.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -0,0 +1,7 @@
{
"Guid": "cad475d3-c621-4ec7-bbfc-784e3b4723ce",
"Name": "Debug Devices",
"Description": "Provides configurable debug devices to among other things easily test layouts",
"Version": "1.0.0.0",
"Main": "Artemis.Plugins.Devices.Debug.dll"
}
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using Artemis.Core.Extensions;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.LayerBrushes.Noise.Utilities;
@@ -8,7 +9,7 @@ using SkiaSharp;
namespace Artemis.Plugins.LayerBrushes.Noise
{
public class NoiseBrush : LayerBrush<NoiseBrushProperties>
public class NoiseBrush : PerLedLayerBrush<NoiseBrushProperties>
{
private static readonly Random Rand = new Random();
private readonly IRgbService _rgbService;
@@ -60,75 +61,69 @@ namespace Artemis.Plugins.LayerBrushes.Noise
DetermineRenderScale();
}
public override void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
{
var mainColor = Properties.MainColor.CurrentValue;
var secondColor = Properties.SecondaryColor.CurrentValue;
var gradientColor = Properties.GradientColor.CurrentValue;
var scale = Properties.Scale.CurrentValue;
var hardness = Properties.Hardness.CurrentValue / 100f;
// Scale down the render path to avoid computing a value for every pixel
var width = (int) Math.Floor(path.Bounds.Width * _renderScale);
var height = (int) Math.Floor(path.Bounds.Height * _renderScale);
CreateBitmap(width, height);
// Copy the layer path to use for the clip path
using var layerPath = new SKPath(Layer.Path);
// Undo any transformations
Layer.ExcludePathFromTranslation(layerPath);
// Apply the transformations so new ones may be applied, not sure if there is a better way to do this
using var clipPath = new SKPath(layerPath);
// Zero out the position of the clip path
clipPath.Transform(SKMatrix.MakeTranslation(Layer.Path.Bounds.Left * -1, Layer.Path.Bounds.Top * -1));
// Fill a canvas matching the final area that will be rendered
using var bitmapCanvas = new SKCanvas(_bitmap);
using var clipPaint = new SKPaint {Color = new SKColor(0, 0, 0, 255)};
bitmapCanvas.Clear();
bitmapCanvas.Scale(_renderScale);
bitmapCanvas.DrawPath(clipPath, clipPaint);
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
var scrolledX = x + _x;
var scrolledY = y + _y;
var evalX = 0.1 * scale.Width * scrolledX / width;
var evalY = 0.1 * scale.Height * scrolledY / height;
if (double.IsInfinity(evalX) || double.IsNaN(evalX) || double.IsNaN(evalY) || double.IsInfinity(evalY))
continue;
var pixel = _bitmap.GetPixel(x, y);
if (pixel.Alpha != 255)
continue;
var v = (float) _noise.Evaluate(evalX, evalY, _z) * hardness;
var amount = Math.Max(0f, Math.Min(1f, v));
if (Properties.ColorType.BaseValue == ColorMappingType.Simple)
_bitmap.SetPixel(x, y, mainColor.Interpolate(secondColor, amount));
else if (gradientColor != null && _colorMap.Length == 101)
{
var color = _colorMap[(int) Math.Round(amount * 100, MidpointRounding.AwayFromZero)];
_bitmap.SetPixel(x, y, color);
}
}
}
var bitmapTransform = SKMatrix.Concat(
SKMatrix.MakeTranslation(path.Bounds.Left, path.Bounds.Top),
SKMatrix.MakeScale(1f / _renderScale, 1f / _renderScale)
);
if (Properties.ColorType.BaseValue == ColorMappingType.Simple)
paint.Color = Properties.SecondaryColor.CurrentValue;
using var foregroundShader = SKShader.CreateBitmap(_bitmap, SKShaderTileMode.Clamp, SKShaderTileMode.Clamp, bitmapTransform);
paint.Shader = foregroundShader;
canvas.DrawPath(path, paint);
}
// public override void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
// {
// var mainColor = Properties.MainColor.CurrentValue;
// var secondColor = Properties.SecondaryColor.CurrentValue;
// var gradientColor = Properties.GradientColor.CurrentValue;
// var scale = Properties.Scale.CurrentValue;
// var hardness = Properties.Hardness.CurrentValue / 100f;
//
// // Scale down the render path to avoid computing a value for every pixel
// var width = (int) Math.Floor(path.Bounds.Width * _renderScale);
// var height = (int) Math.Floor(path.Bounds.Height * _renderScale);
//
// // This lil' snippet renders per LED, it's neater but doesn't support translations
// Layer.ExcludeCanvasFromTranslation(canvas);
//
// var shapePath = new SKPath(Layer.LayerShape.Path);
// Layer.IncludePathInTranslation(shapePath);
// canvas.ClipPath(shapePath);
//
// using var ledPaint = new SKPaint();
// foreach (var artemisLed in Layer.Leds)
// {
// var ledRectangle = SKRect.Create(
// artemisLed.AbsoluteRenderRectangle.Left - Layer.Bounds.Left,
// artemisLed.AbsoluteRenderRectangle.Top - Layer.Bounds.Top,
// artemisLed.AbsoluteRenderRectangle.Width,
// artemisLed.AbsoluteRenderRectangle.Height
// );
//
// var scrolledX = ledRectangle.MidX + _x;
// if (float.IsNaN(scrolledX))
// scrolledX = 0;
// var scrolledY = ledRectangle.MidY + _y;
// if (float.IsNaN(scrolledY))
// scrolledY = 0;
//
//
// var evalPath = new SKPath();
// evalPath.AddPoly(new[] {new SKPoint(0, 0), new SKPoint(scrolledX, scrolledY)});
// Layer.ExcludePathFromTranslation(evalPath);
//
// if (evalPath.Bounds.IsEmpty)
// continue;
//
// scrolledX = evalPath.Points[1].X;
// scrolledY = evalPath.Points[1].Y;
//
// var evalX = 0.1 * scale.Width * scrolledX / width;
// var evalY = 0.1 * scale.Height * scrolledY / height;
//
// var v = (float) _noise.Evaluate(evalX, evalY, _z) * hardness;
// var amount = Math.Max(0f, Math.Min(1f, v));
//
// if (Properties.ColorType.BaseValue == ColorMappingType.Simple)
// ledPaint.Color = mainColor.Interpolate(secondColor, amount);
// else if (gradientColor != null && _colorMap.Length == 101)
// ledPaint.Color = _colorMap[(int) Math.Round(amount * 100, MidpointRounding.AwayFromZero)];
// else
// ledPaint.Color = SKColor.Empty;
//
// canvas.DrawRect(ledRectangle, ledPaint);
// }
// }
private void GradientColorChanged(object sender, PropertyChangedEventArgs e)
{
@@ -138,7 +133,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise
private void DetermineRenderScale()
{
_renderScale = (float) (0.125f / _rgbService.RenderScale);
_renderScale = (float) (0.25f / _rgbService.RenderScale);
}
private void CreateBitmap(int width, int height)
@@ -160,6 +155,36 @@ namespace Artemis.Plugins.LayerBrushes.Noise
_colorMap = colorMap;
}
public override SKColor GetColor(ArtemisLed led, SKPoint renderPoint)
{
var mainColor = Properties.MainColor.CurrentValue;
var secondColor = Properties.SecondaryColor.CurrentValue;
var gradientColor = Properties.GradientColor.CurrentValue;
var scale = Properties.Scale.CurrentValue;
var hardness = Properties.Hardness.CurrentValue / 100f;
var scrolledX = renderPoint.X + _x;
if (float.IsNaN(scrolledX))
scrolledX = 0;
var scrolledY = renderPoint.Y + _y;
if (float.IsNaN(scrolledY))
scrolledY = 0;
var evalX = scrolledX * (scale.Width *-1) / 1000f;
var evalY = scrolledY * (scale.Height*-1) / 1000f;
var v = (float) _noise.Evaluate(evalX, evalY, _z) * hardness;
var amount = Math.Max(0f, Math.Min(1f, v));
if (Properties.ColorType.BaseValue == ColorMappingType.Simple)
return mainColor.Interpolate(secondColor, amount);
else if (gradientColor != null && _colorMap.Length == 101)
return _colorMap[(int) Math.Round(amount * 100, MidpointRounding.AwayFromZero)];
else
return SKColor.Empty;
}
}
public enum ColorMappingType