From eaaa7147055e777ebc12ae54150e2216a18de2a4 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 12 Feb 2018 18:42:56 +0900 Subject: [PATCH] examples/block: Remove deprecated API ColorM.Add --- examples/blocks/blocks/gamescene.go | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/blocks/blocks/gamescene.go b/examples/blocks/blocks/gamescene.go index 15b809130..dbfbf71fc 100644 --- a/examples/blocks/blocks/gamescene.go +++ b/examples/blocks/blocks/gamescene.go @@ -150,6 +150,25 @@ func NewGameScene() *GameScene { } } +var ( + lightGray ebiten.ColorM +) + +func init() { + id := ebiten.ColorM{} + + mono := ebiten.ColorM{} + mono.ChangeHSV(0, 0, 1) + + for j := 0; j < ebiten.ColorMDim-1; j++ { + for i := 0; i < ebiten.ColorMDim-1; i++ { + lightGray.SetElement(i, j, mono.Element(i, j)*0.7+id.Element(i, j)*0.3) + } + } + + lightGray.Translate(0.3, 0.3, 0.3, 0.3) +} + func (s *GameScene) drawBackground(r *ebiten.Image) { r.Fill(color.White) @@ -165,14 +184,7 @@ func (s *GameScene) drawBackground(r *ebiten.Image) { op.GeoM.Translate(-float64(w)/2, -float64(h)/2) op.GeoM.Scale(scale, scale) op.GeoM.Translate(ScreenWidth/2, ScreenHeight/2) - - a := 0.7 - m := ebiten.ColorM{} - m.ChangeHSV(0, 0, 1) - m.Scale(a, a, a, a) - op.ColorM.Scale(1-a, 1-a, 1-a, 1-a) - op.ColorM.Add(m) - op.ColorM.Translate(0.3, 0.3, 0.3, 0) + op.ColorM = lightGray r.DrawImage(imageGameBG, op) }