mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 12:08:58 +01:00
parent
1a54ff34e6
commit
962a11468b
@ -524,6 +524,36 @@ func TestImageFill(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue #740
|
||||||
|
func TestImageClear(t *testing.T) {
|
||||||
|
const w, h = 128, 256
|
||||||
|
img, err := NewImage(w, h, FilterNearest)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
img.Fill(color.White)
|
||||||
|
for j := 0; j < h; j++ {
|
||||||
|
for i := 0; i < w; i++ {
|
||||||
|
got := img.At(i, j)
|
||||||
|
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
||||||
|
if got != want {
|
||||||
|
t.Errorf("img At(%d, %d): got %#v; want %#v", i, j, got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
img.Clear()
|
||||||
|
for j := 0; j < h; j++ {
|
||||||
|
for i := 0; i < w; i++ {
|
||||||
|
got := img.At(i, j)
|
||||||
|
want := color.RGBA{}
|
||||||
|
if got != want {
|
||||||
|
t.Errorf("img At(%d, %d): got %#v; want %#v", i, j, got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Issue #317, #558, #724
|
// Issue #317, #558, #724
|
||||||
func TestImageEdge(t *testing.T) {
|
func TestImageEdge(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
|
@ -157,9 +157,11 @@ func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) {
|
|||||||
// This means dummyImage might not be restored yet when this image is restored.
|
// This means dummyImage might not be restored yet when this image is restored.
|
||||||
// However, that's ok since this image will be stale or have updated pixel data
|
// However, that's ok since this image will be stale or have updated pixel data
|
||||||
// and this image can be restored without dummyImage.
|
// and this image can be restored without dummyImage.
|
||||||
w, h := dummyImage.Size()
|
dw, dh := dummyImage.Size()
|
||||||
vs := graphics.QuadVertices(w, h, 0, 0, w, h,
|
w2 := graphics.NextPowerOf2Int(w)
|
||||||
float32(width)/float32(w), 0, 0, float32(height)/float32(h),
|
h2 := graphics.NextPowerOf2Int(h)
|
||||||
|
vs := graphics.QuadVertices(w2, h2, 0, 0, dw, dh,
|
||||||
|
float32(width)/float32(dw), 0, 0, float32(height)/float32(dh),
|
||||||
float32(x), float32(y),
|
float32(x), float32(y),
|
||||||
0, 0, 0, 0)
|
0, 0, 0, 0)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
|
Loading…
Reference in New Issue
Block a user