mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 02:33:32 +00:00
Corsair - Added VOID layout and Virtuoso PH layout
Core - Added default value to brush plugin properties Core - Bitmap brush optimizations
This commit is contained in:
parent
4b1b0248f5
commit
1d81b782da
@ -67,8 +67,8 @@ namespace Artemis.Core.Models.Profile
|
|||||||
public ReadOnlyCollection<ArtemisLed> Leds => _leds.AsReadOnly();
|
public ReadOnlyCollection<ArtemisLed> Leds => _leds.AsReadOnly();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A path containing all the LEDs this layer is applied to, any rendering outside the layer Path is clipped.
|
/// Gets a copy of the path containing all the LEDs this layer is applied to, any rendering outside the layer Path is
|
||||||
/// <para>For rendering, use the Path on <see cref="LayerShape" />.</para>
|
/// clipped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKPath Path
|
public SKPath Path
|
||||||
{
|
{
|
||||||
@ -211,6 +211,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
#region Rendering
|
#region Rendering
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public override void Update(double deltaTime)
|
public override void Update(double deltaTime)
|
||||||
{
|
{
|
||||||
foreach (var property in Properties)
|
foreach (var property in Properties)
|
||||||
@ -231,6 +232,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
LayerBrush?.Update(deltaTime);
|
LayerBrush?.Update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo)
|
public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo)
|
||||||
{
|
{
|
||||||
if (Path == null || LayerShape?.Path == null)
|
if (Path == null || LayerShape?.Path == null)
|
||||||
|
|||||||
@ -4,6 +4,8 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
|||||||
{
|
{
|
||||||
public abstract class LayerShape
|
public abstract class LayerShape
|
||||||
{
|
{
|
||||||
|
private SKPath _path;
|
||||||
|
|
||||||
protected LayerShape(Layer layer)
|
protected LayerShape(Layer layer)
|
||||||
{
|
{
|
||||||
Layer = layer;
|
Layer = layer;
|
||||||
@ -15,9 +17,13 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
|||||||
public Layer Layer { get; set; }
|
public Layer Layer { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A path outlining the shape
|
/// Gets a copy of the path outlining the shape
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKPath Path { get; protected set; }
|
public SKPath Path
|
||||||
|
{
|
||||||
|
get => _path != null ? new SKPath(_path) : null;
|
||||||
|
protected set => _path = value;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void CalculateRenderProperties();
|
public abstract void CalculateRenderProperties();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,10 +53,11 @@ namespace Artemis.Core.Plugins.LayerBrush
|
|||||||
/// <param name="id">A and ID identifying your property, must be unique within your plugin</param>
|
/// <param name="id">A and ID identifying your property, must be unique within your plugin</param>
|
||||||
/// <param name="name">A name for your property, this is visible in the editor</param>
|
/// <param name="name">A name for your property, this is visible in the editor</param>
|
||||||
/// <param name="description">A description for your property, this is visible in the editor</param>
|
/// <param name="description">A description for your property, this is visible in the editor</param>
|
||||||
|
/// <param name="defaultValue">The default value of the property, if not configured by the user</param>
|
||||||
/// <returns>The layer property</returns>
|
/// <returns>The layer property</returns>
|
||||||
protected LayerProperty<T> RegisterLayerProperty<T>(BaseLayerProperty parent, string id, string name, string description)
|
protected LayerProperty<T> RegisterLayerProperty<T>(BaseLayerProperty parent, string id, string name, string description, T defaultValue = default)
|
||||||
{
|
{
|
||||||
var property = new LayerProperty<T>(Layer, Descriptor.LayerBrushProvider.PluginInfo, parent, id, name, description);
|
var property = new LayerProperty<T>(Layer, Descriptor.LayerBrushProvider.PluginInfo, parent, id, name, description) {Value = defaultValue};
|
||||||
Layer.RegisterLayerProperty(property);
|
Layer.RegisterLayerProperty(property);
|
||||||
// It's fine if this is null, it'll be picked up by SetLayerService later
|
// It's fine if this is null, it'll be picked up by SetLayerService later
|
||||||
_layerService?.InstantiateKeyframeEngine(property);
|
_layerService?.InstantiateKeyframeEngine(property);
|
||||||
@ -71,12 +72,13 @@ namespace Artemis.Core.Plugins.LayerBrush
|
|||||||
/// <param name="id">A and ID identifying your property, must be unique within your plugin</param>
|
/// <param name="id">A and ID identifying your property, must be unique within your plugin</param>
|
||||||
/// <param name="name">A name for your property, this is visible in the editor</param>
|
/// <param name="name">A name for your property, this is visible in the editor</param>
|
||||||
/// <param name="description">A description for your property, this is visible in the editor</param>
|
/// <param name="description">A description for your property, this is visible in the editor</param>
|
||||||
|
/// <param name="defaultValue">The default value of the property, if not configured by the user</param>
|
||||||
/// <returns>The layer property</returns>
|
/// <returns>The layer property</returns>
|
||||||
protected LayerProperty<T> RegisterLayerProperty<T>(string id, string name, string description)
|
protected LayerProperty<T> RegisterLayerProperty<T>(string id, string name, string description, T defaultValue = default)
|
||||||
{
|
{
|
||||||
var property = new LayerProperty<T>(
|
var property = new LayerProperty<T>(
|
||||||
Layer, Descriptor.LayerBrushProvider.PluginInfo, Layer.BrushReferenceProperty.Parent, id, name, description
|
Layer, Descriptor.LayerBrushProvider.PluginInfo, Layer.BrushReferenceProperty.Parent, id, name, description
|
||||||
);
|
) {Value = defaultValue};
|
||||||
Layer.RegisterLayerProperty(property);
|
Layer.RegisterLayerProperty(property);
|
||||||
// It's fine if this is null, it'll be picked up by SetLayerService later
|
// It's fine if this is null, it'll be picked up by SetLayerService later
|
||||||
_layerService?.InstantiateKeyframeEngine(property);
|
_layerService?.InstantiateKeyframeEngine(property);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Artemis.Core.Extensions;
|
using Artemis.Core.Extensions;
|
||||||
using Artemis.Core.Plugins.Models;
|
using Artemis.Core.Plugins.Models;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
@ -89,6 +90,7 @@ namespace Artemis.Core.RGB.NET
|
|||||||
var bitmapWidth = Bitmap.Width;
|
var bitmapWidth = Bitmap.Width;
|
||||||
var bitmapHeight = Bitmap.Height;
|
var bitmapHeight = Bitmap.Height;
|
||||||
|
|
||||||
|
var pixmap = Bitmap.PeekPixels();
|
||||||
foreach (var renderTarget in renderTargets)
|
foreach (var renderTarget in renderTargets)
|
||||||
{
|
{
|
||||||
// SKRect has all the good stuff we need
|
// 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)
|
if (x < 0 || x > bitmapWidth || y < 0 || y > bitmapHeight)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var color = Bitmap.GetPixel(x, y);
|
var color = pixmap.GetPixelColor(x, y);
|
||||||
a += color.Alpha;
|
a += color.Alpha;
|
||||||
r += color.Red;
|
r += color.Red;
|
||||||
g += color.Green;
|
g += color.Green;
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 162 KiB |
@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<Device xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<Name>Corsair Virtuoso</Name>
|
||||||
|
<Description>Physical layout of Corsairs Virtuoso</Description>
|
||||||
|
<Type>Headset</Type>
|
||||||
|
<Lighting>Key</Lighting>
|
||||||
|
<Vendor>Corsair</Vendor>
|
||||||
|
<Model>VIRTUOSO</Model>
|
||||||
|
<Width>242</Width>
|
||||||
|
<Height>228</Height>
|
||||||
|
<LedUnitWidth>35</LedUnitWidth>
|
||||||
|
<LedUnitHeight>85</LedUnitHeight>
|
||||||
|
<ImageBasePath>Images\Corsair\Headsets</ImageBasePath>
|
||||||
|
<DeviceImage>VOIDRGB.png</DeviceImage>
|
||||||
|
<Leds>
|
||||||
|
<Led Id="Headset1">
|
||||||
|
<Shape>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</Shape>
|
||||||
|
<X>0</X>
|
||||||
|
<Y>105</Y>
|
||||||
|
<Height>1</Height>
|
||||||
|
</Led>
|
||||||
|
<Led Id="Headset2">
|
||||||
|
<Shape>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</Shape>
|
||||||
|
<X>+170</X>
|
||||||
|
</Led>
|
||||||
|
</Leds>
|
||||||
|
<LedImageLayouts>
|
||||||
|
<LedImageLayout>
|
||||||
|
<LedImages>
|
||||||
|
<LedImage Id="Headset1" />
|
||||||
|
</LedImages>
|
||||||
|
</LedImageLayout>
|
||||||
|
<LedImageLayout>
|
||||||
|
<LedImages>
|
||||||
|
<LedImage Id="Headset2" />
|
||||||
|
</LedImages>
|
||||||
|
</LedImageLayout>
|
||||||
|
</LedImageLayouts>
|
||||||
|
</Device>
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<Device xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<Name>Corsair Virtuoso SE</Name>
|
||||||
|
<Description>Physical layout of Corsairs Virtuoso SE</Description>
|
||||||
|
<Type>Headset</Type>
|
||||||
|
<Lighting>Key</Lighting>
|
||||||
|
<Vendor>Corsair</Vendor>
|
||||||
|
<Model>VIRTUOSOSE</Model>
|
||||||
|
<Width>242</Width>
|
||||||
|
<Height>228</Height>
|
||||||
|
<LedUnitWidth>35</LedUnitWidth>
|
||||||
|
<LedUnitHeight>85</LedUnitHeight>
|
||||||
|
<ImageBasePath>Images\Corsair\Headsets</ImageBasePath>
|
||||||
|
<DeviceImage>VOIDRGB.png</DeviceImage>
|
||||||
|
<Leds>
|
||||||
|
<Led Id="Headset1">
|
||||||
|
<Shape>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</Shape>
|
||||||
|
<X>0</X>
|
||||||
|
<Y>105</Y>
|
||||||
|
<Height>1</Height>
|
||||||
|
</Led>
|
||||||
|
<Led Id="Headset2">
|
||||||
|
<Shape>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</Shape>
|
||||||
|
<X>+170</X>
|
||||||
|
</Led>
|
||||||
|
</Leds>
|
||||||
|
<LedImageLayouts>
|
||||||
|
<LedImageLayout>
|
||||||
|
<LedImages>
|
||||||
|
<LedImage Id="Headset1" />
|
||||||
|
</LedImages>
|
||||||
|
</LedImageLayout>
|
||||||
|
<LedImageLayout>
|
||||||
|
<LedImages>
|
||||||
|
<LedImage Id="Headset2" />
|
||||||
|
</LedImages>
|
||||||
|
</LedImageLayout>
|
||||||
|
</LedImageLayouts>
|
||||||
|
</Device>
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<Device xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<Name>Corsair VOID RGB</Name>
|
||||||
|
<Description>Physical layout of Corsairs VOID RGB</Description>
|
||||||
|
<Type>Headset</Type>
|
||||||
|
<Lighting>Key</Lighting>
|
||||||
|
<Vendor>Corsair</Vendor>
|
||||||
|
<Model>VOIDRGB</Model>
|
||||||
|
<Width>242</Width>
|
||||||
|
<Height>228</Height>
|
||||||
|
<LedUnitWidth>35</LedUnitWidth>
|
||||||
|
<LedUnitHeight>85</LedUnitHeight>
|
||||||
|
<ImageBasePath>Images\Corsair\Headsets</ImageBasePath>
|
||||||
|
<DeviceImage>VOIDRGB.png</DeviceImage>
|
||||||
|
<Leds>
|
||||||
|
<Led Id="Headset1">
|
||||||
|
<Shape>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</Shape>
|
||||||
|
<X>0</X>
|
||||||
|
<Y>105</Y>
|
||||||
|
<Height>1</Height>
|
||||||
|
</Led>
|
||||||
|
<Led Id="Headset2">
|
||||||
|
<Shape>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</Shape>
|
||||||
|
<X>+170</X>
|
||||||
|
</Led>
|
||||||
|
</Leds>
|
||||||
|
<LedImageLayouts>
|
||||||
|
<LedImageLayout>
|
||||||
|
<LedImages>
|
||||||
|
<LedImage Id="Headset1" />
|
||||||
|
</LedImages>
|
||||||
|
</LedImageLayout>
|
||||||
|
<LedImageLayout>
|
||||||
|
<LedImages>
|
||||||
|
<LedImage Id="Headset2" />
|
||||||
|
</LedImages>
|
||||||
|
</LedImageLayout>
|
||||||
|
</LedImageLayouts>
|
||||||
|
</Device>
|
||||||
@ -31,6 +31,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
|||||||
MainColorProperty = RegisterLayerProperty<SKColor>("Brush.MainColor", "Main color", "The main color of the noise.");
|
MainColorProperty = RegisterLayerProperty<SKColor>("Brush.MainColor", "Main color", "The main color of the noise.");
|
||||||
SecondaryColorProperty = RegisterLayerProperty<SKColor>("Brush.SecondaryColor", "Secondary color", "The secondary color of the noise.");
|
SecondaryColorProperty = RegisterLayerProperty<SKColor>("Brush.SecondaryColor", "Secondary color", "The secondary color of the noise.");
|
||||||
ScaleProperty = RegisterLayerProperty<SKSize>("Brush.Scale", "Scale", "The scale of the noise.");
|
ScaleProperty = RegisterLayerProperty<SKSize>("Brush.Scale", "Scale", "The scale of the noise.");
|
||||||
|
HardnessProperty = RegisterLayerProperty<float>("Brush.Hardness", "Hardness", "The hardness of the noise, lower means there are gradients in the noise, higher means hard lines..");
|
||||||
ScrollSpeedProperty = RegisterLayerProperty<SKPoint>("Brush.ScrollSpeed", "Movement speed", "The speed at which the noise moves vertically and horizontally.");
|
ScrollSpeedProperty = RegisterLayerProperty<SKPoint>("Brush.ScrollSpeed", "Movement speed", "The speed at which the noise moves vertically and horizontally.");
|
||||||
AnimationSpeedProperty = RegisterLayerProperty<float>("Brush.AnimationSpeed", "Animation speed", "The speed at which the noise moves.");
|
AnimationSpeedProperty = RegisterLayerProperty<float>("Brush.AnimationSpeed", "Animation speed", "The speed at which the noise moves.");
|
||||||
ScaleProperty.InputAffix = "%";
|
ScaleProperty.InputAffix = "%";
|
||||||
@ -41,6 +42,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
|||||||
public LayerProperty<SKColor> MainColorProperty { get; set; }
|
public LayerProperty<SKColor> MainColorProperty { get; set; }
|
||||||
public LayerProperty<SKColor> SecondaryColorProperty { get; set; }
|
public LayerProperty<SKColor> SecondaryColorProperty { get; set; }
|
||||||
public LayerProperty<SKSize> ScaleProperty { get; set; }
|
public LayerProperty<SKSize> ScaleProperty { get; set; }
|
||||||
|
public LayerProperty<float> HardnessProperty { get; set; }
|
||||||
public LayerProperty<SKPoint> ScrollSpeedProperty { get; set; }
|
public LayerProperty<SKPoint> ScrollSpeedProperty { get; set; }
|
||||||
public LayerProperty<float> AnimationSpeedProperty { get; set; }
|
public LayerProperty<float> AnimationSpeedProperty { get; set; }
|
||||||
|
|
||||||
@ -67,30 +69,31 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
|||||||
var mainColor = MainColorProperty.CurrentValue;
|
var mainColor = MainColorProperty.CurrentValue;
|
||||||
var scale = ScaleProperty.CurrentValue;
|
var scale = ScaleProperty.CurrentValue;
|
||||||
var opacity = (float) Math.Round(mainColor.Alpha / 255.0, 2, MidpointRounding.AwayFromZero);
|
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
|
// Scale down the render path to avoid computing a value for every pixel
|
||||||
var width = Math.Floor(path.Bounds.Width * _renderScale);
|
var width = (int) Math.Floor(path.Bounds.Width * _renderScale);
|
||||||
var height = Math.Floor(path.Bounds.Height * _renderScale);
|
var height = (int) Math.Floor(path.Bounds.Height * _renderScale);
|
||||||
|
|
||||||
CreateBitmap((int) width, (int) height);
|
CreateBitmap(width, height);
|
||||||
|
for (var y = 0; y < height; y++)
|
||||||
for (var x = 0; x < width; x++)
|
|
||||||
{
|
{
|
||||||
var scrolledX = x + _x;
|
for (var x = 0; x < width; x++)
|
||||||
for (var y = 0; y < height; y++)
|
|
||||||
{
|
{
|
||||||
|
var scrolledX = x + _x;
|
||||||
var scrolledY = y + _y;
|
var scrolledY = y + _y;
|
||||||
var evalX = 0.1 * scale.Width * scrolledX / width;
|
var evalX = 0.1 * scale.Width * scrolledX / width;
|
||||||
var evalY = 0.1 * scale.Height * scrolledY / height;
|
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;
|
continue;
|
||||||
|
|
||||||
var v = _noise.Evaluate(evalX, evalY, _z);
|
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)));
|
_bitmap.SetPixel(x, y, new SKColor(mainColor.Red, mainColor.Green, mainColor.Blue, (byte) (alpha * opacity)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var bitmapTransform = SKMatrix.Concat(
|
var bitmapTransform = SKMatrix.Concat(
|
||||||
SKMatrix.MakeTranslation(path.Bounds.Left, path.Bounds.Top),
|
SKMatrix.MakeTranslation(path.Bounds.Left, path.Bounds.Top),
|
||||||
SKMatrix.MakeScale(1f / _renderScale, 1f / _renderScale)
|
SKMatrix.MakeScale(1f / _renderScale, 1f / _renderScale)
|
||||||
@ -106,6 +109,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void DetermineRenderScale()
|
private void DetermineRenderScale()
|
||||||
{
|
{
|
||||||
_renderScale = (float) (0.125f / _rgbService.RenderScale);
|
_renderScale = (float) (0.125f / _rgbService.RenderScale);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user