mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Added a debugger, ironed out rendering pipeline
This commit is contained in:
1 parent
4add877156
commit
93cd704c6c
15 files changed
+321
-35
No files matched your search
@@ -3,32 +3,30 @@ using System.Drawing;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Plugins.Modules.General.ViewModels;
|
||||
using RGB.NET.Core;
|
||||
using Stylet;
|
||||
using Color = System.Drawing.Color;
|
||||
using Rectangle = System.Drawing.Rectangle;
|
||||
|
||||
namespace Artemis.Plugins.Modules.General
|
||||
{
|
||||
public class GeneralModule : Module
|
||||
{
|
||||
private readonly PluginSettings _settings;
|
||||
private readonly RGBSurface _surface;
|
||||
private Color _color;
|
||||
|
||||
public GeneralModule(PluginInfo pluginInfo, IRgbService rgbService, PluginSettings settings) : base(pluginInfo)
|
||||
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo)
|
||||
{
|
||||
_settings = settings;
|
||||
DisplayName = "General";
|
||||
ExpandsMainDataModel = true;
|
||||
|
||||
_surface = rgbService.Surface;
|
||||
|
||||
var testSetting = _settings.GetSetting("TestSetting", DateTime.Now);
|
||||
_color = ColorHelpers.GetRandomRainbowColor();
|
||||
Colors = new Color[1000];
|
||||
}
|
||||
|
||||
public Color[] Colors { get; set; }
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
}
|
||||
@@ -39,16 +37,59 @@ namespace Artemis.Plugins.Modules.General
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
_color = ColorHelpers.ShiftColor(_color, (int) (deltaTime * 200));
|
||||
for (var i = 0; i < Colors.Length; i++)
|
||||
{
|
||||
var color = Colors[i];
|
||||
Colors[i] = ColorHelpers.ShiftColor(color, (int) (deltaTime * 200));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Render(double deltaTime, RGBSurface surface, Graphics graphics)
|
||||
{
|
||||
// Lets do this in the least performant way possible
|
||||
foreach (var surfaceLed in _surface.Leds)
|
||||
// Per-device coloring, slower
|
||||
// RenderPerDevice(surface, graphics);
|
||||
|
||||
// Per-LED coloring, slowest
|
||||
RenderPerLed(surface, graphics);
|
||||
}
|
||||
|
||||
public void RenderFullSurface(RGBSurface surface, Graphics graphics)
|
||||
{
|
||||
}
|
||||
|
||||
public void RenderPerDevice(RGBSurface surface, Graphics graphics)
|
||||
{
|
||||
var index = 0;
|
||||
foreach (var device in surface.Devices)
|
||||
{
|
||||
var rectangle = surfaceLed.AbsoluteLedRectangle.ToDrawingRectangle();
|
||||
graphics.FillRectangle(new SolidBrush(_color), rectangle);
|
||||
var color = Colors[index];
|
||||
if (color.A == 0)
|
||||
{
|
||||
color = ColorHelpers.GetRandomRainbowColor();
|
||||
Colors[index] = color;
|
||||
}
|
||||
|
||||
var rectangle = new Rectangle((int) device.Location.X, (int) device.Location.Y, (int) device.Size.Width, (int) device.Size.Height);
|
||||
graphics.FillRectangle(new SolidBrush(color), rectangle);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderPerLed(RGBSurface surface, Graphics graphics)
|
||||
{
|
||||
var index = 0;
|
||||
foreach (var led in surface.Leds)
|
||||
{
|
||||
var color = Colors[index];
|
||||
if (color.A == 0)
|
||||
{
|
||||
color = ColorHelpers.GetRandomRainbowColor();
|
||||
Colors[index] = color;
|
||||
}
|
||||
|
||||
var rectangle = led.AbsoluteLedRectangle.ToDrawingRectangle();
|
||||
graphics.FillRectangle(new SolidBrush(color), rectangle);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user