mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Remove DrawImageAt
This commit is contained in:
parent
20da9bffbb
commit
7849a68cd0
@ -58,9 +58,10 @@ func (d *debugPrintState) drawText(rt *ebiten.Image, str string, x, y int, c col
|
||||
g := float64(cc.G) / math.MaxUint16
|
||||
b := float64(cc.B) / math.MaxUint16
|
||||
a := float64(cc.A) / math.MaxUint16
|
||||
rt.DrawImageAt(d.textImage, x+1, y, &ebiten.DrawImageOptions{
|
||||
rt.DrawImage(d.textImage, &ebiten.DrawImageOptions{
|
||||
DstParts: dsts,
|
||||
SrcParts: srcs,
|
||||
GeoM: ebiten.TranslateGeo(float64(x+1), float64(y)),
|
||||
ColorM: ebiten.ScaleColor(r, g, b, a),
|
||||
})
|
||||
}
|
||||
|
@ -50,16 +50,20 @@ func update(screen *ebiten.Image) error {
|
||||
}
|
||||
for i := 0; i < 10; i++ {
|
||||
op := &ebiten.DrawImageOptions{
|
||||
GeoM: ebiten.TranslateGeo(15+float64(i)*diff, 20),
|
||||
ColorM: ebiten.ScaleColor(1.0, 1.0, 1.0, 0.5),
|
||||
}
|
||||
if err := tmpRenderTarget.DrawImageAt(ebitenImage, 15+int(float64(i)*diff), 20, op); err != nil {
|
||||
if err := tmpRenderTarget.DrawImage(ebitenImage, op); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
screen.Fill(color.NRGBA{0x00, 0x00, 0x80, 0xff})
|
||||
for i := 0; i < 10; i++ {
|
||||
if err := screen.DrawImageAt(tmpRenderTarget, 0, int(float64(i)*diff), nil); err != nil {
|
||||
op := &ebiten.DrawImageOptions{
|
||||
GeoM: ebiten.TranslateGeo(0, float64(i)*diff),
|
||||
}
|
||||
if err := screen.DrawImage(tmpRenderTarget, op); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -144,15 +144,15 @@ func drawBlocks(r *ebiten.Image, images *Images, blocks [][]BlockType, x, y int)
|
||||
if block == BlockTypeNone {
|
||||
continue
|
||||
}
|
||||
locationX := i * blockWidth
|
||||
locationY := j * blockHeight
|
||||
locationX := i*blockWidth + x
|
||||
locationY := j*blockHeight + y
|
||||
dsts = append(dsts, image.Rect(locationX, locationY, locationX+blockWidth, locationY+blockHeight))
|
||||
srcX := (int(block) - 1) * blockWidth
|
||||
srcs = append(srcs, image.Rect(srcX, 0, srcX+blockWidth, blockHeight))
|
||||
}
|
||||
}
|
||||
blocksImage := images.GetImage("blocks")
|
||||
r.DrawImageAt(blocksImage, x, y, &ebiten.DrawImageOptions{
|
||||
r.DrawImage(blocksImage, &ebiten.DrawImageOptions{
|
||||
SrcParts: srcs,
|
||||
DstParts: dsts,
|
||||
})
|
||||
|
@ -53,20 +53,21 @@ func drawTitleBackground(r *ebiten.Image, images *Images, c int) {
|
||||
const imageWidth = 32
|
||||
const imageHeight = 32
|
||||
|
||||
dx := (-c / 4) % imageWidth
|
||||
dy := (c / 4) % imageHeight
|
||||
|
||||
backgroundImage := images.GetImage("background")
|
||||
dsts, srcs := []image.Rectangle{}, []image.Rectangle{}
|
||||
for j := -1; j < ScreenHeight/imageHeight+1; j++ {
|
||||
for i := 0; i < ScreenWidth/imageWidth+1; i++ {
|
||||
dstX := i * imageWidth
|
||||
dstY := j * imageHeight
|
||||
dstX := i*imageWidth + dx
|
||||
dstY := j*imageHeight + dy
|
||||
dsts = append(dsts, image.Rect(dstX, dstY, dstX+imageWidth, dstY+imageHeight))
|
||||
srcs = append(srcs, image.Rect(0, 0, imageWidth, imageHeight))
|
||||
}
|
||||
}
|
||||
|
||||
dx := (-c / 4) % imageWidth
|
||||
dy := (c / 4) % imageHeight
|
||||
r.DrawImageAt(backgroundImage, dx, dy, &ebiten.DrawImageOptions{
|
||||
r.DrawImage(backgroundImage, &ebiten.DrawImageOptions{
|
||||
SrcParts: srcs,
|
||||
DstParts: dsts,
|
||||
})
|
||||
|
@ -45,7 +45,8 @@ func Update(screen *ebiten.Image) error {
|
||||
clr := ebiten.ScaleColor(1.0, 0.25, 0.25, 1.0)
|
||||
theta := 2.0 * math.Pi * float64(count%60) / 60.0
|
||||
clr.Concat(ebiten.RotateHue(theta))
|
||||
canvasRenderTarget.DrawImageAt(brushRenderTarget, mx, my, &ebiten.DrawImageOptions{
|
||||
canvasRenderTarget.DrawImage(brushRenderTarget, &ebiten.DrawImageOptions{
|
||||
GeoM: ebiten.TranslateGeo(float64(mx), float64(my)),
|
||||
ColorM: clr,
|
||||
})
|
||||
}
|
||||
|
11
image.go
11
image.go
@ -161,17 +161,6 @@ func (i *Image) DrawImage(image *Image, options *DrawImageOptions) (err error) {
|
||||
return i.drawImage(image.inner, options)
|
||||
}
|
||||
|
||||
// DrawImageAt draws the given image on the receiver image at the position (x, y).
|
||||
//
|
||||
// If a geometry matrix is specified, the geometry matrix is applied ahead of translating the image by (x, y).
|
||||
func (i *Image) DrawImageAt(image *Image, x, y int, options *DrawImageOptions) (err error) {
|
||||
if options == nil {
|
||||
options = &DrawImageOptions{}
|
||||
}
|
||||
options.GeoM.Concat(TranslateGeo(float64(x), float64(y)))
|
||||
return i.drawImage(image.inner, options)
|
||||
}
|
||||
|
||||
func (i *Image) drawImage(image *innerImage, option *DrawImageOptions) (err error) {
|
||||
i.pixels = nil
|
||||
i.syncer.Sync(func() {
|
||||
|
Loading…
Reference in New Issue
Block a user