mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Code style - Use file scoped namespaces
Code style - Ran code cleanup
This commit is contained in:
1 parent
e68e16df4d
commit
f6090dc296
691 files changed
+37301
-38119
No files matched your search
@@ -1,84 +1,80 @@
|
||||
using System;
|
||||
using SkiaSharp;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.LayerBrushes
|
||||
namespace Artemis.Core.LayerBrushes;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a brush that renders on a per-layer basis
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of brush properties</typeparam>
|
||||
public abstract class PerLedLayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a brush that renders on a per-layer basis
|
||||
/// Creates a new instance of the <see cref="PerLedLayerBrush{T}" /> class
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of brush properties</typeparam>
|
||||
public abstract class PerLedLayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup, new()
|
||||
protected PerLedLayerBrush()
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="PerLedLayerBrush{T}" /> class
|
||||
/// </summary>
|
||||
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, SKRect bounds, SKPaint paint)
|
||||
{
|
||||
// We don't want rotation on this canvas because that'll displace the LEDs, translations are applied to the points of each LED instead
|
||||
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
|
||||
canvas.SetMatrix(canvas.TotalMatrix.PreConcat(Layer.GetTransformMatrix(true, false, false, true).Invert()));
|
||||
|
||||
using SKPath pointsPath = new();
|
||||
foreach (ArtemisLed artemisLed in Layer.Leds)
|
||||
{
|
||||
BrushType = LayerBrushType.Regular;
|
||||
pointsPath.AddPoly(new[]
|
||||
{
|
||||
new SKPoint(0, 0),
|
||||
new SKPoint(artemisLed.AbsoluteRectangle.Left - Layer.Bounds.Left, artemisLed.AbsoluteRectangle.Top - Layer.Bounds.Top)
|
||||
});
|
||||
}
|
||||
|
||||
/// <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);
|
||||
// Apply the translation to the points of each LED instead
|
||||
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
|
||||
pointsPath.Transform(Layer.GetTransformMatrix(true, true, true, true).Invert());
|
||||
|
||||
internal override void InternalRender(SKCanvas canvas, SKRect bounds, SKPaint paint)
|
||||
SKPoint[] points = pointsPath.Points;
|
||||
|
||||
TryOrBreak(() =>
|
||||
{
|
||||
// We don't want rotation on this canvas because that'll displace the LEDs, translations are applied to the points of each LED instead
|
||||
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
|
||||
canvas.SetMatrix(canvas.TotalMatrix.PreConcat(Layer.GetTransformMatrix(true, false, false, true).Invert()));
|
||||
|
||||
using SKPath pointsPath = new();
|
||||
foreach (ArtemisLed artemisLed in Layer.Leds)
|
||||
for (int index = 0; index < Layer.Leds.Count; index++)
|
||||
{
|
||||
pointsPath.AddPoly(new[]
|
||||
{
|
||||
new SKPoint(0, 0),
|
||||
new SKPoint(artemisLed.AbsoluteRectangle.Left - Layer.Bounds.Left, artemisLed.AbsoluteRectangle.Top - Layer.Bounds.Top)
|
||||
});
|
||||
ArtemisLed artemisLed = Layer.Leds[index];
|
||||
SKPoint renderPoint = points[index * 2 + 1];
|
||||
if (!float.IsFinite(renderPoint.X) || !float.IsFinite(renderPoint.Y))
|
||||
continue;
|
||||
|
||||
// Let the brush determine the color
|
||||
paint.Color = GetColor(artemisLed, renderPoint);
|
||||
SKRect ledRectangle = SKRect.Create(
|
||||
artemisLed.AbsoluteRectangle.Left - Layer.Bounds.Left,
|
||||
artemisLed.AbsoluteRectangle.Top - Layer.Bounds.Top,
|
||||
artemisLed.AbsoluteRectangle.Width,
|
||||
artemisLed.AbsoluteRectangle.Height
|
||||
);
|
||||
|
||||
canvas.DrawRect(ledRectangle, paint);
|
||||
}
|
||||
}, "Failed to render");
|
||||
}
|
||||
|
||||
// Apply the translation to the points of each LED instead
|
||||
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
|
||||
pointsPath.Transform(Layer.GetTransformMatrix(true, true, true, true).Invert());
|
||||
|
||||
SKPoint[] points = pointsPath.Points;
|
||||
|
||||
TryOrBreak(() =>
|
||||
{
|
||||
|
||||
|
||||
for (int index = 0; index < Layer.Leds.Count; index++)
|
||||
{
|
||||
ArtemisLed artemisLed = Layer.Leds[index];
|
||||
SKPoint renderPoint = points[index * 2 + 1];
|
||||
if (!float.IsFinite(renderPoint.X) || !float.IsFinite(renderPoint.Y))
|
||||
continue;
|
||||
|
||||
// Let the brush determine the color
|
||||
paint.Color = GetColor(artemisLed, renderPoint);
|
||||
SKRect ledRectangle = SKRect.Create(
|
||||
artemisLed.AbsoluteRectangle.Left - Layer.Bounds.Left,
|
||||
artemisLed.AbsoluteRectangle.Top - Layer.Bounds.Top,
|
||||
artemisLed.AbsoluteRectangle.Width,
|
||||
artemisLed.AbsoluteRectangle.Height
|
||||
);
|
||||
|
||||
canvas.DrawRect(ledRectangle, paint);
|
||||
}
|
||||
}, "Failed to render");
|
||||
}
|
||||
|
||||
internal override void Initialize()
|
||||
{
|
||||
TryOrBreak(InitializeProperties, "Failed to initialize");
|
||||
}
|
||||
internal override void Initialize()
|
||||
{
|
||||
TryOrBreak(InitializeProperties, "Failed to initialize");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user