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:
SpoinkyNL committed 2020-08-02 00:20:25 +02:00
1 parent f36049a0e1
commit 29489fe7b3
29 files changed
+767 -277

No files matched your search

@@ -124,7 +124,8 @@ namespace Artemis.Core.Models.Profile.Conditions
StaticConditionLambda = null;
CompiledStaticConditionLambda = null;
if (PredicateType == PredicateType.Dynamic)
// If the operator does not support a right side, create a static expression because the right side will simply be null
if (PredicateType == PredicateType.Dynamic && Operator.SupportsRightSide)
CreateDynamicExpression();
CreateStaticExpression();
@@ -156,8 +156,10 @@ namespace Artemis.Core.Models.Profile
// Iterate the children in reverse because the first layer must be rendered last to end up on top
for (var index = Children.Count - 1; index > -1; index--)
{
folderCanvas.Save();
var profileElement = Children[index];
profileElement.Render(deltaTime, folderCanvas, _folderBitmap.Info);
folderCanvas.Restore();
}
var targetLocation = Path.Bounds.Location;
+71 -6
View File
@@ -425,12 +425,14 @@ namespace Artemis.Core.Models.Profile
OnRenderPropertiesUpdated();
}
internal SKPoint GetLayerAnchorPosition(SKPath layerPath)
internal SKPoint GetLayerAnchorPosition(SKPath layerPath, bool zeroBased = false)
{
var positionProperty = Transform.Position.CurrentValue;
// Start at the center of the shape
var position = new SKPoint(layerPath.Bounds.MidX, layerPath.Bounds.MidY);
var position = zeroBased
? new SKPoint(layerPath.Bounds.MidX - layerPath.Bounds.Left, layerPath.Bounds.MidY - layerPath.Bounds.Top)
: new SKPoint(layerPath.Bounds.MidX, layerPath.Bounds.MidY);
// Apply translation
position.X += positionProperty.X * layerPath.Bounds.Width;
@@ -444,17 +446,46 @@ namespace Artemis.Core.Models.Profile
/// layer translations out
/// </summary>
/// <param name="path"></param>
public void ExcludePathFromTranslation(SKPath path)
public void IncludePathInTranslation(SKPath path, bool zeroBased)
{
var sizeProperty = Transform.Scale.CurrentValue;
var rotationProperty = Transform.Rotation.CurrentValue;
var anchorPosition = GetLayerAnchorPosition(Path);
var anchorPosition = GetLayerAnchorPosition(Path, zeroBased);
var anchorProperty = Transform.AnchorPoint.CurrentValue;
// Translation originates from the unscaled center of the shape and is tied to the anchor
var x = anchorPosition.X - Bounds.MidX - anchorProperty.X * Bounds.Width;
var y = anchorPosition.Y - Bounds.MidY - anchorProperty.Y * Bounds.Height;
var x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width;
var y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height;
if (General.FillType == LayerFillType.Stretch)
{
path.Transform(SKMatrix.MakeTranslation(x, y));
path.Transform(SKMatrix.MakeScale((sizeProperty.Width / 100f), (sizeProperty.Height / 100f), anchorPosition.X, anchorPosition.Y));
path.Transform(SKMatrix.MakeRotationDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y));
}
else
{
path.Transform(SKMatrix.MakeTranslation(x, y));
path.Transform(SKMatrix.MakeRotationDegrees(rotationProperty * -1, anchorPosition.X, anchorPosition.Y));
}
}
/// <summary>
/// Excludes the provided path from the translations applied to the layer by applying translations that cancel the
/// layer translations out
/// </summary>
public void ExcludePathFromTranslation(SKPath path, bool zeroBased)
{
var sizeProperty = Transform.Scale.CurrentValue;
var rotationProperty = Transform.Rotation.CurrentValue;
var anchorPosition = GetLayerAnchorPosition(Path, zeroBased);
var anchorProperty = Transform.AnchorPoint.CurrentValue;
// Translation originates from the unscaled center of the shape and is tied to the anchor
var x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width;
var y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height;
var reversedXScale = 1f / (sizeProperty.Width / 100f);
var reversedYScale = 1f / (sizeProperty.Height / 100f);
@@ -472,6 +503,40 @@ namespace Artemis.Core.Models.Profile
}
}
/// <summary>
/// Excludes the provided canvas from the translations applied to the layer by applying translations that cancel the
/// layer translations out
/// </summary>
/// <returns>The number of transformations applied</returns>
public int ExcludeCanvasFromTranslation(SKCanvas canvas, bool zeroBased)
{
var sizeProperty = Transform.Scale.CurrentValue;
var rotationProperty = Transform.Rotation.CurrentValue;
var anchorPosition = GetLayerAnchorPosition(Path, zeroBased);
var anchorProperty = Transform.AnchorPoint.CurrentValue;
// Translation originates from the unscaled center of the shape and is tied to the anchor
var x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width;
var y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height;
var reversedXScale = 1f / (sizeProperty.Width / 100f);
var reversedYScale = 1f / (sizeProperty.Height / 100f);
if (General.FillType == LayerFillType.Stretch)
{
canvas.Translate(x * -1, y * -1);
canvas.Scale(reversedXScale, reversedYScale, anchorPosition.X, anchorPosition.Y);
canvas.RotateDegrees(rotationProperty * -1, anchorPosition.X, anchorPosition.Y);
return 3;
}
canvas.RotateDegrees(rotationProperty * -1, anchorPosition.X, anchorPosition.Y);
canvas.Translate(x * -1, y * -1);
return 2;
}
#endregion
#region LED management
@@ -30,7 +30,7 @@ namespace Artemis.Core.Plugins.Abstract
protected void ResolveAbsolutePath(Type type, object sender, ResolvePathEventArgs e)
{
if (sender.GetType().IsGenericType(type))
if (sender.GetType() == type || sender.GetType().IsGenericType(type))
{
// Start from the plugin directory
if (e.RelativePart != null && e.FileName != null)
@@ -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);
}
}
}