package world import ( "image/color" "testing" "github.com/fogleman/gg" "github.com/stretchr/testify/require" ) func TestGGDrawer_ClearRectTo_DoesNotAffectStrokeState(t *testing.T) { t.Parallel() dc := gg.NewContext(40, 20) d := &GGDrawer{DC: dc} // Fill background to white. d.ClearAllTo(color.RGBA{R: 255, G: 255, B: 255, A: 255}) // Configure stroke to red and draw first line. d.SetStrokeColor(color.RGBA{R: 255, A: 255}) d.SetLineWidth(2) d.AddLine(2, 5, 38, 5) d.Stroke() // Clear a rect in the middle with gray (must not affect stroke state). d.ClearRectTo(10, 0, 20, 20, color.RGBA{R: 200, G: 200, B: 200, A: 255}) // Draw second line WITHOUT reapplying stroke style; it must still be red. d.AddLine(2, 15, 38, 15) d.Stroke() img := dc.Image() // Sample a pixel from the second line (y ~15). We expect red channel dominates. r, g, b, a := img.At(20, 15).RGBA() require.Greater(t, a, uint32(0), "pixel must not be fully transparent") require.Greater(t, r, g, "expected red-ish pixel after ClearRectTo") require.Greater(t, r, b, "expected red-ish pixel after ClearRectTo") }