mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Added canvas unit tests & fix canvas scaling bug
This commit is contained in:
@ -44,6 +44,16 @@ namespace Spectre.Console
|
||||
/// <param name="height">The canvas height.</param>
|
||||
public Canvas(int width, int height)
|
||||
{
|
||||
if (width < 1)
|
||||
{
|
||||
throw new ArgumentException("Must be > 1", nameof(width));
|
||||
}
|
||||
|
||||
if (height < 1)
|
||||
{
|
||||
throw new ArgumentException("Must be > 1", nameof(height));
|
||||
}
|
||||
|
||||
Width = width;
|
||||
Height = height;
|
||||
|
||||
@ -104,6 +114,12 @@ namespace Spectre.Console
|
||||
{
|
||||
height = (int)(height * (maxWidth / (float)(width * PixelWidth)));
|
||||
width = maxWidth / PixelWidth;
|
||||
|
||||
// If it's not possible to scale the canvas sufficiently, it's too small to render.
|
||||
if (height == 0)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
// Need to rescale the pixel buffer?
|
||||
|
Reference in New Issue
Block a user