feat(ui-visuals): add layout, scale, decimation, viewport and curve math kernels
WPF-free geometry behind the visual controls: wrapped-grid layout with O(1) index/offset mapping and keyboard targets, nice axis ticks, min/max decimation, zoom/pan transforms, monotone curve editing rules, filmstrip and heatmap cell layout, an LRU cache and device-pixel snapping, with tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
16 files changed
+1410
No files matched your search
@@ -0,0 +1,34 @@
|
||||
using Titano.Testing;
|
||||
using Titano.Ui.Visuals;
|
||||
|
||||
namespace Titano.App.Tests.Visuals;
|
||||
|
||||
public sealed class PixelGridTests
|
||||
{
|
||||
[Theory]
|
||||
[Case(1.0)]
|
||||
[Case(1.25)]
|
||||
[Case(1.5)]
|
||||
[Case(2.0)]
|
||||
public void HairlinesCoverWholeDevicePixels(double scale)
|
||||
{
|
||||
var thickness = PixelGrid.SnapThickness(1, scale);
|
||||
var devicePixels = thickness * scale;
|
||||
Assert.Approximately(Math.Round(devicePixels), devicePixels, 1e-9);
|
||||
for (var v = 0.0; v < 50; v += 0.37)
|
||||
{
|
||||
var centre = PixelGrid.SnapLine(v, thickness, scale) * scale;
|
||||
var left = centre - devicePixels / 2;
|
||||
Assert.Approximately(Math.Round(left), left, 1e-9, $"v={v}");
|
||||
Assert.LessOrEqual(Math.Abs(centre - v * scale), 1);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SnapRoundsToDevicePixelBoundaries()
|
||||
{
|
||||
Assert.Approximately(10, PixelGrid.Snap(10.2, 1), 1e-12);
|
||||
Assert.Approximately(10 + 2 / 3.0, PixelGrid.Snap(10.6, 1.5), 1e-12);
|
||||
Assert.Approximately(3.3, PixelGrid.Snap(3.3, 0), 0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user