mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Added GDI-based rendering test
This commit is contained in:
1 parent
dd82a945ef
commit
e6f5dde7f7
21 files changed
+382
-111
No files matched your search
@@ -57,8 +57,8 @@
|
||||
<Reference Include="CSScriptLibrary, Version=3.28.2.0, Culture=neutral, PublicKeyToken=70fcc3d18c749033, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CS-Script.bin.3.28.2.0\lib\net46\CSScriptLibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HidSharp, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HidSharp.1.5\lib\net35\HidSharp.dll</HintPath>
|
||||
<Reference Include="HidSharp, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HidSharp.2.0.1\lib\net35\HidSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.2.7.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
|
||||
@@ -118,40 +118,40 @@
|
||||
<HintPath>..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Brushes, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Brushes.0.0.1.49\lib\net45\RGB.NET.Brushes.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Brushes.0.0.1.51\lib\net45\RGB.NET.Brushes.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Core, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Core.0.0.1.49\lib\net45\RGB.NET.Core.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Core.0.0.1.51\lib\net45\RGB.NET.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Decorators, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Decorators.0.0.1.49\lib\net45\RGB.NET.Decorators.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Decorators.0.0.1.51\lib\net45\RGB.NET.Decorators.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.Asus, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Devices.Asus.0.0.1.49\lib\net45\RGB.NET.Devices.Asus.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Devices.Asus.0.0.1.51\lib\net45\RGB.NET.Devices.Asus.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.CoolerMaster, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Devices.CoolerMaster.0.0.1.49\lib\net45\RGB.NET.Devices.CoolerMaster.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Devices.CoolerMaster.0.0.1.51\lib\net45\RGB.NET.Devices.CoolerMaster.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.Corsair, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Devices.Corsair.0.0.1.49\lib\net45\RGB.NET.Devices.Corsair.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Devices.Corsair.0.0.1.51\lib\net45\RGB.NET.Devices.Corsair.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.DMX, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Devices.DMX.0.0.1.49\lib\net45\RGB.NET.Devices.DMX.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Devices.DMX.0.0.1.51\lib\net45\RGB.NET.Devices.DMX.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.Logitech, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Devices.Logitech.0.0.1.49\lib\net45\RGB.NET.Devices.Logitech.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Devices.Logitech.0.0.1.51\lib\net45\RGB.NET.Devices.Logitech.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.Novation, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Devices.Novation.0.0.1.49\lib\net45\RGB.NET.Devices.Novation.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Devices.Novation.0.0.1.51\lib\net45\RGB.NET.Devices.Novation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.Razer, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Devices.Razer.0.0.1.49\lib\net45\RGB.NET.Devices.Razer.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Devices.Razer.0.0.1.51\lib\net45\RGB.NET.Devices.Razer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Groups, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Groups.0.0.1.49\lib\net45\RGB.NET.Groups.dll</HintPath>
|
||||
<HintPath>..\packages\RGB.NET.Groups.0.0.1.51\lib\net45\RGB.NET.Groups.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Sanford.Multimedia.Midi, Version=6.6.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Sanford.Multimedia.Midi.6.6.0\lib\net20\Sanford.Multimedia.Midi.dll</HintPath>
|
||||
<HintPath>..\packages\Sanford.Multimedia.Midi.Standard.6.6.0\lib\net35\Sanford.Multimedia.Midi.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Stylet, Version=1.1.21.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Stylet.1.1.21\lib\net45\Stylet.dll</HintPath>
|
||||
@@ -186,6 +186,7 @@
|
||||
<HintPath>..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Interactive.Async, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net46\System.Interactive.Async.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -282,6 +283,8 @@
|
||||
<Compile Include="ProfileElements\Profile.cs" />
|
||||
<Compile Include="Ninject\CoreModule.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RGB.NET\DirectBitmap.cs" />
|
||||
<Compile Include="RGB.NET\GraphicsDecorator.cs" />
|
||||
<Compile Include="Services\Interfaces\IMainDataModelService.cs" />
|
||||
<Compile Include="Services\CoreService.cs" />
|
||||
<Compile Include="Services\MainDataModelService.cs" />
|
||||
@@ -293,6 +296,7 @@
|
||||
<Compile Include="Events\PluginEventArgs.cs" />
|
||||
<Compile Include="Services\PluginService.cs" />
|
||||
<Compile Include="Services\StorageService.cs" />
|
||||
<Compile Include="UtilitiesRemoveMe.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using Artemis.Core.Plugins.Interfaces;
|
||||
using Artemis.Core.ProfileElements;
|
||||
using RGB.NET.Core;
|
||||
@@ -46,12 +47,12 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void Render(double deltaTime, RGBSurface surface)
|
||||
public virtual void Render(double deltaTime, RGBSurface surface, Graphics graphics)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
// Render the profile
|
||||
ActiveProfile?.Render(deltaTime, surface);
|
||||
ActiveProfile?.Render(deltaTime, surface, graphics);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Artemis.Core.ProfileElements;
|
||||
using System.Drawing;
|
||||
using Artemis.Core.ProfileElements;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.Plugins.Interfaces
|
||||
@@ -18,6 +19,6 @@ namespace Artemis.Core.Plugins.Interfaces
|
||||
/// <summary>
|
||||
/// Renders the layer type
|
||||
/// </summary>
|
||||
void Render(Layer device, RGBSurface surface);
|
||||
void Render(Layer device, RGBSurface surface, Graphics graphics);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.Plugins.Interfaces
|
||||
@@ -31,6 +32,7 @@ namespace Artemis.Core.Plugins.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Time since the last render</param>
|
||||
/// <param name="surface">The RGB Surface to render to</param>
|
||||
void Render(double deltaTime, RGBSurface surface);
|
||||
/// <param name="graphics"></param>
|
||||
void Render(double deltaTime, RGBSurface surface, Graphics graphics);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using Artemis.Core.ProfileElements.Interfaces;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Entities;
|
||||
@@ -26,11 +27,11 @@ namespace Artemis.Core.ProfileElements
|
||||
profileElement.Update(deltaTime);
|
||||
}
|
||||
|
||||
public void Render(double deltaTime, RGBSurface surface)
|
||||
public void Render(double deltaTime, RGBSurface surface, Graphics graphics)
|
||||
{
|
||||
// Folders don't render but their children do
|
||||
foreach (var profileElement in Children)
|
||||
profileElement.Render(deltaTime, surface);
|
||||
profileElement.Render(deltaTime, surface, graphics);
|
||||
}
|
||||
|
||||
public static Folder FromFolderEntity(Profile profile, FolderEntity folderEntity, IPluginService pluginService)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.ProfileElements.Interfaces
|
||||
@@ -29,6 +30,6 @@ namespace Artemis.Core.ProfileElements.Interfaces
|
||||
/// <summary>
|
||||
/// Renders the element
|
||||
/// </summary>
|
||||
void Render(double deltaTime, RGBSurface surface);
|
||||
void Render(double deltaTime, RGBSurface surface, Graphics graphics);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using Artemis.Core.Plugins.Interfaces;
|
||||
using Artemis.Core.ProfileElements.Interfaces;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
@@ -34,14 +35,14 @@ namespace Artemis.Core.ProfileElements
|
||||
}
|
||||
}
|
||||
|
||||
public void Render(double deltaTime, RGBSurface surface)
|
||||
public void Render(double deltaTime, RGBSurface surface, Graphics graphics)
|
||||
{
|
||||
if (LayerType == null)
|
||||
return;
|
||||
|
||||
lock (LayerType)
|
||||
{
|
||||
LayerType.Render(this, surface);
|
||||
LayerType.Render(this, surface, graphics);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.ProfileElements.Interfaces;
|
||||
@@ -34,7 +35,7 @@ namespace Artemis.Core.ProfileElements
|
||||
}
|
||||
}
|
||||
|
||||
public void Render(double deltaTime, RGBSurface surface)
|
||||
public void Render(double deltaTime, RGBSurface surface, Graphics graphics)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
@@ -42,7 +43,7 @@ namespace Artemis.Core.ProfileElements
|
||||
throw new ArtemisCoreException($"Cannot render inactive profile: {this}");
|
||||
|
||||
foreach (var profileElement in Children)
|
||||
profileElement.Render(deltaTime, surface);
|
||||
profileElement.Render(deltaTime, surface, graphics);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Artemis.Core.RGB.NET
|
||||
{
|
||||
public class DirectBitmap : IDisposable
|
||||
{
|
||||
public Bitmap Bitmap { get; private set; }
|
||||
public Int32[] Bits { get; private set; }
|
||||
public bool Disposed { get; private set; }
|
||||
public int Height { get; private set; }
|
||||
public int Width { get; private set; }
|
||||
|
||||
protected GCHandle BitsHandle { get; private set; }
|
||||
|
||||
public DirectBitmap(int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
Bits = new Int32[width * height];
|
||||
BitsHandle = GCHandle.Alloc(Bits, GCHandleType.Pinned);
|
||||
Bitmap = new Bitmap(width, height, width * 4, PixelFormat.Format32bppPArgb, BitsHandle.AddrOfPinnedObject());
|
||||
}
|
||||
|
||||
public void SetPixel(int x, int y, Color colour)
|
||||
{
|
||||
int index = x + (y * Width);
|
||||
int col = colour.ToArgb();
|
||||
|
||||
Bits[index] = col;
|
||||
}
|
||||
|
||||
public Color GetPixel(int x, int y)
|
||||
{
|
||||
int index = x + (y * Width);
|
||||
int col = Bits[index];
|
||||
Color result = Color.FromArgb(col);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Disposed) return;
|
||||
Disposed = true;
|
||||
Bitmap.Dispose();
|
||||
BitsHandle.Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Groups;
|
||||
using Color = RGB.NET.Core.Color;
|
||||
using Rectangle = RGB.NET.Core.Rectangle;
|
||||
|
||||
namespace Artemis.Core.RGB.NET
|
||||
{
|
||||
public class GraphicsDecorator : AbstractDecorator, IBrushDecorator
|
||||
{
|
||||
private readonly DirectBitmap _bitmap;
|
||||
|
||||
public GraphicsDecorator(ListLedGroup ledGroup)
|
||||
{
|
||||
// var width = ledGroup.GetLeds().Max(l => l.LedRectangle.X + l.LedRectangle.Width);
|
||||
// var height = ledGroup.GetLeds().Max(l => l.LedRectangle.Y + l.LedRectangle.Height);
|
||||
var width = 500;
|
||||
var height = 500;
|
||||
_bitmap = new DirectBitmap((int) width, (int) height);
|
||||
}
|
||||
|
||||
public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color)
|
||||
{
|
||||
var pixel = _bitmap.GetPixel((int) (renderTarget.Rectangle.X + renderTarget.Rectangle.Width / 2), (int) (renderTarget.Rectangle.Y + renderTarget.Rectangle.Height / 2));
|
||||
return new Color(pixel.A, pixel.R, pixel.G, pixel.B);
|
||||
}
|
||||
|
||||
public Graphics GetGraphics()
|
||||
{
|
||||
return Graphics.FromImage(_bitmap.Bitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Plugins.Interfaces;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using Color = System.Drawing.Color;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
{
|
||||
@@ -19,6 +20,7 @@ namespace Artemis.Core.Services
|
||||
_rgbService = rgbService;
|
||||
_rgbService.Surface.Updating += SurfaceOnUpdating;
|
||||
|
||||
|
||||
Task.Run(Initialize);
|
||||
}
|
||||
|
||||
@@ -47,11 +49,20 @@ namespace Artemis.Core.Services
|
||||
try
|
||||
{
|
||||
// Update all active modules
|
||||
foreach (var module in _pluginService.Plugins.OfType<IModule>())
|
||||
foreach (var module in _pluginService.Plugins.Select(p => p.Plugin).OfType<IModule>())
|
||||
module.Update(args.DeltaTime);
|
||||
|
||||
if (_rgbService.GraphicsDecorator == null)
|
||||
return;
|
||||
|
||||
// Render all active modules
|
||||
foreach (var module in _pluginService.Plugins.OfType<IModule>())
|
||||
module.Render(args.DeltaTime, _rgbService.Surface);
|
||||
using (var g = _rgbService.GraphicsDecorator.GetGraphics())
|
||||
{
|
||||
g.Clear(Color.Red);
|
||||
|
||||
foreach (var module in _pluginService.Plugins.Select(p => p.Plugin).OfType<IModule>())
|
||||
module.Render(args.DeltaTime, _rgbService.Surface, g);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.RGB.NET;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.Services.Interfaces
|
||||
@@ -9,6 +10,7 @@ namespace Artemis.Core.Services.Interfaces
|
||||
{
|
||||
bool LoadingDevices { get; }
|
||||
RGBSurface Surface { get; set; }
|
||||
GraphicsDecorator GraphicsDecorator { get; }
|
||||
Task LoadDevices();
|
||||
void Dispose();
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.RGB.NET;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Brushes;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair;
|
||||
using RGB.NET.Groups;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
{
|
||||
@@ -28,6 +31,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
/// <inheritdoc />
|
||||
public RGBSurface Surface { get; set; }
|
||||
public GraphicsDecorator GraphicsDecorator { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task LoadDevices()
|
||||
@@ -51,6 +55,11 @@ namespace Artemis.Core.Services
|
||||
Surface.AlignDevices();
|
||||
});
|
||||
|
||||
// Apply the application wide brush and decorator
|
||||
var background = new ListLedGroup(Surface.Leds) { Brush = new SolidColorBrush(new Color(255, 255, 255, 255)) };
|
||||
GraphicsDecorator = new GraphicsDecorator(background);
|
||||
background.Brush.AddDecorator(GraphicsDecorator);
|
||||
|
||||
OnFinishedLoadedDevices();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
public static class ColorHelpers
|
||||
{
|
||||
private static readonly Random _rand = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Comes up with a 'pure' psuedo-random color
|
||||
/// </summary>
|
||||
/// <returns>The color</returns>
|
||||
public static Color GetRandomRainbowColor()
|
||||
{
|
||||
var colors = new List<int>();
|
||||
for (var i = 0; i < 3; i++)
|
||||
colors.Add(_rand.Next(0, 256));
|
||||
|
||||
var highest = colors.Max();
|
||||
var lowest = colors.Min();
|
||||
colors[colors.FindIndex(c => c == highest)] = 255;
|
||||
colors[colors.FindIndex(c => c == lowest)] = 0;
|
||||
|
||||
var returnColor = Color.FromArgb(255, colors[0], colors[1], colors[2]);
|
||||
|
||||
return returnColor;
|
||||
}
|
||||
|
||||
public static Color GetRandomRainbowMediaColor()
|
||||
{
|
||||
var colors = new List<byte>();
|
||||
for (var i = 0; i < 3; i++)
|
||||
colors.Add((byte) _rand.Next(0, 256));
|
||||
|
||||
var highest = colors.Max();
|
||||
var lowest = colors.Min();
|
||||
colors[colors.FindIndex(c => c == highest)] = 255;
|
||||
colors[colors.FindIndex(c => c == lowest)] = 0;
|
||||
|
||||
var returnColor = Color.FromArgb(255, colors[0], colors[1], colors[2]);
|
||||
|
||||
return returnColor;
|
||||
}
|
||||
|
||||
public static Color ShiftColor(Color c, int shiftAmount)
|
||||
{
|
||||
int newRed = c.R;
|
||||
int newGreen = c.G;
|
||||
int newBlue = c.B;
|
||||
|
||||
// Red to purple
|
||||
if (c.R == 255 && c.B < 255 && c.G == 0)
|
||||
newBlue = newBlue + shiftAmount;
|
||||
// Purple to blue
|
||||
else if (c.B == 255 && c.R > 0)
|
||||
newRed = newRed - shiftAmount;
|
||||
// Blue to light-blue
|
||||
else if (c.B == 255 && c.G < 255)
|
||||
newGreen = newGreen + shiftAmount;
|
||||
// Light-blue to green
|
||||
else if (c.G == 255 && c.B > 0)
|
||||
newBlue = newBlue - shiftAmount;
|
||||
// Green to yellow
|
||||
else if (c.G == 255 && c.R < 255)
|
||||
newRed = newRed + shiftAmount;
|
||||
// Yellow to red
|
||||
else if (c.R == 255 && c.G > 0)
|
||||
newGreen = newGreen - shiftAmount;
|
||||
|
||||
newRed = BringIntInColorRange(newRed);
|
||||
newGreen = BringIntInColorRange(newGreen);
|
||||
newBlue = BringIntInColorRange(newBlue);
|
||||
|
||||
return Color.FromArgb(c.A, newRed, newGreen, newBlue);
|
||||
}
|
||||
|
||||
private static int BringIntInColorRange(int i)
|
||||
{
|
||||
if (i < 0)
|
||||
return 0;
|
||||
if (i > 255)
|
||||
return 255;
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<packages>
|
||||
<package id="Castle.Core" version="4.2.1" targetFramework="net461" />
|
||||
<package id="CS-Script.bin" version="3.28.2.0" targetFramework="net461" />
|
||||
<package id="HidSharp" version="1.5" targetFramework="net461" />
|
||||
<package id="HidSharp" version="2.0.1" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.Analyzers" version="2.6.0" targetFramework="net461" developmentDependency="true" />
|
||||
<package id="Microsoft.CodeAnalysis.Common" version="2.7.0" targetFramework="net461" />
|
||||
<package id="Microsoft.CodeAnalysis.CSharp" version="2.7.0" targetFramework="net461" />
|
||||
@@ -24,21 +24,21 @@
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net461" />
|
||||
<package id="RGB.NET" version="0.0.1" targetFramework="net461" />
|
||||
<package id="RGB.NET.Asus" version="0.0.1" targetFramework="net461" />
|
||||
<package id="RGB.NET.Brushes" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Brushes" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.CoolerMaster" version="0.0.1" targetFramework="net461" />
|
||||
<package id="RGB.NET.Core" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Core" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.Corsair" version="0.0.1" targetFramework="net461" />
|
||||
<package id="RGB.NET.Decorators" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Decorators" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices" version="0.0.1" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Asus" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.CoolerMaster" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Corsair" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.DMX" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Logitech" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Novation" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Razer" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Asus" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.CoolerMaster" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Corsair" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.DMX" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Logitech" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Novation" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Razer" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.DMX" version="0.0.1" targetFramework="net461" />
|
||||
<package id="RGB.NET.Groups" version="0.0.1.49" targetFramework="net461" />
|
||||
<package id="RGB.NET.Groups" version="0.0.1.51" targetFramework="net461" />
|
||||
<package id="RGB.NET.Logitech" version="0.0.1" targetFramework="net461" />
|
||||
<package id="RGB.NET.Novation" version="0.0.1" targetFramework="net461" />
|
||||
<package id="RGB.NET.Presets" version="0.0.1" targetFramework="net461" />
|
||||
@@ -50,6 +50,7 @@
|
||||
<package id="RGB.NET.Resources.Novation" version="0.1.0" targetFramework="net461" />
|
||||
<package id="RGB.NET.Resources.Razer" version="0.1.0" targetFramework="net461" />
|
||||
<package id="Sanford.Multimedia.Midi" version="6.6.0" targetFramework="net461" />
|
||||
<package id="Sanford.Multimedia.Midi.Standard" version="6.6.0" targetFramework="net461" />
|
||||
<package id="Stylet" version="1.1.21" targetFramework="net461" />
|
||||
<package id="System.AppContext" version="4.3.0" targetFramework="net461" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
|
||||
|
||||
Reference in new issue
Block a user