diff --git a/CUE.NET.nuspec b/CUE.NET.nuspec
index f4af248..f9381f7 100644
--- a/CUE.NET.nuspec
+++ b/CUE.NET.nuspec
@@ -10,7 +10,8 @@
https://raw.githubusercontent.com/DarthAffe/CUE.NET/master/LICENSE
true
Corsair HID SDK Wrapper
- Updated SDK to v1.15.28
+ Updated SDK to v1.15.28,
+ Fixed a calculation bug while calculating the parameters for the brush calculation (THIS MIGHT BREAK EXISTING IMPLEMENTATIONS AND WILL BE CHANGED AGAIN IN THE NEXT VERSION)
C# (.NET) Wrapper library around the Corsair CUE-SDK
Copyright © Wyrez 2016
en-US
diff --git a/Devices/Keyboard/CorsairKeyboard.cs b/Devices/Keyboard/CorsairKeyboard.cs
index 597cc57..800a80d 100644
--- a/Devices/Keyboard/CorsairKeyboard.cs
+++ b/Devices/Keyboard/CorsairKeyboard.cs
@@ -179,8 +179,13 @@ namespace CUE.NET.Devices.Keyboard
try
{
RectangleF brushRectangle = RectangleHelper.CreateRectangleFromRectangles(keys.Select(x => x.KeyRectangle));
+ //TODO DarthAffe 16.03.2016: Rework brushes and replace this workaround with a proper selection of absolute/relative calculations
+ float offsetX = -brushRectangle.X;
+ float offsetY = -brushRectangle.Y;
+ brushRectangle.X = 0;
+ brushRectangle.Y = 0;
foreach (CorsairKey key in keys)
- key.Led.Color = brush.GetColorAtPoint(brushRectangle, key.KeyRectangle.GetCenter());
+ key.Led.Color = brush.GetColorAtPoint(brushRectangle, key.KeyRectangle.GetCenter(offsetX, offsetY));
}
// ReSharper disable once CatchAllClause
catch (Exception ex) { ManageException(ex); }
diff --git a/Helper/RectangleHelper.cs b/Helper/RectangleHelper.cs
index dc1faea..cb360fd 100644
--- a/Helper/RectangleHelper.cs
+++ b/Helper/RectangleHelper.cs
@@ -10,13 +10,15 @@ namespace CUE.NET.Helper
public static class RectangleHelper
{
///
- /// Calculates the center-point of a rectangle.
+ /// Calculates the center-point of a rectangle adding a offset.
///
/// The rectangle.
+ /// The offset for the x-value
+ /// The offset for the y-value
/// The center point of the rectangle.
- public static PointF GetCenter(this RectangleF rectangle)
+ public static PointF GetCenter(this RectangleF rectangle, float offsetX = 0f, float offsetY = 0f)
{
- return new PointF(rectangle.Left + rectangle.Width / 2f, rectangle.Top + rectangle.Height / 2f);
+ return new PointF((rectangle.Left + rectangle.Width / 2f) + offsetX, (rectangle.Top + rectangle.Height / 2f) + offsetY);
}
///