Skip to content

Commit

Permalink
more lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlm committed Oct 31, 2024
1 parent d2580a4 commit baca3bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/Consolonia.Core/Drawing/DrawingContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>

Check warning on line 143 in src/Consolonia.Core/Drawing/DrawingContextImpl.cs

View workflow job for this annotation

GitHub Actions / build

"[RedundantAssignment] The value passed to the method is never used because it is overwritten in the method body before being read" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/DrawingContextImpl.cs(143,41)
{
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);

Check warning on line 145 in src/Consolonia.Core/Drawing/DrawingContextImpl.cs

View workflow job for this annotation

GitHub Actions / build

"[AccessToModifiedClosure] Captured variable is modified in the outer scope" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/DrawingContextImpl.cs(145,88)

Check warning on line 145 in src/Consolonia.Core/Drawing/DrawingContextImpl.cs

View workflow job for this annotation

GitHub Actions / build

"[AccessToModifiedClosure] Captured variable is modified in the outer scope" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/DrawingContextImpl.cs(145,91)
return pixel.Blend(new Pixel(new PixelBackground(backgroundBrush.Mode, backgroundBrush.Color)));
}, new ConsoleBrush(Colors.Transparent));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Media;

namespace Consolonia.Core.Drawing.PixelBufferImplementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
12 changes: 6 additions & 6 deletions src/Consolonia.Core/Drawing/RenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down

0 comments on commit baca3bb

Please sign in to comment.