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:
SpoinkyNL committed 2020-02-17 20:46:27 +01:00
1 parent 4b1b0248f5
commit 1d81b782da
9 files changed
+151 -18

No files matched your search

+4 -2
View File
@@ -67,8 +67,8 @@ namespace Artemis.Core.Models.Profile
public ReadOnlyCollection<ArtemisLed> Leds => _leds.AsReadOnly();
/// <summary>
/// A path containing all the LEDs this layer is applied to, any rendering outside the layer Path is clipped.
/// <para>For rendering, use the Path on <see cref="LayerShape" />.</para>
/// Gets a copy of the path containing all the LEDs this layer is applied to, any rendering outside the layer Path is
/// clipped.
/// </summary>
public SKPath Path
{
@@ -211,6 +211,7 @@ namespace Artemis.Core.Models.Profile
#region Rendering
/// <inheritdoc />
public override void Update(double deltaTime)
{
foreach (var property in Properties)
@@ -231,6 +232,7 @@ namespace Artemis.Core.Models.Profile
LayerBrush?.Update(deltaTime);
}
/// <inheritdoc />
public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo)
{
if (Path == null || LayerShape?.Path == null)
@@ -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; }
/// <summary>
/// A path outlining the shape
/// Gets a copy of the path outlining the shape
/// </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();
}
@@ -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="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="defaultValue">The default value of the property, if not configured by the user</param>
/// <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);
// 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
/// <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="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>
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>(
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);
+3 -1
View File
@@ -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;