mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2026-11-11 13:06:24 +00:00
Added own color-type to have more control over and easier manipulation of collors
This commit is contained in:
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
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Effects;
|
||||
using CUE.NET.Gradients;
|
||||
|
||||
namespace SimpleDevTest
|
||||
{
|
||||
public class MoveRainbowEffect : AbstractBrushEffect<IGradientBrush>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public float DegreePerSecond { get; set; } = 30f;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
float value = DegreePerSecond * deltaTime;
|
||||
|
||||
//DarthAffe 11.09.2016: Only to test! This will overflow if run for a longer time!!!
|
||||
((RainbowGradient)Brush.Gradient).StartHue += value;
|
||||
((RainbowGradient)Brush.Gradient).EndHue += value;
|
||||
}
|
||||
|
||||
public override bool CanBeAppliedTo(IBrush target)
|
||||
{
|
||||
return (target as IGradientBrush)?.Gradient is RainbowGradient;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -39,17 +39,15 @@ namespace SimpleDevTest
|
||||
CueSDK.UpdateMode = UpdateMode.Continuous;
|
||||
|
||||
IBrush rainbowBrush = new LinearGradientBrush(new RainbowGradient());
|
||||
rainbowBrush.AddEffect(new FlashEffect());
|
||||
rainbowBrush.AddEffect(new FlashEffect { Attack = 5f, Sustain = 1f, Decay = 0, Release = 5f, Interval = 1f });
|
||||
rainbowBrush.AddEffect(new MoveRainbowEffect());
|
||||
rainbowBrush.AddEffect(new RemoveRedEffect());
|
||||
|
||||
AddTestBrush(CueSDK.KeyboardSDK, rainbowBrush);
|
||||
AddTestBrush(CueSDK.KeyboardSDK, rainbowBrush);
|
||||
AddTestBrush(CueSDK.KeyboardSDK, rainbowBrush);
|
||||
AddTestBrush(CueSDK.MouseSDK, rainbowBrush);
|
||||
AddTestBrush(CueSDK.HeadsetSDK, rainbowBrush);
|
||||
AddTestBrush(CueSDK.MousematSDK, rainbowBrush);
|
||||
|
||||
Wait(10);
|
||||
|
||||
|
||||
//// Get connected keyboard or throw exception if there is no light controllable keyboard connected
|
||||
//CorsairKeyboard keyboard = CueSDK.KeyboardSDK;
|
||||
//if (keyboard == null)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using CUE.NET.Devices.Generic;
|
||||
using CUE.NET.Effects;
|
||||
|
||||
namespace SimpleDevTest
|
||||
{
|
||||
public class RemoveRedEffect : AbstractBrushEffect
|
||||
{
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
foreach (CorsairColor colors in Brush.RenderedTargets.Values)
|
||||
colors.R = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,8 +47,10 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MoveRainbowEffect.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RemoveRedEffect.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config">
|
||||
|
||||
Reference in new issue
Block a user