mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ebiten: Remove the returning value from (*Image).DrawImage
Updates #1380
This commit is contained in:
parent
04bbe1ebb6
commit
54da0d9763
@ -78,7 +78,7 @@ func drawDebugText(rt *ebiten.Image, str string, ox, oy int, shadow bool) {
|
||||
op.GeoM.Reset()
|
||||
op.GeoM.Translate(float64(x), float64(y))
|
||||
op.GeoM.Translate(float64(ox+1), float64(oy))
|
||||
_ = rt.DrawImage(s, op)
|
||||
rt.DrawImage(s, op)
|
||||
x += cw
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func DrawLine(dst *ebiten.Image, x1, y1, x2, y2 float64, clr color.Color) {
|
||||
op.ColorM = colormcache.ColorToColorM(clr)
|
||||
// Filter must be 'nearest' filter (default).
|
||||
// Linear filtering would make edges blurred.
|
||||
_ = dst.DrawImage(emptyImage, op)
|
||||
dst.DrawImage(emptyImage, op)
|
||||
}
|
||||
|
||||
// DrawRect draws a rectangle on the given destination dst.
|
||||
@ -64,5 +64,5 @@ func DrawRect(dst *ebiten.Image, x, y, width, height float64, clr color.Color) {
|
||||
op.ColorM = colormcache.ColorToColorM(clr)
|
||||
// Filter must be 'nearest' filter (default).
|
||||
// Linear filtering would make edges blurred.
|
||||
_ = dst.DrawImage(emptyImage, op)
|
||||
dst.DrawImage(emptyImage, op)
|
||||
}
|
||||
|
@ -103,8 +103,8 @@ func (c *Camera) worldMatrix() ebiten.GeoM {
|
||||
return m
|
||||
}
|
||||
|
||||
func (c *Camera) Render(world, screen *ebiten.Image) error {
|
||||
return screen.DrawImage(world, &ebiten.DrawImageOptions{
|
||||
func (c *Camera) Render(world, screen *ebiten.Image) {
|
||||
screen.DrawImage(world, &ebiten.DrawImageOptions{
|
||||
GeoM: c.worldMatrix(),
|
||||
})
|
||||
}
|
||||
|
7
image.go
7
image.go
@ -154,16 +154,14 @@ type DrawImageOptions struct {
|
||||
// share the texture atlas with high probability.
|
||||
//
|
||||
// For more performance tips, see https://ebiten.org/documents/performancetips.html
|
||||
//
|
||||
// DrawImage always returns nil as of 1.5.0.
|
||||
func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
|
||||
func (i *Image) DrawImage(img *Image, options *DrawImageOptions) {
|
||||
i.copyCheck()
|
||||
|
||||
if img.isDisposed() {
|
||||
panic("ebiten: the given image to DrawImage must not be disposed")
|
||||
}
|
||||
if i.isDisposed() {
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Implement this.
|
||||
@ -192,7 +190,6 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
|
||||
|
||||
srcs := [graphics.ShaderImageNum]*mipmap.Mipmap{img.mipmap}
|
||||
i.mipmap.DrawTriangles(srcs, vs, is, options.ColorM.impl, mode, filter, driver.AddressUnsafe, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, canSkipMipmap(options.GeoM, filter))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Vertex represents a vertex passed to DrawTriangles.
|
||||
|
@ -142,18 +142,9 @@ func TestImageComposition(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
if err := img2.DrawImage(img1, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
if err := img3.DrawImage(img2, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
if err := img_12_3.DrawImage(img3, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
img2.DrawImage(img1, nil)
|
||||
img3.DrawImage(img2, nil)
|
||||
img_12_3.DrawImage(img3, nil)
|
||||
|
||||
img2.Fill(img2Color)
|
||||
img3.Fill(img3Color)
|
||||
@ -162,18 +153,9 @@ func TestImageComposition(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
if err := img3.DrawImage(img2, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
if err := img3.DrawImage(img1, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
if err := img_1_23.DrawImage(img3, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
img3.DrawImage(img2, nil)
|
||||
img3.DrawImage(img1, nil)
|
||||
img_1_23.DrawImage(img3, nil)
|
||||
|
||||
for j := 0; j < h; j++ {
|
||||
for i := 0; i < w; i++ {
|
||||
@ -223,10 +205,7 @@ func TestImageScale(t *testing.T) {
|
||||
op := &DrawImageOptions{}
|
||||
op.GeoM.Scale(float64(scale), float64(scale))
|
||||
|
||||
if err := img1.DrawImage(img0, op); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
img1.DrawImage(img0, op)
|
||||
|
||||
for j := 0; j < h*scale; j++ {
|
||||
for i := 0; i < w*scale; i++ {
|
||||
@ -255,10 +234,7 @@ func TestImage90DegreeRotate(t *testing.T) {
|
||||
op := &DrawImageOptions{}
|
||||
op.GeoM.Rotate(math.Pi / 2)
|
||||
op.GeoM.Translate(float64(h), 0)
|
||||
if err := img1.DrawImage(img0, op); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
img1.DrawImage(img0, op)
|
||||
|
||||
for j := 0; j < h; j++ {
|
||||
for i := 0; i < w; i++ {
|
||||
@ -286,10 +262,7 @@ func TestImageDotByDotInversion(t *testing.T) {
|
||||
op := &DrawImageOptions{}
|
||||
op.GeoM.Rotate(math.Pi)
|
||||
op.GeoM.Translate(float64(w), float64(h))
|
||||
if err := img1.DrawImage(img0, op); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
img1.DrawImage(img0, op)
|
||||
|
||||
for j := 0; j < h; j++ {
|
||||
for i := 0; i < w; i++ {
|
||||
@ -411,10 +384,7 @@ func TestImageCompositeModeLighter(t *testing.T) {
|
||||
img1.Fill(color.RGBA{0x01, 0x02, 0x03, 0x04})
|
||||
op := &DrawImageOptions{}
|
||||
op.CompositeMode = CompositeModeLighter
|
||||
if err := img1.DrawImage(img0, op); err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
img1.DrawImage(img0, op)
|
||||
for j := 0; j < img1.Bounds().Size().Y; j++ {
|
||||
for i := 0; i < img1.Bounds().Size().X; i++ {
|
||||
got := img1.At(i, j).(color.RGBA)
|
||||
|
@ -56,7 +56,7 @@ func drawGlyph(dst *ebiten.Image, face font.Face, r rune, img *ebiten.Image, x,
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(float64((x+b.Min.X)>>6), float64((y+b.Min.Y)>>6))
|
||||
op.ColorM = clr
|
||||
_ = dst.DrawImage(img, op)
|
||||
dst.DrawImage(img, op)
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -240,7 +240,7 @@ func (c *uiContext) draw() {
|
||||
} else {
|
||||
op.Filter = FilterLinear
|
||||
}
|
||||
_ = c.screen.DrawImage(c.offscreen, op)
|
||||
c.screen.DrawImage(c.offscreen, op)
|
||||
}
|
||||
|
||||
func (c *uiContext) AdjustPosition(x, y float64) (float64, float64) {
|
||||
|
Loading…
Reference in New Issue
Block a user