mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Fixed a relative/absolute position problem with leds
This commit is contained in:
parent
6063f48cd4
commit
6fe54bd3ec
@ -49,6 +49,11 @@ namespace RGB.NET.Core
|
||||
/// </summary>
|
||||
public Rectangle LedRectangle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a rectangle representing the physical location of the <see cref="Led"/> on the <see cref="RGBSurface"/>.
|
||||
/// </summary>
|
||||
public Rectangle AbsoluteLedRectangle => (LedRectangle.Location + Device.Location) + new Size(LedRectangle.Size.Width, LedRectangle.Size.Height);
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the <see cref="Led" /> is about to change it's color.
|
||||
/// </summary>
|
||||
|
||||
@ -131,14 +131,14 @@ namespace RGB.NET.Core
|
||||
switch (brush.BrushCalculationMode)
|
||||
{
|
||||
case BrushCalculationMode.Relative:
|
||||
Rectangle brushRectangle = new Rectangle(leds.Select(GetDeviceLedLocation));
|
||||
Rectangle brushRectangle = new Rectangle(leds.Select(led => led.AbsoluteLedRectangle));
|
||||
Point offset = new Point(-brushRectangle.Location.X, -brushRectangle.Location.Y);
|
||||
brushRectangle.Location = new Point(0, 0);
|
||||
brush.PerformRender(brushRectangle,
|
||||
leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x, offset))));
|
||||
break;
|
||||
case BrushCalculationMode.Absolute:
|
||||
brush.PerformRender(SurfaceRectangle, leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x))));
|
||||
brush.PerformRender(SurfaceRectangle, leds.Select(x => new BrushRenderTarget(x, x.AbsoluteLedRectangle)));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
@ -151,9 +151,11 @@ namespace RGB.NET.Core
|
||||
renders.Key.Led.Color = renders.Value;
|
||||
}
|
||||
|
||||
private Rectangle GetDeviceLedLocation(Led led) => (led.LedRectangle.Location + led.Device.Location) + new Size(led.LedRectangle.Size.Width, led.LedRectangle.Size.Height);
|
||||
|
||||
private Rectangle GetDeviceLedLocation(Led led, Point extraOffset) => (led.LedRectangle.Location + led.Device.Location + extraOffset) + new Size(led.LedRectangle.Size.Width, led.LedRectangle.Size.Height);
|
||||
private Rectangle GetDeviceLedLocation(Led led, Point extraOffset)
|
||||
{
|
||||
Rectangle absoluteRectangle = led.AbsoluteLedRectangle;
|
||||
return (absoluteRectangle.Location + extraOffset) + absoluteRectangle.Size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches the given <see cref="ILedGroup"/>.
|
||||
|
||||
@ -117,7 +117,7 @@ namespace RGB.NET.Groups
|
||||
/// Gets a list containing all <see cref="T:RGB.NET.Core.Led" /> of this <see cref="T:RGB.NET.Groups.RectangleLedGroup" />.
|
||||
/// </summary>
|
||||
/// <returns>The list containing all <see cref="T:RGB.NET.Core.Led" /> of this <see cref="T:RGB.NET.Groups.RectangleLedGroup" />.</returns>
|
||||
public override IEnumerable<Led> GetLeds() => _ledCache ?? (_ledCache = RGBSurface.Instance.Leds.Where(x => x.LedRectangle.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList());
|
||||
public override IEnumerable<Led> GetLeds() => _ledCache ?? (_ledCache = RGBSurface.Instance.Leds.Where(x => x.AbsoluteLedRectangle.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList());
|
||||
|
||||
private void InvalidateCache() => _ledCache = null;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user