themes and styles
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package world
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestRender_CircleRadiusScale_AffectsRenderedRadiusPx(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
w := NewWorld(10, 10)
|
||||
w.resetGrid(2 * SCALE)
|
||||
|
||||
// Ensure index state is initialized so Add triggers rebuild if needed.
|
||||
w.IndexOnViewportChange(10, 10, 1.0)
|
||||
|
||||
_, err := w.AddCircle(5, 5, 2) // raw radius = 2 units
|
||||
require.NoError(t, err)
|
||||
|
||||
// scale = 2.0
|
||||
require.NoError(t, w.SetCircleRadiusScaleFp(2*SCALE))
|
||||
|
||||
// Reindex explicitly (safe).
|
||||
w.Reindex()
|
||||
|
||||
params := RenderParams{
|
||||
ViewportWidthPx: 10,
|
||||
ViewportHeightPx: 10,
|
||||
MarginXPx: 0,
|
||||
MarginYPx: 0,
|
||||
CameraXWorldFp: 5 * SCALE,
|
||||
CameraYWorldFp: 5 * SCALE,
|
||||
CameraZoom: 1.0,
|
||||
Options: &RenderOptions{
|
||||
BackgroundColor: color.RGBA{A: 255},
|
||||
},
|
||||
}
|
||||
|
||||
d := &fakePrimitiveDrawer{}
|
||||
require.NoError(t, w.Render(d, params))
|
||||
|
||||
circles := d.CommandsByName("AddCircle")
|
||||
require.NotEmpty(t, circles)
|
||||
|
||||
// AddCircle args: cx, cy, rPx
|
||||
rPx := circles[0].Args[2]
|
||||
require.Equal(t, float64(4), rPx, "raw radius=2 with scale=2 => eff radius=4 => rPx=4 at zoom=1")
|
||||
}
|
||||
Reference in New Issue
Block a user