mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 16:58:29 +00:00
Added key-rectangle to BrushRenderTarget
This commit is contained in:
parent
74824e3363
commit
deb043b6b2
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Drawing;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Helper;
|
||||
|
||||
namespace CUE.NET.Brushes
|
||||
{
|
||||
@ -18,6 +19,11 @@ namespace CUE.NET.Brushes
|
||||
/// </summary>
|
||||
public CorsairLedId LedId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rectangle representing the area to render the target-LED.
|
||||
/// </summary>
|
||||
public RectangleF Rectangle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point representing the position to render the target-LED.
|
||||
/// </summary>
|
||||
@ -31,11 +37,13 @@ namespace CUE.NET.Brushes
|
||||
/// Initializes a new instance of the <see cref="BrushRenderTarget"/> class.
|
||||
/// </summary>
|
||||
/// <param name="ledId">The ID of the target-LED.</param>
|
||||
/// <param name="point">The point representing the position to render the target-LED.</param>
|
||||
public BrushRenderTarget(CorsairLedId ledId, PointF point)
|
||||
/// <param name="rectangle">The rectangle representing the area to render the target-LED.</param>
|
||||
public BrushRenderTarget(CorsairLedId ledId, RectangleF rectangle)
|
||||
{
|
||||
this.Point = point;
|
||||
this.Rectangle = rectangle;
|
||||
this.LedId = ledId;
|
||||
|
||||
Point = rectangle.GetCenter();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -239,10 +239,10 @@ namespace CUE.NET.Devices.Generic
|
||||
float offsetY = -brushRectangle.Y;
|
||||
brushRectangle.X = 0;
|
||||
brushRectangle.Y = 0;
|
||||
brush.PerformRender(brushRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.GetCenter(offsetX, offsetY))));
|
||||
brush.PerformRender(brushRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.Move(offsetX, offsetY))));
|
||||
break;
|
||||
case BrushCalculationMode.Absolute:
|
||||
brush.PerformRender(DeviceRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.GetCenter())));
|
||||
brush.PerformRender(DeviceRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle)));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
|
||||
@ -10,7 +10,19 @@ namespace CUE.NET.Helper
|
||||
public static class RectangleHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates the center-point of a rectangle adding a offset.
|
||||
/// Moves a rectangle by a adding an 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 moved rectangle.</returns>
|
||||
public static RectangleF Move(this RectangleF rectangle, float offsetX = 0f, float offsetY = 0f)
|
||||
{
|
||||
return new RectangleF(rectangle.X + offsetX, rectangle.Y + offsetY, rectangle.Width, rectangle.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the center-point of a rectangle adding an offset.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The rectangle.</param>
|
||||
/// <param name="offsetX">The offset for the x-value</param>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user