func (b *Board) Draw(boardImage *ebiten.Image) {
	boardImage.Fill(frameColor)
	for j := 0; j < b.size; j++ {
		for i := 0; i < b.size; i++ {
			v := 0
			op := &ebiten.DrawImageOptions{}
			x := i*tileSize + (i+1)*tileMargin
			y := j*tileSize + (j+1)*tileMargin
			op.GeoM.Translate(float64(x), float64(y))
			r, g, b, a := colorToScale(tileBackgroundColor(v))
			op.ColorM.Scale(r, g, b, a)
			boardImage.DrawImage(tileImage, op)
		}
	}
	animatingTiles := map[*Tile]struct{}{}
	nonAnimatingTiles := map[*Tile]struct{}{}
	for t := range b.tiles {
		if t.IsMoving() {
			animatingTiles[t] = struct{}{}
		} else {
			nonAnimatingTiles[t] = struct{}{}
		}
	}
	for t := range nonAnimatingTiles {
		t.Draw(boardImage)
	}
	for t := range animatingTiles {
		t.Draw(boardImage)
	}
}
func (b *Board) Draw(boardImage *ebiten.Image) {
	boardImage.Fill(frameColor)
	for j := 0; j < b.size; j++ {
		for i := 0; i < b.size; i++ {
			v := 0
			op := &ebiten.DrawImageOptions{}
			x := i*tileSize + (i+1)*tileMargin
			y := j*tileSize + (j+1)*tileMargin
			op.GeoM.Translate(float64(x), float64(y))
			r, g, b, a := colorToScale(tileBackgroundColor(v))
			op.ColorM.Scale(r, g, b, a)
			boardImage.DrawImage(tileImage, op)
		}
	}
	animatingTiles := map[*Tile]struct{}{}
	nonAnimatingTiles := map[*Tile]struct{}{}
	for t := range b.tiles {
		if t.IsMoving() {
			animatingTiles[t] = struct{}{}
		} else {
			nonAnimatingTiles[t] = struct{}{}
		}
	}
	for t := range nonAnimatingTiles {
		t.Draw(boardImage)
	}
	for t := range animatingTiles {
		t.Draw(boardImage)
	}
}
func ( b * Board ) Draw ( boardImage * ebiten . Image ) { boardImage . Fill ( frameColor ) for j := 0 ; j < b . size ; j ++ { for i := 0 ; i < b . size ; i ++ { v := 0 op := & ebiten . DrawImageOptions { } x := i * tileSize + ( i + 1 ) * tileMargin y := j * tileSize + ( j + 1 ) * tileMargin op . GeoM . Translate ( float64 ( x ) , float64 ( y ) ) r , g , b , a := colorToScale ( tileBackgroundColor ( v ) ) op . ColorM . Scale ( r , g , b , a ) boardImage . DrawImage ( tileImage , op ) } } animatingTiles := map [ * Tile ] struct { } { } nonAnimatingTiles := map [ * Tile ] struct { } { } for t := range b . tiles { if t . IsMoving ( ) { animatingTiles [ t ] = struct { } { } } else { nonAnimatingTiles [ t ] = struct { } { } } } for t := range nonAnimatingTiles { t . Draw ( boardImage ) } for t := range animatingTiles { t . Draw ( boardImage ) } }
// Draw draws the board to the given boardImage.
Draw draws the board to the given boardImage .