mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
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:
1 parent
f36049a0e1
commit
29489fe7b3
29 files changed
+767
-277
No files matched your search
@@ -0,0 +1,74 @@
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
{
|
||||
public abstract class PerLedLayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup
|
||||
{
|
||||
protected PerLedLayerBrush()
|
||||
{
|
||||
BrushType = LayerBrushType.Regular;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The main method of rendering for this type of brush. Called once per frame for each LED in the layer
|
||||
/// <para>
|
||||
/// Note: Due to transformations, the render point may not match the position of the LED, always use the render
|
||||
/// point to determine where the color will go.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="led">The LED that will receive the color</param>
|
||||
/// <param name="renderPoint">The point at which the color is located</param>
|
||||
/// <returns>The color the LED will receive</returns>
|
||||
public abstract SKColor GetColor(ArtemisLed led, SKPoint renderPoint);
|
||||
|
||||
internal override void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
{
|
||||
// This lil' snippet renders per LED, it's neater but doesn't support translations
|
||||
Layer.ExcludeCanvasFromTranslation(canvas, true);
|
||||
|
||||
var shapePath = new SKPath(Layer.LayerShape.Path);
|
||||
Layer.IncludePathInTranslation(shapePath, true);
|
||||
canvas.ClipPath(shapePath);
|
||||
|
||||
using var pointsPath = new SKPath();
|
||||
using var ledPaint = new SKPaint();
|
||||
foreach (var artemisLed in Layer.Leds)
|
||||
{
|
||||
pointsPath.AddPoly(new[]
|
||||
{
|
||||
new SKPoint(0, 0),
|
||||
new SKPoint(artemisLed.AbsoluteRenderRectangle.Left - Layer.Bounds.Left, artemisLed.AbsoluteRenderRectangle.Top - Layer.Bounds.Top)
|
||||
});
|
||||
}
|
||||
|
||||
Layer.ExcludePathFromTranslation(pointsPath, true);
|
||||
var points = pointsPath.Points;
|
||||
for (var index = 0; index < Layer.Leds.Count; index++)
|
||||
{
|
||||
var artemisLed = Layer.Leds[index];
|
||||
var renderPoint = points[index * 2 + 1];
|
||||
|
||||
// Let the brush determine the color
|
||||
ledPaint.Color = GetColor(artemisLed, renderPoint);
|
||||
|
||||
var ledRectangle = SKRect.Create(
|
||||
artemisLed.AbsoluteRenderRectangle.Left - Layer.Bounds.Left,
|
||||
artemisLed.AbsoluteRenderRectangle.Top - Layer.Bounds.Top,
|
||||
artemisLed.AbsoluteRenderRectangle.Width,
|
||||
artemisLed.AbsoluteRenderRectangle.Height
|
||||
);
|
||||
|
||||
canvas.DrawRect(ledRectangle, ledPaint);
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Initialize(IRenderElementService renderElementService)
|
||||
{
|
||||
InitializeProperties(renderElementService);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user