fixes and stuff

This commit is contained in:
tyuXX 2026-10-29 11:45:21 +03:00
parent 99fd7ab61a
commit 5db8423cdb
3 changed files with 153 additions and 26 deletions

View file

@ -158,5 +158,46 @@ public static class BrailleCanvasTests
}
Assert.True(cyanCells > 0, "Expected Cyan cells for line y=x");
});
runner.Add("PlotRenderer: Grid, axes, and ticks render far from origin", () =>
{
var canvas = new BrailleCanvas(30, 20);
var vp = new Viewport
{
XMin = 500,
XMax = 550,
YMin = 200,
YMax = 250
};
// Origin (0, 0) is far off screen in both dimensions
var ticks = PlotRenderer.Render(canvas, vp, [], _ => 0, showGrid: true);
// 1. Ticks should be computed for both X and Y axes
Assert.True(ticks.Count > 0, "Expected axis tick numbers when far from origin");
bool hasXTick = ticks.Any(t => t.IsXAxis);
bool hasYTick = ticks.Any(t => !t.IsXAxis);
Assert.True(hasXTick, "Expected X axis tick numbers when far from origin");
Assert.True(hasYTick, "Expected Y axis tick numbers when far from origin");
// 2. Grid dots and Axis lines should be rasterized on canvas
int gridCells = 0;
int axisCells = 0;
for (int r = 0; r < canvas.CellHeight; r++)
{
for (int c = 0; c < canvas.CellWidth; c++)
{
var (ch, fg, _) = canvas.GetCell(c, r);
if (ch != ' ')
{
if (fg == ColorRgb.GridLine) gridCells++;
if (fg == ColorRgb.AxisLine) axisCells++;
}
}
}
Assert.True(gridCells > 0, $"Expected background grid line cells far from origin, got {gridCells}");
Assert.True(axisCells > 0, $"Expected reference axis line cells far from origin, got {axisCells}");
});
}
}