no-wrap option; pivoted exponential zoom

This commit is contained in:
Ilia Denisov
2026-03-07 11:35:18 +02:00
committed by GitHub
parent 1de621c743
commit 477e656008
22 changed files with 605 additions and 81 deletions
+39 -2
View File
@@ -31,7 +31,7 @@ func TestDrawLinesFromPlan_WrapX_SplitsAndDrawsInThreeXTiles(t *testing.T) {
require.NoError(t, err)
d := &fakePrimitiveDrawer{}
drawLinesFromPlan(d, plan, w.W, w.H)
drawLinesFromPlan(d, plan, w.W, w.H, true)
// Expect drawing in 3 X tiles (left partial, middle full, right partial) for the central Y tile:
// Each tile group: Save, ClipRect, AddLine(s), Stroke, Restore
@@ -95,7 +95,7 @@ func TestDrawLinesFromPlan_WrapY_SplitsAndDrawsInThreeYTiles(t *testing.T) {
require.NoError(t, err)
d := &fakePrimitiveDrawer{}
drawLinesFromPlan(d, plan, w.W, w.H)
drawLinesFromPlan(d, plan, w.W, w.H, true)
// Here we expect 3 Y tiles for the central X tile:
// Top partial, middle full (two segments), bottom partial.
@@ -156,3 +156,40 @@ func TestTorusShortestLineSegments_TieCaseIsDeterministicAndSplits(t *testing.T)
require.Equal(t, lineSeg{x1: 1000, y1: 5000, x2: 0, y2: 5000}, segs[0])
require.Equal(t, lineSeg{x1: 10000, y1: 5000, x2: 6000, y2: 5000}, segs[1])
}
func TestLines_NoWrap_TieCaseDoesNotWrap(t *testing.T) {
t.Parallel()
w := NewWorld(10, 10)
w.resetGrid(2 * SCALE)
// Tie-case along X: 1 -> 6 in world of 10.
_, err := w.AddLine(1, 5, 6, 5)
require.NoError(t, err)
for _, obj := range w.objects {
w.indexObject(obj)
}
params := RenderParams{
ViewportWidthPx: 10,
ViewportHeightPx: 10,
MarginXPx: 0,
MarginYPx: 0,
CameraXWorldFp: 5 * SCALE,
CameraYWorldFp: 5 * SCALE,
CameraZoom: 1.0,
Options: &RenderOptions{
DisableWrapScroll: true,
Layers: []RenderLayer{RenderLayerLines},
},
}
d := &fakePrimitiveDrawer{}
require.NoError(t, w.Render(d, params))
lines := d.CommandsByName("AddLine")
require.Len(t, lines, 1)
// At zoom=1 and margin=0, world==canvas, so pixels equal world units.
require.Equal(t, []float64{1, 5, 6, 5}, lines[0].Args)
}