Added own color-type to have more control over and easier manipulation of collors

This commit is contained in:
DarthAffe committed 2016-09-11 10:40:01 +02:00
1 parent 5c6dba769b
commit 381ec55349
29 files changed
+271 -93

No files matched your search

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
using CUE.NET.Exceptions;
@@ -65,10 +66,10 @@ namespace Example_AudioAnalyzer_full
CueSDK.UpdateMode = UpdateMode.Continuous;
// Add a black background. We want this to be semi-transparent to add some sort of fade-effect - this will smooth everything out a bit
// Note that this isn't a 'real effect' since it's update-rate dependent. A real effect would do always the same thing not mather how fast the keyboard updates.
_keyboard.Brush = new SolidColorBrush(Color.FromArgb(96, 0, 0, 0));
_keyboard.Brush = new SolidColorBrush(new CorsairColor(96, 0, 0, 0));
// Add our song-beat-effect. Remember to uncomment the update in the spectrum effect if you want to remove this.
ListLedGroup songBeatGroup = new ListLedGroup(_keyboard, _keyboard);
songBeatGroup.Brush = new SolidColorBrush(Color.FromArgb(127, 164, 164, 164));
songBeatGroup.Brush = new SolidColorBrush(new CorsairColor(127, 164, 164, 164));
songBeatGroup.Brush.AddEffect(new SongBeatEffect(_soundDataProcessor));
// Add our spectrum-effect using the soundDataProcessor and a rainbow from purple to red as gradient
@@ -1,6 +1,7 @@
using System;
using System.Drawing;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic;
using CUE.NET.Gradients;
using Example_AudioAnalyzer_full.TakeAsIs;
@@ -28,9 +29,9 @@ namespace Example_AudioAnalyzer_full
#region Methods
protected override Color GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget)
protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget)
{
if (_soundDataProcessor?.BarValues == null) return Color.Transparent;
if (_soundDataProcessor?.BarValues == null) return CorsairColor.Transparent;
// This logic is also stolen from AterialDawn
int barSampleIndex = (int)Math.Floor(_soundDataProcessor.BarValues.Length * (renderTarget.Point.X / (rectangle.X + rectangle.Width))); // Calculate bar sampling index
@@ -38,7 +39,7 @@ namespace Example_AudioAnalyzer_full
float verticalPos = (renderTarget.Point.Y / rectangle.Height);
// If the barHeight is lower than the vertical pos currently calculated return the brush value. Otherwise do nothing by returning transparent.
return curBarHeight <= verticalPos ? base.GetColorAtPoint(rectangle, renderTarget) : Color.Transparent;
return curBarHeight <= verticalPos ? base.GetColorAtPoint(rectangle, renderTarget) : CorsairColor.Transparent;
}
#endregion