diff --git a/RGB.NET.Core/Leds/Led.cs b/RGB.NET.Core/Leds/Led.cs index 84eb272..13187db 100644 --- a/RGB.NET.Core/Leds/Led.cs +++ b/RGB.NET.Core/Leds/Led.cs @@ -49,6 +49,11 @@ namespace RGB.NET.Core /// public Rectangle LedRectangle { get; } + /// + /// Gets a rectangle representing the physical location of the on the . + /// + public Rectangle AbsoluteLedRectangle => (LedRectangle.Location + Device.Location) + new Size(LedRectangle.Size.Width, LedRectangle.Size.Height); + /// /// Indicates whether the is about to change it's color. /// diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index 37111b2..354f248 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -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; + } /// /// Attaches the given . diff --git a/RGB.NET.Groups/Groups/RectangleLedGroup.cs b/RGB.NET.Groups/Groups/RectangleLedGroup.cs index ac5213c..63b5616 100644 --- a/RGB.NET.Groups/Groups/RectangleLedGroup.cs +++ b/RGB.NET.Groups/Groups/RectangleLedGroup.cs @@ -117,7 +117,7 @@ namespace RGB.NET.Groups /// Gets a list containing all of this . /// /// The list containing all of this . - public override IEnumerable GetLeds() => _ledCache ?? (_ledCache = RGBSurface.Instance.Leds.Where(x => x.LedRectangle.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList()); + public override IEnumerable GetLeds() => _ledCache ?? (_ledCache = RGBSurface.Instance.Leds.Where(x => x.AbsoluteLedRectangle.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList()); private void InvalidateCache() => _ledCache = null;