mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ebiten: refactoring
This commit is contained in:
parent
c4b8378b71
commit
ead3f32df0
17
image.go
17
image.go
@ -93,9 +93,7 @@ func (i *Image) Fill(clr color.Color) {
|
|||||||
cgf = float32(cg) / 0xffff
|
cgf = float32(cg) / 0xffff
|
||||||
cbf = float32(cb) / 0xffff
|
cbf = float32(cb) / 0xffff
|
||||||
caf = float32(ca) / 0xffff
|
caf = float32(ca) / 0xffff
|
||||||
b := i.Bounds()
|
i.image.Fill(crf, cgf, cbf, caf, i.adjustedBounds())
|
||||||
x, y := i.adjustPosition(b.Min.X, b.Min.Y)
|
|
||||||
i.image.Fill(crf, cgf, cbf, caf, image.Rect(x, y, x+b.Dx(), y+b.Dy()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func canSkipMipmap(geom GeoM, filter builtinshader.Filter) bool {
|
func canSkipMipmap(geom GeoM, filter builtinshader.Filter) bool {
|
||||||
@ -172,6 +170,12 @@ func (i *Image) adjustPositionF32(x, y float32) (float32, float32) {
|
|||||||
return x, y
|
return x, y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *Image) adjustedBounds() image.Rectangle {
|
||||||
|
b := i.Bounds()
|
||||||
|
x, y := i.adjustPosition(b.Min.X, b.Min.Y)
|
||||||
|
return image.Rect(x, y, x+b.Dx(), y+b.Dy())
|
||||||
|
}
|
||||||
|
|
||||||
func (i *Image) adjustedRegion() graphicsdriver.Region {
|
func (i *Image) adjustedRegion() graphicsdriver.Region {
|
||||||
b := i.Bounds()
|
b := i.Bounds()
|
||||||
x, y := i.adjustPosition(b.Min.X, b.Min.Y)
|
x, y := i.adjustPosition(b.Min.X, b.Min.Y)
|
||||||
@ -886,8 +890,7 @@ func (i *Image) ReadPixels(pixels []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
x, y := i.adjustPosition(b.Min.X, b.Min.Y)
|
i.image.ReadPixels(pixels, i.adjustedBounds())
|
||||||
i.image.ReadPixels(pixels, image.Rect(x, y, x+b.Dx(), y+b.Dy()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// At returns the color of the image at (x, y).
|
// At returns the color of the image at (x, y).
|
||||||
@ -998,12 +1001,10 @@ func (i *Image) WritePixels(pixels []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r := i.Bounds()
|
|
||||||
x, y := i.adjustPosition(r.Min.X, r.Min.Y)
|
|
||||||
// Do not need to copy pixels here.
|
// Do not need to copy pixels here.
|
||||||
// * In internal/mipmap, pixels are copied when necessary.
|
// * In internal/mipmap, pixels are copied when necessary.
|
||||||
// * In internal/atlas, pixels are copied to make its paddings.
|
// * In internal/atlas, pixels are copied to make its paddings.
|
||||||
i.image.WritePixels(pixels, image.Rect(x, y, x+r.Dx(), y+r.Dy()))
|
i.image.WritePixels(pixels, i.adjustedBounds())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplacePixels replaces the pixels of the image.
|
// ReplacePixels replaces the pixels of the image.
|
||||||
|
Loading…
Reference in New Issue
Block a user