Run TidyCode on all new classes

This commit is contained in:
tznind
2024-10-10 12:41:43 +01:00
parent 5a6aae694a
commit bcdb11e2f6
12 changed files with 145 additions and 140 deletions

View File

@@ -1,19 +1,19 @@
namespace Terminal.Gui;
/// <summary>
/// Implementation of <see cref="ISixelSupportDetector"/> that assumes best
/// case scenario (full support including transparency with 10x20 resolution).
/// Implementation of <see cref="ISixelSupportDetector"/> that assumes best
/// case scenario (full support including transparency with 10x20 resolution).
/// </summary>
public class AssumeSupportDetector : ISixelSupportDetector
{
/// <inheritdoc />
/// <inheritdoc/>
public SixelSupportResult Detect ()
{
return new SixelSupportResult
return new()
{
IsSupported = true,
MaxPaletteColors = 256,
Resolution = new Size (10, 20),
Resolution = new (10, 20),
SupportsTransparency = true
};
}

View File

@@ -1,14 +1,14 @@
namespace Terminal.Gui;
/// <summary>
/// Interface for detecting sixel support. Either through
/// ansi requests to terminal or config file etc.
/// Interface for detecting sixel support. Either through
/// ansi requests to terminal or config file etc.
/// </summary>
public interface ISixelSupportDetector
{
/// <summary>
/// Gets the supported sixel state e.g. by sending Ansi escape sequences
/// or from a config file etc.
/// Gets the supported sixel state e.g. by sending Ansi escape sequences
/// or from a config file etc.
/// </summary>
/// <returns>Description of sixel support.</returns>
public SixelSupportResult Detect ();

View File

@@ -3,49 +3,49 @@
namespace Terminal.Gui;
/// <summary>
/// Translates colors in an image into a Palette of up to <see cref="MaxColors"/> colors (typically 256).
/// Translates colors in an image into a Palette of up to <see cref="MaxColors"/> colors (typically 256).
/// </summary>
public class ColorQuantizer
{
/// <summary>
/// Gets the current colors in the palette based on the last call to
/// <see cref="BuildPalette"/>.
/// Gets the current colors in the palette based on the last call to
/// <see cref="BuildPalette"/>.
/// </summary>
public IReadOnlyCollection<Color> Palette { get; private set; } = new List<Color> ();
/// <summary>
/// Gets or sets the maximum number of colors to put into the <see cref="Palette"/>.
/// Defaults to 256 (the maximum for sixel images).
/// Gets or sets the maximum number of colors to put into the <see cref="Palette"/>.
/// Defaults to 256 (the maximum for sixel images).
/// </summary>
public int MaxColors { get; set; } = 256;
/// <summary>
/// Gets or sets the algorithm used to map novel colors into existing
/// palette colors (closest match). Defaults to <see cref="EuclideanColorDistance"/>
/// Gets or sets the algorithm used to map novel colors into existing
/// palette colors (closest match). Defaults to <see cref="EuclideanColorDistance"/>
/// </summary>
public IColorDistance DistanceAlgorithm { get; set; } = new EuclideanColorDistance ();
/// <summary>
/// Gets or sets the algorithm used to build the <see cref="Palette"/>.
/// Gets or sets the algorithm used to build the <see cref="Palette"/>.
/// </summary>
public IPaletteBuilder PaletteBuildingAlgorithm { get; set; } = new PopularityPaletteWithThreshold (new EuclideanColorDistance (),8) ;
public IPaletteBuilder PaletteBuildingAlgorithm { get; set; } = new PopularityPaletteWithThreshold (new EuclideanColorDistance (), 8);
private readonly ConcurrentDictionary<Color, int> _nearestColorCache = new ();
/// <summary>
/// Builds a <see cref="Palette"/> of colors that most represent the colors used in <paramref name="pixels"/> image.
/// This is based on the currently configured <see cref="PaletteBuildingAlgorithm"/>.
/// Builds a <see cref="Palette"/> of colors that most represent the colors used in <paramref name="pixels"/> image.
/// This is based on the currently configured <see cref="PaletteBuildingAlgorithm"/>.
/// </summary>
/// <param name="pixels"></param>
public void BuildPalette (Color [,] pixels)
{
List<Color> allColors = new List<Color> ();
List<Color> allColors = new ();
int width = pixels.GetLength (0);
int height = pixels.GetLength (1);
for (int x = 0; x < width; x++)
for (var x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
for (var y = 0; y < height; y++)
{
allColors.Add (pixels [x, y]);
}
@@ -57,14 +57,14 @@ public class ColorQuantizer
public int GetNearestColor (Color toTranslate)
{
if (_nearestColorCache.TryGetValue (toTranslate, out var cachedAnswer))
if (_nearestColorCache.TryGetValue (toTranslate, out int cachedAnswer))
{
return cachedAnswer;
}
// Simple nearest color matching based on DistanceAlgorithm
double minDistance = double.MaxValue;
int nearestIndex = 0;
var minDistance = double.MaxValue;
var nearestIndex = 0;
for (var index = 0; index < Palette.Count; index++)
{
@@ -79,6 +79,7 @@ public class ColorQuantizer
}
_nearestColorCache.TryAdd (toTranslate, nearestIndex);
return nearestIndex;
}
}
}

View File

@@ -1,20 +1,21 @@
namespace Terminal.Gui;
/// <summary>
/// <para>
/// Calculates the distance between two colors using Euclidean distance in 3D RGB space.
/// This measures the straight-line distance between the two points representing the colors.
///</para>
/// <para>
/// Euclidean distance in RGB space is calculated as:
/// </para>
/// <code>
/// √((R2 - R1)² + (G2 - G1)² + (B2 - B1)²)
/// </code>
/// <remarks>Values vary from 0 to ~441.67 linearly</remarks>
///
/// <remarks>This distance metric is commonly used for comparing colors in RGB space, though
/// it doesn't account for perceptual differences in color.</remarks>
/// <para>
/// Calculates the distance between two colors using Euclidean distance in 3D RGB space.
/// This measures the straight-line distance between the two points representing the colors.
/// </para>
/// <para>
/// Euclidean distance in RGB space is calculated as:
/// </para>
/// <code>
/// √((R2 - R1)² + (G2 - G1)² + (B2 - B1)²)
/// </code>
/// <remarks>Values vary from 0 to ~441.67 linearly</remarks>
/// <remarks>
/// This distance metric is commonly used for comparing colors in RGB space, though
/// it doesn't account for perceptual differences in color.
/// </remarks>
/// </summary>
public class EuclideanColorDistance : IColorDistance
{
@@ -24,6 +25,7 @@ public class EuclideanColorDistance : IColorDistance
int rDiff = c1.R - c2.R;
int gDiff = c1.G - c2.G;
int bDiff = c1.B - c2.B;
return Math.Sqrt (rDiff * rDiff + gDiff * gDiff + bDiff * bDiff);
}
}

View File

@@ -1,15 +1,15 @@
namespace Terminal.Gui;
/// <summary>
/// Interface for algorithms that compute the relative distance between pairs of colors.
/// This is used for color matching to a limited palette, such as in Sixel rendering.
/// Interface for algorithms that compute the relative distance between pairs of colors.
/// This is used for color matching to a limited palette, such as in Sixel rendering.
/// </summary>
public interface IColorDistance
{
/// <summary>
/// Computes a similarity metric between two <see cref="Color"/> instances.
/// A larger value indicates more dissimilar colors, while a smaller value indicates more similar colors.
/// The metric is internally consistent for the given algorithm.
/// Computes a similarity metric between two <see cref="Color"/> instances.
/// A larger value indicates more dissimilar colors, while a smaller value indicates more similar colors.
/// The metric is internally consistent for the given algorithm.
/// </summary>
/// <param name="c1">The first color.</param>
/// <param name="c2">The second color.</param>

View File

@@ -1,16 +1,18 @@
namespace Terminal.Gui;
/// <summary>
/// Builds a palette of a given size for a given set of input colors.
/// Builds a palette of a given size for a given set of input colors.
/// </summary>
public interface IPaletteBuilder
{
/// <summary>
/// Reduce the number of <paramref name="colors"/> to <paramref name="maxColors"/> (or less)
/// using an appropriate selection algorithm.
/// Reduce the number of <paramref name="colors"/> to <paramref name="maxColors"/> (or less)
/// using an appropriate selection algorithm.
/// </summary>
/// <param name="colors">Color of every pixel in the image. Contains duplication in order
/// to support algorithms that weigh how common a color is.</param>
/// <param name="colors">
/// Color of every pixel in the image. Contains duplication in order
/// to support algorithms that weigh how common a color is.
/// </param>
/// <param name="maxColors">The maximum number of colours that should be represented.</param>
/// <returns></returns>
List<Color> BuildPalette (List<Color> colors, int maxColors);

View File

@@ -2,10 +2,10 @@
using Color = Terminal.Gui.Color;
/// <summary>
/// Simple fast palette building algorithm which uses the frequency that a color is seen
/// to determine whether it will appear in the final palette. Includes a threshold where
/// by colors will be considered 'the same'. This reduces the chance of under represented
/// colors being missed completely.
/// Simple fast palette building algorithm which uses the frequency that a color is seen
/// to determine whether it will appear in the final palette. Includes a threshold where
/// by colors will be considered 'the same'. This reduces the chance of under represented
/// colors being missed completely.
/// </summary>
public class PopularityPaletteWithThreshold : IPaletteBuilder
{
@@ -13,7 +13,7 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder
private readonly double _mergeThreshold;
/// <summary>
/// Creates a new instance with the given color grouping parameters.
/// Creates a new instance with the given color grouping parameters.
/// </summary>
/// <param name="colorDistance">Determines which different colors can be considered the same.</param>
/// <param name="mergeThreshold">Threshold for merging two colors together.</param>
@@ -31,7 +31,7 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder
}
// Step 1: Build the histogram of colors (count occurrences)
Dictionary<Color, int> colorHistogram = new Dictionary<Color, int> ();
Dictionary<Color, int> colorHistogram = new ();
foreach (Color color in colors)
{
@@ -64,14 +64,14 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder
}
/// <summary>
/// Merge colors in the histogram if they are within the threshold distance
/// Merge colors in the histogram if they are within the threshold distance
/// </summary>
/// <param name="colorHistogram"></param>
/// <param name="maxColors"></param>
/// <returns></returns>
private Dictionary<Color, int> MergeSimilarColors (Dictionary<Color, int> colorHistogram, int maxColors)
{
Dictionary<Color, int> mergedHistogram = new Dictionary<Color, int> ();
Dictionary<Color, int> mergedHistogram = new ();
foreach (KeyValuePair<Color, int> entry in colorHistogram)
{

View File

@@ -4,12 +4,10 @@
// libsixel (C/C++) - https://github.com/saitoha/libsixel
// Copyright (c) 2014-2016 Hayaki Saito @license MIT
using Terminal.Gui;
namespace Terminal.Gui;
/// <summary>
/// Encodes a images into the sixel console image output format.
/// Encodes a images into the sixel console image output format.
/// </summary>
public class SixelEncoder
{
@@ -35,32 +33,29 @@ public class SixelEncoder
*/
/// <summary>
/// Gets or sets the quantizer responsible for building a representative
/// limited color palette for images and for mapping novel colors in
/// images to their closest palette color
/// Gets or sets the quantizer responsible for building a representative
/// limited color palette for images and for mapping novel colors in
/// images to their closest palette color
/// </summary>
public ColorQuantizer Quantizer { get; set; } = new ();
/// <summary>
/// Encode the given bitmap into sixel encoding
/// Encode the given bitmap into sixel encoding
/// </summary>
/// <param name="pixels"></param>
/// <returns></returns>
public string EncodeSixel (Color [,] pixels)
{
const string start = "\u001bP"; // Start sixel sequence
string defaultRatios = this.AnyHasAlphaOfZero(pixels) ? "0;1;0": "0;0;0"; // Defaults for aspect ratio and grid size
string defaultRatios = AnyHasAlphaOfZero (pixels) ? "0;1;0" : "0;0;0"; // Defaults for aspect ratio and grid size
const string completeStartSequence = "q"; // Signals beginning of sixel image data
const string noScaling = "\"1;1;"; // no scaling factors (1x1);
string fillArea = GetFillArea (pixels);
string pallette = GetColorPalette (pixels );
string pallette = GetColorPalette (pixels);
string pixelData = WriteSixel (pixels);
@@ -71,15 +66,14 @@ public class SixelEncoder
private string WriteSixel (Color [,] pixels)
{
StringBuilder sb = new StringBuilder ();
var sb = new StringBuilder ();
int height = pixels.GetLength (1);
int width = pixels.GetLength (0);
// Iterate over each 'row' of the image. Because each sixel write operation
// outputs a screen area 6 pixels high (and 1+ across) we must process the image
// 6 'y' units at once (1 band)
for (int y = 0; y < height; y += 6)
for (var y = 0; y < height; y += 6)
{
sb.Append (ProcessBand (pixels, y, Math.Min (6, height - y), width));
@@ -107,18 +101,18 @@ public class SixelEncoder
Array.Fill (accu, (ushort)1);
Array.Fill (slots, (short)-1);
var usedColorIdx = new List<int> ();
var targets = new List<List<string>> ();
List<int> usedColorIdx = new List<int> ();
List<List<string>> targets = new List<List<string>> ();
// Process columns within the band
for (int x = 0; x < width; ++x)
for (var x = 0; x < width; ++x)
{
Array.Clear (code, 0, usedColorIdx.Count);
// Process each row in the 6-pixel high band
for (int row = 0; row < bandHeight; ++row)
for (var row = 0; row < bandHeight; ++row)
{
var color = pixels [x, startY + row];
Color color = pixels [x, startY + row];
int colorIndex = Quantizer.GetNearestColor (color);
@@ -129,12 +123,14 @@ public class SixelEncoder
if (slots [colorIndex] == -1)
{
targets.Add (new List<string> ());
targets.Add (new ());
if (x > 0)
{
last [usedColorIdx.Count] = 0;
accu [usedColorIdx.Count] = (ushort)x;
}
slots [colorIndex] = (short)usedColorIdx.Count;
usedColorIdx.Add (colorIndex);
}
@@ -143,7 +139,7 @@ public class SixelEncoder
}
// Handle transitions between columns
for (int j = 0; j < usedColorIdx.Count; ++j)
for (var j = 0; j < usedColorIdx.Count; ++j)
{
if (code [j] == last [j])
{
@@ -155,6 +151,7 @@ public class SixelEncoder
{
targets [j].Add (CodeToSixel (last [j], accu [j]));
}
last [j] = (sbyte)code [j];
accu [j] = 1;
}
@@ -162,7 +159,7 @@ public class SixelEncoder
}
// Process remaining data for this band
for (int j = 0; j < usedColorIdx.Count; ++j)
for (var j = 0; j < usedColorIdx.Count; ++j)
{
if (last [j] != 0)
{
@@ -172,7 +169,8 @@ public class SixelEncoder
// Build the final output for this band
var result = new StringBuilder ();
for (int j = 0; j < usedColorIdx.Count; ++j)
for (var j = 0; j < usedColorIdx.Count; ++j)
{
result.Append ($"#{usedColorIdx [j]}{string.Join ("", targets [j])}$");
}
@@ -182,7 +180,8 @@ public class SixelEncoder
private static string CodeToSixel (int code, int repeat)
{
char c = (char)(code + 63);
var c = (char)(code + 63);
if (repeat > 3)
{
return "!" + repeat + c;
@@ -205,16 +204,18 @@ public class SixelEncoder
{
Quantizer.BuildPalette (pixels);
StringBuilder paletteSb = new StringBuilder ();
var paletteSb = new StringBuilder ();
for (int i = 0; i < Quantizer.Palette.Count; i++)
for (var i = 0; i < Quantizer.Palette.Count; i++)
{
var color = Quantizer.Palette.ElementAt (i);
paletteSb.AppendFormat ("#{0};2;{1};{2};{3}",
i,
color.R * 100 / 255,
color.G * 100 / 255,
color.B * 100 / 255);
Color color = Quantizer.Palette.ElementAt (i);
paletteSb.AppendFormat (
"#{0};2;{1};{2};{3}",
i,
color.R * 100 / 255,
color.G * 100 / 255,
color.B * 100 / 255);
}
return paletteSb.ToString ();
@@ -227,15 +228,16 @@ public class SixelEncoder
return $"{widthInChars};{heightInChars}";
}
private bool AnyHasAlphaOfZero (Color [,] pixels)
{
int width = pixels.GetLength (0);
int height = pixels.GetLength (1);
// Loop through each pixel in the 2D array
for (int x = 0; x < width; x++)
for (var x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
for (var y = 0; y < height; y++)
{
// Check if the alpha component (A) is 0
if (pixels [x, y].A == 0)
@@ -244,6 +246,7 @@ public class SixelEncoder
}
}
}
return false; // No pixel with A of 0 was found
}
}
}

View File

@@ -1,9 +1,9 @@
namespace Terminal.Gui;
/// <summary>
/// Describes the discovered state of sixel support and ancillary information
/// e.g. <see cref="Resolution"/>. You can use any <see cref="ISixelSupportDetector"/>
/// to discover this information.
/// Describes the discovered state of sixel support and ancillary information
/// e.g. <see cref="Resolution"/>. You can use any <see cref="ISixelSupportDetector"/>
/// to discover this information.
/// </summary>
public class SixelSupportResult
{

View File

@@ -1,19 +1,19 @@
namespace Terminal.Gui;
/// <summary>
/// Describes a request to render a given <see cref="SixelData"/> at a given <see cref="ScreenPosition"/>.
/// Requires that the terminal and <see cref="ConsoleDriver"/> both support sixel.
/// Describes a request to render a given <see cref="SixelData"/> at a given <see cref="ScreenPosition"/>.
/// Requires that the terminal and <see cref="ConsoleDriver"/> both support sixel.
/// </summary>
public class SixelToRender
{
/// <summary>
/// gets or sets the encoded sixel data. Use <see cref="SixelEncoder"/> to convert bitmaps
/// into encoded sixel data.
/// gets or sets the encoded sixel data. Use <see cref="SixelEncoder"/> to convert bitmaps
/// into encoded sixel data.
/// </summary>
public string SixelData { get; set; }
/// <summary>
/// gets or sets where to move the cursor to before outputting the <see cref="SixelData"/>.
/// gets or sets where to move the cursor to before outputting the <see cref="SixelData"/>.
/// </summary>
public Point ScreenPosition { get; set; }
}

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
@@ -70,7 +69,7 @@ public class Images : Scenario
_sixelSupportResult = sixelSupportDetector.Detect ();
Application.Init ();
_win = new() { Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" };
_win = new () { Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" };
bool canTrueColor = Application.Driver?.SupportsTrueColor ?? false;
@@ -79,7 +78,7 @@ public class Images : Scenario
DisplayText = "Basic"
};
_tabSixel = new()
_tabSixel = new ()
{
DisplayText = "Sixel"
};
@@ -129,7 +128,7 @@ public class Images : Scenario
var btnOpenImage = new Button { X = Pos.Right (cbUseTrueColor) + 2, Y = 0, Text = "Open Image" };
_win.Add (btnOpenImage);
_tabView = new()
_tabView = new ()
{
Y = Pos.Bottom (btnOpenImage), Width = Dim.Fill (), Height = Dim.Fill ()
};
@@ -166,19 +165,18 @@ public class Images : Scenario
if (!_sixelSupportResult.SupportsTransparency)
{
if (MessageBox.Query (
"Transparency Not Supported",
"It looks like your terminal does not support transparent sixel backgrounds. Do you want to try anyway?",
"Yes",
"No")
"Transparency Not Supported",
"It looks like your terminal does not support transparent sixel backgrounds. Do you want to try anyway?",
"Yes",
"No")
!= 0)
{
return;
}
}
_fire = new DoomFire (_win.Frame.Width * _pxX.Value, _win.Frame.Height * _pxY.Value);
_fireEncoder = new SixelEncoder ();
_fire = new (_win.Frame.Width * _pxX.Value, _win.Frame.Height * _pxY.Value);
_fireEncoder = new ();
_fireEncoder.Quantizer.MaxColors = Math.Min (_fireEncoder.Quantizer.MaxColors, _sixelSupportResult.MaxPaletteColors);
_fireEncoder.Quantizer.PaletteBuildingAlgorithm = new ConstPalette (_fire.Palette);
@@ -294,14 +292,14 @@ public class Images : Scenario
private void BuildSixelTab ()
{
_sixelSupported = new()
_sixelSupported = new ()
{
Width = Dim.Fill (),
Height = Dim.Fill (),
CanFocus = true
};
_sixelNotSupported = new()
_sixelNotSupported = new ()
{
Width = Dim.Fill (),
Height = Dim.Fill (),
@@ -318,7 +316,7 @@ public class Images : Scenario
VerticalTextAlignment = Alignment.Center
});
_sixelView = new()
_sixelView = new ()
{
Width = Dim.Percent (50),
Height = Dim.Fill (),
@@ -345,7 +343,6 @@ public class Images : Scenario
btnStartFire.Accepting += BtnStartFireOnAccept;
_sixelSupported.Add (btnStartFire);
var lblPxX = new Label
{
X = Pos.Right (_sixelView),
@@ -353,7 +350,7 @@ public class Images : Scenario
Text = "Pixels per Col:"
};
_pxX = new()
_pxX = new ()
{
X = Pos.Right (lblPxX),
Y = Pos.Bottom (btnStartFire) + 1,
@@ -367,27 +364,27 @@ public class Images : Scenario
Text = "Pixels per Row:"
};
_pxY = new()
_pxY = new ()
{
X = Pos.Right (lblPxY),
Y = Pos.Bottom (_pxX),
Value = _sixelSupportResult.Resolution.Height
};
var l1 = new Label ()
var l1 = new Label
{
Text = "Palette Building Algorithm",
Width = Dim.Auto (),
X = Pos.Right (_sixelView),
Y = Pos.Bottom (_pxY) + 1,
Y = Pos.Bottom (_pxY) + 1
};
_rgPaletteBuilder = new RadioGroup
_rgPaletteBuilder = new()
{
RadioLabels = new []
{
"Popularity",
"Median Cut",
"Median Cut"
},
X = Pos.Right (_sixelView) + 2,
Y = Pos.Bottom (l1),
@@ -401,21 +398,22 @@ public class Images : Scenario
Value = 8
};
var lblPopThreshold = new Label ()
var lblPopThreshold = new Label
{
Text = "(threshold)",
X = Pos.Right (_popularityThreshold),
Y = Pos.Top (_popularityThreshold),
Y = Pos.Top (_popularityThreshold)
};
var l2 = new Label ()
var l2 = new Label
{
Text = "Color Distance Algorithm",
Width = Dim.Auto (),
X = Pos.Right (_sixelView),
Y = Pos.Bottom (_rgPaletteBuilder) + 1,
Y = Pos.Bottom (_rgPaletteBuilder) + 1
};
_rgDistanceAlgorithm = new RadioGroup ()
_rgDistanceAlgorithm = new()
{
RadioLabels = new []
{
@@ -423,7 +421,7 @@ public class Images : Scenario
"CIE76"
},
X = Pos.Right (_sixelView) + 2,
Y = Pos.Bottom (l2),
Y = Pos.Bottom (l2)
};
_sixelSupported.Add (lblPxX);
@@ -441,7 +439,7 @@ public class Images : Scenario
_sixelView.DrawContent += SixelViewOnDrawContent;
}
IPaletteBuilder GetPaletteBuilder ()
private IPaletteBuilder GetPaletteBuilder ()
{
switch (_rgPaletteBuilder.SelectedItem)
{
@@ -451,7 +449,7 @@ public class Images : Scenario
}
}
IColorDistance GetDistanceAlgorithm ()
private IColorDistance GetDistanceAlgorithm ()
{
switch (_rgDistanceAlgorithm.SelectedItem)
{
@@ -466,6 +464,7 @@ public class Images : Scenario
if (_imageView.FullResImage == null)
{
MessageBox.Query ("No Image Loaded", "You must first open an image. Use the 'Open Image' button above.", "Ok");
return;
}
@@ -493,9 +492,7 @@ public class Images : Scenario
_sixelImage.SixelData = _encodedSixelData;
}
_sixelView.SetNeedsDisplay();
_sixelView.SetNeedsDisplay ();
}
private void SixelViewOnDrawContent (object sender, DrawEventArgs e)

View File

@@ -25,7 +25,7 @@ public class PopularityPaletteWithThresholdTests
{
// Arrange
var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50);
List<Color> colors = new() { new (255, 0), new (0, 255) };
List<Color> colors = new () { new (255, 0), new (0, 255) };
// Act
List<Color> result = paletteBuilder.BuildPalette (colors, 0);
@@ -39,7 +39,7 @@ public class PopularityPaletteWithThresholdTests
{
// Arrange
var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50);
List<Color> colors = new() { new (255, 0), new (255, 0) };
List<Color> colors = new () { new (255, 0), new (255, 0) };
// Act
List<Color> result = paletteBuilder.BuildPalette (colors, 256);
@@ -55,7 +55,7 @@ public class PopularityPaletteWithThresholdTests
// Arrange
var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50); // Set merge threshold to 50
List<Color> colors = new List<Color>
List<Color> colors = new()
{
new (255, 0), // Red
new (250, 0), // Very close to Red
@@ -78,7 +78,7 @@ public class PopularityPaletteWithThresholdTests
// Arrange
var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50);
List<Color> colors = new()
List<Color> colors = new ()
{
new (255, 0), // Red
new (0, 255) // Green
@@ -99,7 +99,7 @@ public class PopularityPaletteWithThresholdTests
// Arrange
var paletteBuilder = new PopularityPaletteWithThreshold (_colorDistance, 50);
List<Color> colors = new List<Color>
List<Color> colors = new()
{
new (255, 0), // Red
new (254, 0), // Close to Red