mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Made devices aware of the plugin that loaded them
Fixed Corsair LL Fans layout Expanded render events Added identify option to device settings, must move this to be reusable though
This commit is contained in:
1 parent
af2612f294
commit
6ebceacd13
23 files changed
+400
-229
No files matched your search
@@ -1,17 +1,20 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Plugins.Modules.General.ViewModels;
|
||||
using Stylet;
|
||||
using Device = Artemis.Core.Models.Surface.Device;
|
||||
|
||||
namespace Artemis.Plugins.Modules.General
|
||||
{
|
||||
public class GeneralModule : Module
|
||||
{
|
||||
private readonly PluginSettings _settings;
|
||||
private readonly ColorBlend _rainbowColorBlend;
|
||||
|
||||
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo)
|
||||
{
|
||||
@@ -24,9 +27,20 @@ namespace Artemis.Plugins.Modules.General
|
||||
Hues = new int[1000];
|
||||
for (var i = 0; i < 1000; i++)
|
||||
Hues[i] = ColorHelpers.GetRandomHue();
|
||||
|
||||
_rainbowColorBlend = new ColorBlend(9);
|
||||
for (var i = 0; i < 9; i++)
|
||||
{
|
||||
_rainbowColorBlend.Positions[i] = i / 8f;
|
||||
if (i != 8)
|
||||
_rainbowColorBlend.Colors[i] = ColorHelpers.ColorFromHSV(i * 32, 1, 1);
|
||||
else
|
||||
_rainbowColorBlend.Colors[i] = ColorHelpers.ColorFromHSV(0, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public int[] Hues { get; set; }
|
||||
public int MovePercentage { get; set; }
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
@@ -44,15 +58,20 @@ namespace Artemis.Plugins.Modules.General
|
||||
if (Hues[i] > 360)
|
||||
Hues[i] = 0;
|
||||
}
|
||||
|
||||
MovePercentage++;
|
||||
if (MovePercentage > 100)
|
||||
MovePercentage = 0;
|
||||
}
|
||||
|
||||
|
||||
public override void Render(double deltaTime, Surface surface, Graphics graphics)
|
||||
{
|
||||
// Per-device coloring, slower
|
||||
RenderPerDevice(surface, graphics);
|
||||
// RenderPerDevice(surface, graphics);
|
||||
|
||||
// Per-LED coloring, slowest
|
||||
// RenderPerLed(surface, graphics);
|
||||
RenderPerLed(surface, graphics);
|
||||
}
|
||||
|
||||
public void RenderFullSurface(Surface surface, Graphics graphics)
|
||||
@@ -61,14 +80,34 @@ namespace Artemis.Plugins.Modules.General
|
||||
|
||||
public void RenderPerDevice(Surface surface, Graphics graphics)
|
||||
{
|
||||
var index = 0;
|
||||
foreach (var device in surface.Devices)
|
||||
{
|
||||
graphics.FillRectangle(new SolidBrush(ColorHelpers.ColorFromHSV(Hues[index], 1, 1)), device.RenderRectangle);
|
||||
index++;
|
||||
using (var gradient = RenderGradientForDevice(device))
|
||||
{
|
||||
using (var brush = new TextureBrush(gradient, WrapMode.Tile))
|
||||
{
|
||||
brush.TranslateTransform((int) Math.Round(device.RenderRectangle.Width / 100.0 * MovePercentage), 0);
|
||||
graphics.FillPath(brush, device.RenderPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Image RenderGradientForDevice(Device device)
|
||||
{
|
||||
var brush = new LinearGradientBrush(device.RenderRectangle, Color.Black, Color.Black, 0, false)
|
||||
{
|
||||
InterpolationColors = _rainbowColorBlend
|
||||
};
|
||||
var bitmap = new Bitmap(device.RenderRectangle.Width, device.RenderRectangle.Height);
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.FillRectangle(brush, 0, 0, device.RenderRectangle.Width, device.RenderRectangle.Height);
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public void RenderPerLed(Surface surface, Graphics graphics)
|
||||
{
|
||||
var index = 0;
|
||||
|
||||
Reference in new issue
Block a user