diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs index 361e32d95..d35a50833 100644 --- a/src/Artemis.Core/Models/Profile/Layer.cs +++ b/src/Artemis.Core/Models/Profile/Layer.cs @@ -67,8 +67,8 @@ namespace Artemis.Core.Models.Profile public ReadOnlyCollection Leds => _leds.AsReadOnly(); /// - /// A path containing all the LEDs this layer is applied to, any rendering outside the layer Path is clipped. - /// For rendering, use the Path on . + /// Gets a copy of the path containing all the LEDs this layer is applied to, any rendering outside the layer Path is + /// clipped. /// public SKPath Path { @@ -211,6 +211,7 @@ namespace Artemis.Core.Models.Profile #region Rendering + /// public override void Update(double deltaTime) { foreach (var property in Properties) @@ -231,6 +232,7 @@ namespace Artemis.Core.Models.Profile LayerBrush?.Update(deltaTime); } + /// public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo) { if (Path == null || LayerShape?.Path == null) diff --git a/src/Artemis.Core/Models/Profile/LayerShapes/LayerShape.cs b/src/Artemis.Core/Models/Profile/LayerShapes/LayerShape.cs index d05e62bfc..e7c878307 100644 --- a/src/Artemis.Core/Models/Profile/LayerShapes/LayerShape.cs +++ b/src/Artemis.Core/Models/Profile/LayerShapes/LayerShape.cs @@ -4,6 +4,8 @@ namespace Artemis.Core.Models.Profile.LayerShapes { public abstract class LayerShape { + private SKPath _path; + protected LayerShape(Layer layer) { Layer = layer; @@ -15,9 +17,13 @@ namespace Artemis.Core.Models.Profile.LayerShapes public Layer Layer { get; set; } /// - /// A path outlining the shape + /// Gets a copy of the path outlining the shape /// - public SKPath Path { get; protected set; } + public SKPath Path + { + get => _path != null ? new SKPath(_path) : null; + protected set => _path = value; + } public abstract void CalculateRenderProperties(); } diff --git a/src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs index 4c9e66790..80fd93a05 100644 --- a/src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs +++ b/src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs @@ -53,10 +53,11 @@ namespace Artemis.Core.Plugins.LayerBrush /// A and ID identifying your property, must be unique within your plugin /// A name for your property, this is visible in the editor /// A description for your property, this is visible in the editor + /// The default value of the property, if not configured by the user /// The layer property - protected LayerProperty RegisterLayerProperty(BaseLayerProperty parent, string id, string name, string description) + protected LayerProperty RegisterLayerProperty(BaseLayerProperty parent, string id, string name, string description, T defaultValue = default) { - var property = new LayerProperty(Layer, Descriptor.LayerBrushProvider.PluginInfo, parent, id, name, description); + var property = new LayerProperty(Layer, Descriptor.LayerBrushProvider.PluginInfo, parent, id, name, description) {Value = defaultValue}; Layer.RegisterLayerProperty(property); // It's fine if this is null, it'll be picked up by SetLayerService later _layerService?.InstantiateKeyframeEngine(property); @@ -71,12 +72,13 @@ namespace Artemis.Core.Plugins.LayerBrush /// A and ID identifying your property, must be unique within your plugin /// A name for your property, this is visible in the editor /// A description for your property, this is visible in the editor + /// The default value of the property, if not configured by the user /// The layer property - protected LayerProperty RegisterLayerProperty(string id, string name, string description) + protected LayerProperty RegisterLayerProperty(string id, string name, string description, T defaultValue = default) { var property = new LayerProperty( Layer, Descriptor.LayerBrushProvider.PluginInfo, Layer.BrushReferenceProperty.Parent, id, name, description - ); + ) {Value = defaultValue}; Layer.RegisterLayerProperty(property); // It's fine if this is null, it'll be picked up by SetLayerService later _layerService?.InstantiateKeyframeEngine(property); diff --git a/src/Artemis.Core/RGB.NET/BitmapBrush.cs b/src/Artemis.Core/RGB.NET/BitmapBrush.cs index bae50acb3..9f4974a57 100644 --- a/src/Artemis.Core/RGB.NET/BitmapBrush.cs +++ b/src/Artemis.Core/RGB.NET/BitmapBrush.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Artemis.Core.Extensions; using Artemis.Core.Plugins.Models; using RGB.NET.Core; @@ -89,6 +90,7 @@ namespace Artemis.Core.RGB.NET var bitmapWidth = Bitmap.Width; var bitmapHeight = Bitmap.Height; + var pixmap = Bitmap.PeekPixels(); foreach (var renderTarget in renderTargets) { // SKRect has all the good stuff we need @@ -110,7 +112,7 @@ namespace Artemis.Core.RGB.NET if (x < 0 || x > bitmapWidth || y < 0 || y > bitmapHeight) continue; - var color = Bitmap.GetPixel(x, y); + var color = pixmap.GetPixelColor(x, y); a += color.Alpha; r += color.Red; g += color.Green; diff --git a/src/Artemis.Plugins.Devices.Corsair/Images/Corsair/Headsets/VOIDRGB.png b/src/Artemis.Plugins.Devices.Corsair/Images/Corsair/Headsets/VOIDRGB.png new file mode 100644 index 000000000..9ead0959d Binary files /dev/null and b/src/Artemis.Plugins.Devices.Corsair/Images/Corsair/Headsets/VOIDRGB.png differ diff --git a/src/Artemis.Plugins.Devices.Corsair/Layouts/Corsair/Headsets/VIRTUOSO.xml b/src/Artemis.Plugins.Devices.Corsair/Layouts/Corsair/Headsets/VIRTUOSO.xml new file mode 100644 index 000000000..2861227ff --- /dev/null +++ b/src/Artemis.Plugins.Devices.Corsair/Layouts/Corsair/Headsets/VIRTUOSO.xml @@ -0,0 +1,39 @@ + + + Corsair Virtuoso + Physical layout of Corsairs Virtuoso + Headset + Key + Corsair + VIRTUOSO + 242 + 228 + 35 + 85 + Images\Corsair\Headsets + VOIDRGB.png + + + M0.766,0.059 L0.685,0.044 L0.497,0.053 L0.326,0.123 L0.17,0.276 L0.113,0.454 L0.109,0.649 L0.142,0.822 L0.232,0.896 L0.305,0.851 L0.399,0.826 L0.468,0.809 L0.428,0.663 L0.423,0.501 L0.489,0.332 L0.64,0.148z + 0 + 105 + 1 + + + M0.071,0.053 L0.03,0.036 L0.118,0.023 L0.316,0.027 L0.497,0.077 L0.71,0.248 L0.804,0.415 L0.877,0.586 L0.903,0.731 L0.851,0.845 L0.799,0.877 L0.721,0.838 L0.591,0.802 L0.508,0.789 L0.549,0.695 L0.539,0.558 L0.451,0.415 L0.362,0.308 L0.274,0.201 L0.149,0.104z + +170 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.Plugins.Devices.Corsair/Layouts/Corsair/Headsets/VIRTUOSOSE.xml b/src/Artemis.Plugins.Devices.Corsair/Layouts/Corsair/Headsets/VIRTUOSOSE.xml new file mode 100644 index 000000000..c8dfb5d92 --- /dev/null +++ b/src/Artemis.Plugins.Devices.Corsair/Layouts/Corsair/Headsets/VIRTUOSOSE.xml @@ -0,0 +1,39 @@ + + + Corsair Virtuoso SE + Physical layout of Corsairs Virtuoso SE + Headset + Key + Corsair + VIRTUOSOSE + 242 + 228 + 35 + 85 + Images\Corsair\Headsets + VOIDRGB.png + + + M0.766,0.059 L0.685,0.044 L0.497,0.053 L0.326,0.123 L0.17,0.276 L0.113,0.454 L0.109,0.649 L0.142,0.822 L0.232,0.896 L0.305,0.851 L0.399,0.826 L0.468,0.809 L0.428,0.663 L0.423,0.501 L0.489,0.332 L0.64,0.148z + 0 + 105 + 1 + + + M0.071,0.053 L0.03,0.036 L0.118,0.023 L0.316,0.027 L0.497,0.077 L0.71,0.248 L0.804,0.415 L0.877,0.586 L0.903,0.731 L0.851,0.845 L0.799,0.877 L0.721,0.838 L0.591,0.802 L0.508,0.789 L0.549,0.695 L0.539,0.558 L0.451,0.415 L0.362,0.308 L0.274,0.201 L0.149,0.104z + +170 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.Plugins.Devices.Corsair/Layouts/Corsair/Headsets/VOIDRGB.xml b/src/Artemis.Plugins.Devices.Corsair/Layouts/Corsair/Headsets/VOIDRGB.xml new file mode 100644 index 000000000..a574f9a2a --- /dev/null +++ b/src/Artemis.Plugins.Devices.Corsair/Layouts/Corsair/Headsets/VOIDRGB.xml @@ -0,0 +1,39 @@ + + + Corsair VOID RGB + Physical layout of Corsairs VOID RGB + Headset + Key + Corsair + VOIDRGB + 242 + 228 + 35 + 85 + Images\Corsair\Headsets + VOIDRGB.png + + + M0.766,0.059 L0.685,0.044 L0.497,0.053 L0.326,0.123 L0.17,0.276 L0.113,0.454 L0.109,0.649 L0.142,0.822 L0.232,0.896 L0.305,0.851 L0.399,0.826 L0.468,0.809 L0.428,0.663 L0.423,0.501 L0.489,0.332 L0.64,0.148z + 0 + 105 + 1 + + + M0.071,0.053 L0.03,0.036 L0.118,0.023 L0.316,0.027 L0.497,0.077 L0.71,0.248 L0.804,0.415 L0.877,0.586 L0.903,0.731 L0.851,0.845 L0.799,0.877 L0.721,0.838 L0.591,0.802 L0.508,0.789 L0.549,0.695 L0.539,0.558 L0.451,0.415 L0.362,0.308 L0.274,0.201 L0.149,0.104z + +170 + + + + + + + + + + + + + + + \ 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 a19d12079..8e2fc44be 100644 --- a/src/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs +++ b/src/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs @@ -31,6 +31,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise MainColorProperty = RegisterLayerProperty("Brush.MainColor", "Main color", "The main color of the noise."); SecondaryColorProperty = RegisterLayerProperty("Brush.SecondaryColor", "Secondary color", "The secondary color of the noise."); ScaleProperty = RegisterLayerProperty("Brush.Scale", "Scale", "The scale of the noise."); + HardnessProperty = RegisterLayerProperty("Brush.Hardness", "Hardness", "The hardness of the noise, lower means there are gradients in the noise, higher means hard lines.."); ScrollSpeedProperty = RegisterLayerProperty("Brush.ScrollSpeed", "Movement speed", "The speed at which the noise moves vertically and horizontally."); AnimationSpeedProperty = RegisterLayerProperty("Brush.AnimationSpeed", "Animation speed", "The speed at which the noise moves."); ScaleProperty.InputAffix = "%"; @@ -41,6 +42,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise public LayerProperty MainColorProperty { get; set; } public LayerProperty SecondaryColorProperty { get; set; } public LayerProperty ScaleProperty { get; set; } + public LayerProperty HardnessProperty { get; set; } public LayerProperty ScrollSpeedProperty { get; set; } public LayerProperty AnimationSpeedProperty { get; set; } @@ -67,30 +69,31 @@ namespace Artemis.Plugins.LayerBrushes.Noise var mainColor = MainColorProperty.CurrentValue; var scale = ScaleProperty.CurrentValue; var opacity = (float) Math.Round(mainColor.Alpha / 255.0, 2, MidpointRounding.AwayFromZero); + var hardness = 127 + HardnessProperty.CurrentValue; // Scale down the render path to avoid computing a value for every pixel - var width = Math.Floor(path.Bounds.Width * _renderScale); - var height = Math.Floor(path.Bounds.Height * _renderScale); + var width = (int) Math.Floor(path.Bounds.Width * _renderScale); + var height = (int) Math.Floor(path.Bounds.Height * _renderScale); - CreateBitmap((int) width, (int) height); - - for (var x = 0; x < width; x++) + CreateBitmap(width, height); + for (var y = 0; y < height; y++) { - var scrolledX = x + _x; - 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.IsNaN(evalX) || double.IsNaN(evalY)) + if (double.IsInfinity(evalX) || double.IsNaN(evalX) || double.IsNaN(evalY) || double.IsInfinity(evalY)) continue; var v = _noise.Evaluate(evalX, evalY, _z); - var alpha = (byte) Math.Max(0, Math.Min(255, v * 1024)); + var alpha = (byte) Math.Max(0, Math.Min(255, v * hardness)); _bitmap.SetPixel(x, y, new SKColor(mainColor.Red, mainColor.Green, mainColor.Blue, (byte) (alpha * opacity))); } } + var bitmapTransform = SKMatrix.Concat( SKMatrix.MakeTranslation(path.Bounds.Left, path.Bounds.Top), SKMatrix.MakeScale(1f / _renderScale, 1f / _renderScale) @@ -106,6 +109,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise } } + private void DetermineRenderScale() { _renderScale = (float) (0.125f / _rgbService.RenderScale);