mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Color brush - Added configurable gradient repeat
Color brush - Fixed gradient positioning in the clip render mode Color brush - Added gradient tile modes in clip render mode Layer properties - Allow disabling support of keyframes via the description decorator
This commit is contained in:
1 parent
aa7c914b92
commit
b659be1f48
8 files changed
+86
-19
No files matched your search
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Documents;
|
||||
using Artemis.Core.Annotations;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
@@ -30,14 +32,37 @@ namespace Artemis.Core.Models.Profile.Colors
|
||||
}
|
||||
}
|
||||
|
||||
public SKColor[] GetColorsArray()
|
||||
public SKColor[] GetColorsArray(int timesToRepeat = 0)
|
||||
{
|
||||
return Stops.OrderBy(c => c.Position).Select(c => c.Color).ToArray();
|
||||
if (timesToRepeat == 0)
|
||||
return Stops.OrderBy(c => c.Position).Select(c => c.Color).ToArray();
|
||||
|
||||
var colors = Stops.OrderBy(c => c.Position).Select(c => c.Color).ToList();
|
||||
var result = new List<SKColor>();
|
||||
|
||||
for (var i = 0; i <= timesToRepeat; i++)
|
||||
result.AddRange(colors);
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public float[] GetPositionsArray()
|
||||
public float[] GetPositionsArray(int timesToRepeat = 0)
|
||||
{
|
||||
return Stops.OrderBy(c => c.Position).Select(c => c.Position).ToArray();
|
||||
if (timesToRepeat == 0)
|
||||
return Stops.OrderBy(c => c.Position).Select(c => c.Position).ToArray();
|
||||
|
||||
// Create stops and a list of divided stops
|
||||
var stops = Stops.OrderBy(c => c.Position).Select(c => c.Position / (timesToRepeat + 1)).ToList();
|
||||
var result = new List<float>();
|
||||
|
||||
// For each repeat cycle, add the base stops to the end result
|
||||
for (var i = 0; i <= timesToRepeat; i++)
|
||||
{
|
||||
var localStops = stops.Select(s => s + result.LastOrDefault()).ToList();
|
||||
result.AddRange(localStops);
|
||||
}
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public void OnColorValuesUpdated()
|
||||
|
||||
@@ -334,6 +334,7 @@ namespace Artemis.Core.Models.Profile
|
||||
if (Parent is Folder parentFolder)
|
||||
targetLocation = Path.Bounds.Location - parentFolder.Path.Bounds.Location;
|
||||
|
||||
|
||||
canvas.DrawBitmap(_layerBitmap, targetLocation, layerPaint);
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -38,5 +38,10 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Attributes
|
||||
/// Maximum input value, only enforced in the UI
|
||||
/// </summary>
|
||||
public object MaxInputValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not keyframes are supported, true by default and cannot be changed at runtime
|
||||
/// </summary>
|
||||
public bool KeyframesSupported { get; set; } = true;
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,9 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
||||
public LayerPropertyGroup Parent { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether keyframes are supported on this property
|
||||
/// Gets whether keyframes are supported on this type of property
|
||||
/// </summary>
|
||||
public bool KeyframesSupported { get; protected set; } = true;
|
||||
public bool KeyframesSupported { get; protected internal set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether keyframes are enabled on this property, has no effect if <see cref="KeyframesSupported" /> is
|
||||
|
||||
@@ -156,6 +156,7 @@ namespace Artemis.Core.Models.Profile
|
||||
instance.ProfileElement = profileElement;
|
||||
instance.Parent = this;
|
||||
instance.PropertyDescription = (PropertyDescriptionAttribute) propertyDescription;
|
||||
instance.KeyframesSupported = instance.PropertyDescription.KeyframesSupported;
|
||||
InitializeProperty(profileElement, path + propertyInfo.Name, instance);
|
||||
|
||||
propertyInfo.SetValue(this, instance);
|
||||
|
||||
@@ -27,9 +27,10 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
|
||||
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
|
||||
// We don't want translations on this canvas because that'll displace the LEDs, translations are applied to the points of each LED instead
|
||||
Layer.ExcludeCanvasFromTranslation(canvas, true);
|
||||
|
||||
// Apply a translated version of the shape as the clipping mask
|
||||
var shapePath = new SKPath(Layer.LayerShape.Path);
|
||||
Layer.IncludePathInTranslation(shapePath, true);
|
||||
canvas.ClipPath(shapePath);
|
||||
|
||||
Reference in new issue
Block a user