mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
Revert "internal/restorable: refactoring"
This reverts commit 81e1104613
.
Updates #3083
This commit is contained in:
parent
19d2009a5f
commit
becada4afc
@ -88,10 +88,7 @@ func clearImage(i *graphicscommand.Image, region image.Rectangle) {
|
|||||||
|
|
||||||
// ClearPixels clears the specified region by WritePixels.
|
// ClearPixels clears the specified region by WritePixels.
|
||||||
func (i *Image) ClearPixels(region image.Rectangle) {
|
func (i *Image) ClearPixels(region image.Rectangle) {
|
||||||
if region.Dx() <= 0 || region.Dy() <= 0 {
|
i.WritePixels(nil, region)
|
||||||
panic("restorable: width/height must be positive")
|
|
||||||
}
|
|
||||||
clearImage(i.Image, region.Intersect(image.Rect(0, 0, i.width, i.height)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WritePixels replaces the image pixels with the given pixels slice.
|
// WritePixels replaces the image pixels with the given pixels slice.
|
||||||
@ -106,7 +103,11 @@ func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangl
|
|||||||
panic(fmt.Sprintf("restorable: out of range %v", region))
|
panic(fmt.Sprintf("restorable: out of range %v", region))
|
||||||
}
|
}
|
||||||
|
|
||||||
i.Image.WritePixels(pixels, region)
|
if pixels != nil {
|
||||||
|
i.Image.WritePixels(pixels, region)
|
||||||
|
} else {
|
||||||
|
clearImage(i.Image, region)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DrawTriangles draws triangles with the given image.
|
// DrawTriangles draws triangles with the given image.
|
||||||
|
Loading…
Reference in New Issue
Block a user