ui: basic map scroller

This commit is contained in:
Ilia Denisov
2026-03-06 23:29:06 +02:00
committed by GitHub
parent 29d188969b
commit 1de621c743
68 changed files with 9861 additions and 118 deletions
+58
View File
@@ -0,0 +1,58 @@
package world
import (
"image/color"
"testing"
"github.com/stretchr/testify/require"
)
func TestWorldRender_AppliesLineStyle(t *testing.T) {
t.Parallel()
w := NewWorld(10, 10)
w.resetGrid(2 * SCALE)
_, err := w.AddLine(9, 5, 1, 5)
require.NoError(t, err)
for _, obj := range w.objects {
w.indexObject(obj)
}
custom := DefaultRenderStyle()
custom.LineWidthPx = 3
custom.LineDash = []float64{5, 2}
custom.LineDashOffset = 1
custom.LineStroke = color.RGBA{R: 255, A: 255}
params := RenderParams{
ViewportWidthPx: 10,
ViewportHeightPx: 10,
MarginXPx: 2,
MarginYPx: 2,
CameraXWorldFp: 5 * SCALE,
CameraYWorldFp: 5 * SCALE,
CameraZoom: 1.0,
Options: &RenderOptions{
Layers: []RenderLayer{RenderLayerLines},
Style: &custom,
},
}
d := &fakePrimitiveDrawer{}
err = w.Render(d, params)
require.NoError(t, err)
// There must be at least one AddLine call, and every AddLine must observe
// the configured line state snapshot.
cmds := d.CommandsByName("AddLine")
require.NotEmpty(t, cmds)
for _, cmd := range cmds {
require.Equal(t, 3.0, cmd.LineWidth)
require.Equal(t, []float64{5, 2}, cmd.Dashes)
require.Equal(t, 1.0, cmd.DashOffset)
require.Equal(t, color.RGBA{R: 255, A: 255}, cmd.StrokeColor)
}
}