mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 16:58:29 +00:00
Fixed a calculation bug while calculating the parameters for the brush calculation
This commit is contained in:
parent
855e850ce4
commit
d3103dd646
@ -10,7 +10,8 @@
|
||||
<licenseUrl>https://raw.githubusercontent.com/DarthAffe/CUE.NET/master/LICENSE</licenseUrl>
|
||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||
<description>Corsair HID SDK Wrapper</description>
|
||||
<releaseNotes>Updated SDK to v1.15.28</releaseNotes>
|
||||
<releaseNotes>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)</releaseNotes>
|
||||
<summary>C# (.NET) Wrapper library around the Corsair CUE-SDK</summary>
|
||||
<copyright>Copyright © Wyrez 2016</copyright>
|
||||
<language>en-US</language>
|
||||
|
||||
@ -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); }
|
||||
|
||||
@ -10,13 +10,15 @@ namespace CUE.NET.Helper
|
||||
public static class RectangleHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates the center-point of a rectangle.
|
||||
/// Calculates the center-point of a rectangle adding a offset.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The rectangle.</param>
|
||||
/// <param name="offsetX">The offset for the x-value</param>
|
||||
/// <param name="offsetY">The offset for the y-value</param>
|
||||
/// <returns>The center point of the rectangle.</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user