ebiten: separate a package for ColorM: colorm

Closes #2171
This commit is contained in:
Hajime Hoshi
2022-11-02 02:43:42 +09:00
parent 8c5f525ac2
commit 156c34a316
28 changed files with 645 additions and 78 deletions

View File

@@ -59,7 +59,7 @@ type sprite struct {
img *ebiten.Image
scale float64
angle float64
alpha float64
alpha float32
}
func (s *sprite) update() {
@@ -94,8 +94,8 @@ func (s *sprite) draw(screen *ebiten.Image) {
op.GeoM.Translate(x, y)
op.GeoM.Translate(ox, oy)
rate := float64(s.count) / float64(s.maxCount)
alpha := 0.0
rate := float32(s.count) / float32(s.maxCount)
var alpha float32
if rate < 0.2 {
alpha = rate / 0.2
} else if rate > 0.8 {
@@ -104,7 +104,7 @@ func (s *sprite) draw(screen *ebiten.Image) {
alpha = 1
}
alpha *= s.alpha
op.ColorM.Scale(1, 1, 1, alpha)
op.ColorScale.ScaleAlpha(alpha)
screen.DrawImage(s.img, op)
}