mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
e804f9e58c
commit
81e1104613
@ -96,7 +96,10 @@ func clearImage(i *graphicscommand.Image, region image.Rectangle) {
|
||||
|
||||
// ClearPixels clears the specified region by WritePixels.
|
||||
func (i *Image) ClearPixels(region image.Rectangle) {
|
||||
i.WritePixels(nil, region)
|
||||
if region.Dx() <= 0 || region.Dy() <= 0 {
|
||||
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.
|
||||
@ -111,11 +114,7 @@ func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangl
|
||||
panic(fmt.Sprintf("restorable: out of range %v", region))
|
||||
}
|
||||
|
||||
if pixels != nil {
|
||||
i.Image.WritePixels(pixels, region)
|
||||
} else {
|
||||
clearImage(i.Image, region)
|
||||
}
|
||||
}
|
||||
|
||||
// DrawTriangles draws triangles with the given image.
|
||||
|
Loading…
Reference in New Issue
Block a user