func (c *ColorM) Scale(r, g, b, a float32) *ColorM {
	if !c.isInited() {
		return &ColorM{
			body: []float32{
				r, 0, 0, 0,
				0, g, 0, 0,
				0, 0, b, 0,
				0, 0, 0, a,
			},
		}
	}
	eb := make([]float32, len(colorMIdentityBody))
	if c.body != nil {
		copy(eb, c.body)
		for i := 0; i < ColorMDim-1; i++ {
			eb[i*(ColorMDim-1)] *= r
			eb[i*(ColorMDim-1)+1] *= g
			eb[i*(ColorMDim-1)+2] *= b
			eb[i*(ColorMDim-1)+3] *= a
		}
	} else {
		eb[0] = r
		eb[5] = g
		eb[10] = b
		eb[15] = a
	}

	et := make([]float32, len(colorMIdentityTranslate))
	if c.translate != nil {
		et[0] = c.translate[0] * r
		et[1] = c.translate[1] * g
		et[2] = c.translate[2] * b
		et[3] = c.translate[3] * a
	}

	return &ColorM{
		body:      eb,
		translate: et,
	}
}
func (c *ColorM) Scale(r, g, b, a float32) *ColorM {
	if !c.isInited() {
		return &ColorM{
			body: []float32{
				r, 0, 0, 0,
				0, g, 0, 0,
				0, 0, b, 0,
				0, 0, 0, a,
			},
		}
	}
	eb := make([]float32, len(colorMIdentityBody))
	if c.body != nil {
		copy(eb, c.body)
		for i := 0; i < ColorMDim-1; i++ {
			eb[i*(ColorMDim-1)] *= r
			eb[i*(ColorMDim-1)+1] *= g
			eb[i*(ColorMDim-1)+2] *= b
			eb[i*(ColorMDim-1)+3] *= a
		}
	} else {
		eb[0] = r
		eb[5] = g
		eb[10] = b
		eb[15] = a
	}

	et := make([]float32, len(colorMIdentityTranslate))
	if c.translate != nil {
		et[0] = c.translate[0] * r
		et[1] = c.translate[1] * g
		et[2] = c.translate[2] * b
		et[3] = c.translate[3] * a
	}

	return &ColorM{
		body:      eb,
		translate: et,
	}
}
func ( c * ColorM ) Scale ( r , g , b , a float32 ) * ColorM { if ! c . isInited ( ) { return & ColorM { body : [ ] float32 { r , 0 , 0 , 0 , 0 , g , 0 , 0 , 0 , 0 , b , 0 , 0 , 0 , 0 , a , } , } } eb := make ( [ ] float32 , len ( colorMIdentityBody ) ) if c . body != nil { copy ( eb , c . body ) for i := 0 ; i < ColorMDim - 1 ; i ++ { eb [ i * ( ColorMDim - 1 ) ] *= r eb [ i * ( ColorMDim - 1 ) + 1 ] *= g eb [ i * ( ColorMDim - 1 ) + 2 ] *= b eb [ i * ( ColorMDim - 1 ) + 3 ] *= a } } else { eb [ 0 ] = r eb [ 5 ] = g eb [ 10 ] = b eb [ 15 ] = a } et := make ( [ ] float32 , len ( colorMIdentityTranslate ) ) if c . translate != nil { et [ 0 ] = c . translate [ 0 ] * r et [ 1 ] = c . translate [ 1 ] * g et [ 2 ] = c . translate [ 2 ] * b et [ 3 ] = c . translate [ 3 ] * a } return & ColorM { body : eb , translate : et , } }
// Scale scales the matrix by (r, g, b, a).
Scale scales the matrix by ( r g b a ) .