From 0fc28f6e98564055db0a4770b0952d10363102a1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 14 Aug 2017 00:28:10 +0900 Subject: [PATCH] examples/piano: Use ebitenutil.DrawRect --- examples/piano/main.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/examples/piano/main.go b/examples/piano/main.go index 0f3399c13..d50e11b06 100644 --- a/examples/piano/main.go +++ b/examples/piano/main.go @@ -152,8 +152,6 @@ var ( ) func init() { - imageEmpty, _ := ebiten.NewImage(16, 16, ebiten.FilterNearest) - imageEmpty.Fill(color.White) imagePiano, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest) whiteKeys := []string{"A", "S", "D", "F", "G", "H", "J", "K", "L"} width := 24 @@ -161,12 +159,7 @@ func init() { for i, k := range whiteKeys { x := i*width + 36 height := 112 - op := &ebiten.DrawImageOptions{} - w, h := imageEmpty.Size() - op.GeoM.Scale(float64(width-1)/float64(w), float64(height)/float64(h)) - op.GeoM.Translate(float64(x), float64(y)) - op.ColorM.Scale(1, 1, 1, 1) - imagePiano.DrawImage(imageEmpty, op) + ebitenutil.DrawRect(imagePiano, float64(x), float64(y), float64(width-1), float64(height), color.White) common.ArcadeFont.DrawText(imagePiano, k, x+8, y+height-16, 1, color.Black) } @@ -177,12 +170,7 @@ func init() { } x := i*width + 24 height := 64 - op := &ebiten.DrawImageOptions{} - w, h := imageEmpty.Size() - op.GeoM.Scale(float64(width-1)/float64(w), float64(height)/float64(h)) - op.GeoM.Translate(float64(x), float64(y)) - op.ColorM.Scale(0, 0, 0, 1) - imagePiano.DrawImage(imageEmpty, op) + ebitenutil.DrawRect(imagePiano, float64(x), float64(y), float64(width-1), float64(height), color.Black) common.ArcadeFont.DrawText(imagePiano, k, x+8, y+height-16, 1, color.White) } }