diff --git a/ebitenutil/debugprint.go b/ebitenutil/debugprint.go index 19006dbf2..9e1292917 100644 --- a/ebitenutil/debugprint.go +++ b/ebitenutil/debugprint.go @@ -58,11 +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 - clr := ebiten.ScaleColor(r, g, b, a) rt.DrawImageAt(d.textImage, x+1, y, &ebiten.DrawImageOptions{ DstParts: dsts, SrcParts: srcs, - ColorMatrix: &clr, + ColorMatrix: ebiten.ScaleColor(r, g, b, a), }) } diff --git a/example/alphablending/main.go b/example/alphablending/main.go index 600f43214..b57fa7c99 100644 --- a/example/alphablending/main.go +++ b/example/alphablending/main.go @@ -49,9 +49,8 @@ func update(screen *ebiten.Image) error { return err } for i := 0; i < 10; i++ { - clr := ebiten.ScaleColor(1.0, 1.0, 1.0, 0.5) op := &ebiten.DrawImageOptions{ - ColorMatrix: &clr, + ColorMatrix: ebiten.ScaleColor(1.0, 1.0, 1.0, 0.5), } if err := tmpRenderTarget.DrawImageAt(ebitenImage, 15+int(float64(i)*diff), 20, op); err != nil { return err diff --git a/example/blocks/blocks/font.go b/example/blocks/blocks/font.go index 5aa20c471..b7eb084f9 100644 --- a/example/blocks/blocks/font.go +++ b/example/blocks/blocks/font.go @@ -63,8 +63,8 @@ func drawText(rt *ebiten.Image, images *Images, str string, ox, oy, scale int, c rt.DrawImage(fontImageId, &ebiten.DrawImageOptions{ DstParts: dsts, SrcParts: srcs, - GeometryMatrix: &geo, - ColorMatrix: &clr, + GeometryMatrix: geo, + ColorMatrix: clr, }) } diff --git a/example/blocks/blocks/gamescene.go b/example/blocks/blocks/gamescene.go index 59e1a29da..b175c5d72 100644 --- a/example/blocks/blocks/gamescene.go +++ b/example/blocks/blocks/gamescene.go @@ -114,10 +114,9 @@ func (s *GameScene) Draw(r *ebiten.Image, images *Images) { w, h := field.Size() geo := ebiten.ScaleGeometry(float64(fieldWidth)/float64(w), float64(fieldHeight)/float64(h)) geo.Concat(ebiten.TranslateGeometry(20, 20)) // TODO: magic number? - clr := ebiten.ScaleColor(0.0, 0.0, 0.0, 0.5) r.DrawImage(field, &ebiten.DrawImageOptions{ - GeometryMatrix: &geo, - ColorMatrix: &clr, + GeometryMatrix: geo, + ColorMatrix: ebiten.ScaleColor(0.0, 0.0, 0.0, 0.5), }) s.field.Draw(r, images, 20, 20) diff --git a/example/blocks/blocks/scenemanager.go b/example/blocks/blocks/scenemanager.go index a0ee6ac6e..e78f78140 100644 --- a/example/blocks/blocks/scenemanager.go +++ b/example/blocks/blocks/scenemanager.go @@ -74,9 +74,8 @@ func (s *SceneManager) Draw(r *ebiten.Image, images *Images) { r.DrawImage(from, nil) alpha := float64(s.transitionCount) / float64(transitionMaxCount) - clr := ebiten.ScaleColor(1, 1, 1, alpha) op := &ebiten.DrawImageOptions{ - ColorMatrix: &clr, + ColorMatrix: ebiten.ScaleColor(1, 1, 1, alpha), } r.DrawImage(to, op) } diff --git a/example/mosaic/main.go b/example/mosaic/main.go index 44bfc9190..3baacceab 100644 --- a/example/mosaic/main.go +++ b/example/mosaic/main.go @@ -34,14 +34,11 @@ var ( ) func update(screen *ebiten.Image) error { - geo := ebiten.ScaleGeometry(1.0/mosaicRatio, 1.0/mosaicRatio) gophersRenderTarget.DrawImage(gophersImage, &ebiten.DrawImageOptions{ - GeometryMatrix: &geo, + GeometryMatrix: ebiten.ScaleGeometry(1.0/mosaicRatio, 1.0/mosaicRatio), }) - - geo = ebiten.ScaleGeometry(mosaicRatio, mosaicRatio) screen.DrawImage(gophersRenderTarget, &ebiten.DrawImageOptions{ - GeometryMatrix: &geo, + GeometryMatrix: ebiten.ScaleGeometry(mosaicRatio, mosaicRatio), }) return nil } diff --git a/example/paint/main.go b/example/paint/main.go index 73a98bc06..7fb0f573d 100644 --- a/example/paint/main.go +++ b/example/paint/main.go @@ -46,7 +46,7 @@ func Update(screen *ebiten.Image) error { theta := 2.0 * math.Pi * float64(count%60) / 60.0 clr.Concat(ebiten.RotateHue(theta)) canvasRenderTarget.DrawImageAt(brushRenderTarget, mx, my, &ebiten.DrawImageOptions{ - ColorMatrix: &clr, + ColorMatrix: clr, }) } diff --git a/example/perspective/main.go b/example/perspective/main.go index e9a17a4a5..39285aecc 100644 --- a/example/perspective/main.go +++ b/example/perspective/main.go @@ -46,7 +46,7 @@ func update(screen *ebiten.Image) error { screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{ DstParts: dsts, SrcParts: srcs, - GeometryMatrix: &geo, + GeometryMatrix: geo, }) return nil } diff --git a/example/rotate/main.go b/example/rotate/main.go index 35028baf3..e8c2e0a6e 100644 --- a/example/rotate/main.go +++ b/example/rotate/main.go @@ -57,7 +57,7 @@ func update(screen *ebiten.Image) error { geo.Concat(ebiten.RotateGeometry(float64(count%720) * 2 * math.Pi / 720)) geo.Concat(ebiten.TranslateGeometry(screenWidth/2, screenHeight/2)) if err := screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{ - GeometryMatrix: &geo, + GeometryMatrix: geo, }); err != nil { return err } diff --git a/graphicscontext.go b/graphicscontext.go index 6c214614f..fb9273133 100644 --- a/graphicscontext.go +++ b/graphicscontext.go @@ -66,11 +66,8 @@ func (c *graphicsContext) postUpdate() error { } scale := float64(c.screenScale) - geo := ScaleGeometry(scale, scale) - clr := NewColorMatrix() option := &DrawImageOptions{ - GeometryMatrix: &geo, - ColorMatrix: &clr, + GeometryMatrix: ScaleGeometry(scale, scale), } if err := c.defaultR.drawImage(c.screen, option); err != nil { return err diff --git a/image.go b/image.go index 2355711ba..c5a6d7d52 100644 --- a/image.go +++ b/image.go @@ -68,15 +68,7 @@ func (i *innerImage) drawImage(img *innerImage, options *DrawImageOptions) error } } geo := options.GeometryMatrix - if geo == nil { - i := NewGeometryMatrix() - geo = &i - } clr := options.ColorMatrix - if clr == nil { - i := NewColorMatrix() - clr = &i - } if err := i.framebuffer.SetAsViewport(); err != nil { return err @@ -176,12 +168,7 @@ func (i *Image) DrawImageAt(image *Image, x, y int, options *DrawImageOptions) ( if options == nil { options = &DrawImageOptions{} } - if options.GeometryMatrix == nil { - geo := TranslateGeometry(float64(x), float64(y)) - options.GeometryMatrix = &geo - } else { - options.GeometryMatrix.Concat(TranslateGeometry(float64(x), float64(y))) - } + options.GeometryMatrix.Concat(TranslateGeometry(float64(x), float64(y))) return i.drawImage(image.inner, options) } @@ -228,6 +215,6 @@ func (i *Image) At(x, y int) color.Color { type DrawImageOptions struct { DstParts []image.Rectangle SrcParts []image.Rectangle - GeometryMatrix *GeometryMatrix - ColorMatrix *ColorMatrix + GeometryMatrix GeometryMatrix + ColorMatrix ColorMatrix }