mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ebiten: Bug fix: Colorm.Concat crashed when the argument is an initial value
Closes #1765
This commit is contained in:
parent
12350e2fee
commit
415ceded79
@ -64,7 +64,11 @@ func (c *ColorM) Apply(clr color.Color) color.Color {
|
||||
// Concat multiplies a color matrix with the other color matrix.
|
||||
// This is same as muptiplying the matrix other and the matrix c in this order.
|
||||
func (c *ColorM) Concat(other ColorM) {
|
||||
c.impl = c.affineColorM().Concat(other.impl)
|
||||
o := other.impl
|
||||
if o == nil {
|
||||
o = affine.ColorMIdentity{}
|
||||
}
|
||||
c.impl = c.affineColorM().Concat(o)
|
||||
}
|
||||
|
||||
// Scale scales the matrix by (r, g, b, a).
|
||||
|
@ -2426,3 +2426,13 @@ func BenchmarkColorMScale(b *testing.B) {
|
||||
dst.DrawImage(src, op)
|
||||
}
|
||||
}
|
||||
|
||||
// #1765
|
||||
func TestColorMConcat(t *testing.T) {
|
||||
var a, b ColorM
|
||||
a.SetElement(1, 2, -1)
|
||||
a.Concat(b)
|
||||
if got, want := a.Element(1, 2), -1.0; got != want {
|
||||
t.Errorf("got: %f, want: %f", got, want)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user