From baca3bb244a47dd528e5552c6f1ff7980ae28a7b Mon Sep 17 00:00:00 2001 From: Tom Laird-McConnell Date: Wed, 30 Oct 2024 17:48:10 -0700 Subject: [PATCH] more lint --- src/Consolonia.Core/Drawing/DrawingContextImpl.cs | 7 ++++--- .../PixelBufferImplementation/PixelForeground.cs | 1 - .../PixelBufferImplementation/PixelOperations.cs | 6 ++++-- src/Consolonia.Core/Drawing/RenderTarget.cs | 12 ++++++------ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Consolonia.Core/Drawing/DrawingContextImpl.cs b/src/Consolonia.Core/Drawing/DrawingContextImpl.cs index 72460929..7207a172 100644 --- a/src/Consolonia.Core/Drawing/DrawingContextImpl.cs +++ b/src/Consolonia.Core/Drawing/DrawingContextImpl.cs @@ -140,10 +140,11 @@ public void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry) CurrentClip.ExecuteWithClipping(new Point(px, py), () => { _pixelBuffer.Set(new PixelBufferCoordinate((ushort)px, (ushort)py), - (pixel, bb) => + (pixel, backgroundBrush) => { - return pixel.Blend(new Pixel(new PixelBackground(bb.Mode, bb.Color))); - }, ConsoleBrush.FromPosition(brush, x, y, (int)width, (int)height)); + backgroundBrush = ConsoleBrush.FromPosition(brush, x, y, (int)width, (int)height); + return pixel.Blend(new Pixel(new PixelBackground(backgroundBrush.Mode, backgroundBrush.Color))); + }, new ConsoleBrush(Colors.Transparent)); }); } } diff --git a/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs b/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs index b53c7840..98d07973 100644 --- a/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs +++ b/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using Avalonia.Media; namespace Consolonia.Core.Drawing.PixelBufferImplementation diff --git a/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelOperations.cs b/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelOperations.cs index 52f287ca..fb719de7 100644 --- a/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelOperations.cs +++ b/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelOperations.cs @@ -83,9 +83,11 @@ public static Color Brighten(this Color foreground, Color background) } } - private static double GetPerceivedBrightness(Color color) + private static int GetPerceivedBrightness(Color color) { - return (0.299 * color.R + 0.587 * color.G + 0.114 * color.B); + return (int)(0.299 * color.R + + 0.587 * color.G + + 0.114 * color.B); } } } \ No newline at end of file diff --git a/src/Consolonia.Core/Drawing/RenderTarget.cs b/src/Consolonia.Core/Drawing/RenderTarget.cs index 16e8f9ab..5a5d65cd 100644 --- a/src/Consolonia.Core/Drawing/RenderTarget.cs +++ b/src/Consolonia.Core/Drawing/RenderTarget.cs @@ -112,11 +112,11 @@ private void RenderToDevice() caretPosition = new PixelBufferCoordinate(x, y); } - /* todo: There is not IWindowImpl.Invalidate anymore. - if (!_consoleWindow.InvalidatedRects.Any(rect => - rect.ContainsExclusive(new Point(x, y)))) continue;*/ - if (pixel.Background.Mode != PixelBackgroundMode.Colored) - throw new InvalidOperationException("All pixels in the buffer must have exact console color before rendering"); + /* todo: There is not IWindowImpl.Invalidate anymore. + if (!_consoleWindow.InvalidatedRects.Any(rect => + rect.ContainsExclusive(new Point(x, y)))) continue;*/ + if (pixel.Background.Mode != PixelBackgroundMode.Colored) + throw new InvalidOperationException("All pixels in the buffer must have exact console color before rendering"); if (pixel.Foreground.Symbol is null) // not using 'when' as it swallows the exceptions { @@ -126,7 +126,7 @@ private void RenderToDevice() var pixelSpread = (pixel.Background.Color, pixel.Foreground.Color, pixel.Foreground.Weight, pixel.Foreground.Style, pixel.Foreground.TextDecorations, pixel.Foreground.Symbol.GetCharacter()); //todo: indexOutOfRange during resize - if (_cache[x, y] == pixelSpread) + if (_cache[x, y] == pixelSpread) continue; _cache[x, y] = pixelSpread;