mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +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
|
g := float64(cc.G) / math.MaxUint16
|
||||||
b := float64(cc.B) / math.MaxUint16
|
b := float64(cc.B) / math.MaxUint16
|
||||||
a := float64(cc.A) / 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,
|
DstParts: dsts,
|
||||||
SrcParts: srcs,
|
SrcParts: srcs,
|
||||||
|
GeoM: ebiten.TranslateGeo(float64(x+1), float64(y)),
|
||||||
ColorM: ebiten.ScaleColor(r, g, b, a),
|
ColorM: ebiten.ScaleColor(r, g, b, a),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -50,16 +50,20 @@ func update(screen *ebiten.Image) error {
|
|||||||
}
|
}
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
op := &ebiten.DrawImageOptions{
|
op := &ebiten.DrawImageOptions{
|
||||||
|
GeoM: ebiten.TranslateGeo(15+float64(i)*diff, 20),
|
||||||
ColorM: ebiten.ScaleColor(1.0, 1.0, 1.0, 0.5),
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
screen.Fill(color.NRGBA{0x00, 0x00, 0x80, 0xff})
|
screen.Fill(color.NRGBA{0x00, 0x00, 0x80, 0xff})
|
||||||
for i := 0; i < 10; i++ {
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,15 +144,15 @@ func drawBlocks(r *ebiten.Image, images *Images, blocks [][]BlockType, x, y int)
|
|||||||
if block == BlockTypeNone {
|
if block == BlockTypeNone {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
locationX := i * blockWidth
|
locationX := i*blockWidth + x
|
||||||
locationY := j * blockHeight
|
locationY := j*blockHeight + y
|
||||||
dsts = append(dsts, image.Rect(locationX, locationY, locationX+blockWidth, locationY+blockHeight))
|
dsts = append(dsts, image.Rect(locationX, locationY, locationX+blockWidth, locationY+blockHeight))
|
||||||
srcX := (int(block) - 1) * blockWidth
|
srcX := (int(block) - 1) * blockWidth
|
||||||
srcs = append(srcs, image.Rect(srcX, 0, srcX+blockWidth, blockHeight))
|
srcs = append(srcs, image.Rect(srcX, 0, srcX+blockWidth, blockHeight))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blocksImage := images.GetImage("blocks")
|
blocksImage := images.GetImage("blocks")
|
||||||
r.DrawImageAt(blocksImage, x, y, &ebiten.DrawImageOptions{
|
r.DrawImage(blocksImage, &ebiten.DrawImageOptions{
|
||||||
SrcParts: srcs,
|
SrcParts: srcs,
|
||||||
DstParts: dsts,
|
DstParts: dsts,
|
||||||
})
|
})
|
||||||
|
@ -53,20 +53,21 @@ func drawTitleBackground(r *ebiten.Image, images *Images, c int) {
|
|||||||
const imageWidth = 32
|
const imageWidth = 32
|
||||||
const imageHeight = 32
|
const imageHeight = 32
|
||||||
|
|
||||||
|
dx := (-c / 4) % imageWidth
|
||||||
|
dy := (c / 4) % imageHeight
|
||||||
|
|
||||||
backgroundImage := images.GetImage("background")
|
backgroundImage := images.GetImage("background")
|
||||||
dsts, srcs := []image.Rectangle{}, []image.Rectangle{}
|
dsts, srcs := []image.Rectangle{}, []image.Rectangle{}
|
||||||
for j := -1; j < ScreenHeight/imageHeight+1; j++ {
|
for j := -1; j < ScreenHeight/imageHeight+1; j++ {
|
||||||
for i := 0; i < ScreenWidth/imageWidth+1; i++ {
|
for i := 0; i < ScreenWidth/imageWidth+1; i++ {
|
||||||
dstX := i * imageWidth
|
dstX := i*imageWidth + dx
|
||||||
dstY := j * imageHeight
|
dstY := j*imageHeight + dy
|
||||||
dsts = append(dsts, image.Rect(dstX, dstY, dstX+imageWidth, dstY+imageHeight))
|
dsts = append(dsts, image.Rect(dstX, dstY, dstX+imageWidth, dstY+imageHeight))
|
||||||
srcs = append(srcs, image.Rect(0, 0, imageWidth, imageHeight))
|
srcs = append(srcs, image.Rect(0, 0, imageWidth, imageHeight))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dx := (-c / 4) % imageWidth
|
r.DrawImage(backgroundImage, &ebiten.DrawImageOptions{
|
||||||
dy := (c / 4) % imageHeight
|
|
||||||
r.DrawImageAt(backgroundImage, dx, dy, &ebiten.DrawImageOptions{
|
|
||||||
SrcParts: srcs,
|
SrcParts: srcs,
|
||||||
DstParts: dsts,
|
DstParts: dsts,
|
||||||
})
|
})
|
||||||
|
@ -45,7 +45,8 @@ func Update(screen *ebiten.Image) error {
|
|||||||
clr := ebiten.ScaleColor(1.0, 0.25, 0.25, 1.0)
|
clr := ebiten.ScaleColor(1.0, 0.25, 0.25, 1.0)
|
||||||
theta := 2.0 * math.Pi * float64(count%60) / 60.0
|
theta := 2.0 * math.Pi * float64(count%60) / 60.0
|
||||||
clr.Concat(ebiten.RotateHue(theta))
|
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,
|
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)
|
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) {
|
func (i *Image) drawImage(image *innerImage, option *DrawImageOptions) (err error) {
|
||||||
i.pixels = nil
|
i.pixels = nil
|
||||||
i.syncer.Sync(func() {
|
i.syncer.Sync(func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user