graphics: Bug fix: ColorM.Scale worked wrongly

This commit is contained in:
Hajime Hoshi 2016-11-27 23:27:14 +09:00
parent cd48e79355
commit 7bd2fb6ce2
2 changed files with 2 additions and 2 deletions

View File

@ -120,7 +120,7 @@ func TestColorTranslateAndScale(t *testing.T) {
{1, 0, 0, 0, 0}, {1, 0, 0, 0, 0},
{0, 1, 0, 0, 0}, {0, 1, 0, 0, 0},
{0, 0, 1, 0, 0}, {0, 0, 1, 0, 0},
{0, 0, 0, 0.5, 1}, {0, 0, 0, 0.5, 0.5},
} }
m := ColorM{} m := ColorM{}
m.Translate(0, 0, 0, 1) m.Translate(0, 0, 0, 1)

View File

@ -91,7 +91,7 @@ func (c *ColorM) Add(other ColorM) {
// Scale scales the matrix by (r, g, b, a). // Scale scales the matrix by (r, g, b, a).
func (c *ColorM) Scale(r, g, b, a float64) { func (c *ColorM) Scale(r, g, b, a float64) {
for i := 0; i < ColorMDim-1; i++ { for i := 0; i < ColorMDim; i++ {
c.SetElement(0, i, c.Element(0, i)*r) c.SetElement(0, i, c.Element(0, i)*r)
c.SetElement(1, i, c.Element(1, i)*g) c.SetElement(1, i, c.Element(1, i)*g)
c.SetElement(2, i, c.Element(2, i)*b) c.SetElement(2, i, c.Element(2, i)*b)