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