mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-28 08:47:59 +01:00
Adjust default quantizer
This commit is contained in:
@@ -28,7 +28,7 @@ public class ColorQuantizer
|
||||
/// <summary>
|
||||
/// Gets or sets the algorithm used to build the <see cref="Palette"/>.
|
||||
/// </summary>
|
||||
public IPaletteBuilder PaletteBuildingAlgorithm { get; set; } = new PopularityPaletteWithThreshold (new EuclideanColorDistance (),5) ;
|
||||
public IPaletteBuilder PaletteBuildingAlgorithm { get; set; } = new PopularityPaletteWithThreshold (new EuclideanColorDistance (),8) ;
|
||||
|
||||
private readonly ConcurrentDictionary<Color, int> _nearestColorCache = new ();
|
||||
|
||||
@@ -46,6 +46,7 @@ public class ColorQuantizer
|
||||
}
|
||||
}
|
||||
|
||||
_nearestColorCache.Clear ();
|
||||
Palette = PaletteBuildingAlgorithm.BuildPalette (allColors, MaxColors);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ public class Images : Scenario
|
||||
private View _sixelView;
|
||||
|
||||
private DoomFire _fire;
|
||||
private SixelEncoder _encoder;
|
||||
private SixelEncoder _fireEncoder;
|
||||
private SixelToRender _fireSixel;
|
||||
private int _fireFrameCounter;
|
||||
private bool _isDisposed;
|
||||
private SixelToRender _fireSixel;
|
||||
|
||||
public override void Main ()
|
||||
{
|
||||
@@ -155,19 +155,14 @@ public class Images : Scenario
|
||||
}
|
||||
|
||||
_fire = new DoomFire (_win.Frame.Width * _pxX.Value, _win.Frame.Height * _pxY.Value);
|
||||
_encoder = new SixelEncoder ();
|
||||
_encoder.Quantizer.PaletteBuildingAlgorithm = new ConstPalette (_fire.Palette);
|
||||
_fireEncoder = new SixelEncoder ();
|
||||
_fireEncoder.Quantizer.PaletteBuildingAlgorithm = new ConstPalette (_fire.Palette);
|
||||
|
||||
_fireFrameCounter = 0;
|
||||
|
||||
Application.AddTimeout (TimeSpan.FromMilliseconds (30), AdvanceFireTimerCallback);
|
||||
}
|
||||
|
||||
private void StopFire ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private bool AdvanceFireTimerCallback ()
|
||||
{
|
||||
_fire.AdvanceFrame ();
|
||||
@@ -190,7 +185,7 @@ public class Images : Scenario
|
||||
|
||||
_fireSixel = new ()
|
||||
{
|
||||
SixelData = _encoder.EncodeSixel (bmp),
|
||||
SixelData = _fireEncoder.EncodeSixel (bmp),
|
||||
ScreenPosition = new (0, 0)
|
||||
};
|
||||
|
||||
@@ -410,6 +405,7 @@ public class Images : Scenario
|
||||
)
|
||||
{
|
||||
var encoder = new SixelEncoder ();
|
||||
|
||||
|
||||
// Calculate the target size in pixels based on console units
|
||||
int targetWidthInPixels = maxSize.Width * pixelsPerCellX;
|
||||
|
||||
Reference in New Issue
Block a user