Concat / Add returns the receiver

This commit is contained in:
Hajime Hoshi 2014-12-26 22:53:47 +09:00
parent ffab448d40
commit 20da9bffbb
2 changed files with 12 additions and 4 deletions

View File

@ -59,7 +59,8 @@ func (c ColorM) Element(i, j int) float64 {
}
// Concat multiplies a color matrix with the other color matrix.
func (c *ColorM) Concat(other ColorM) {
// This returns c.
func (c *ColorM) Concat(other ColorM) ColorM {
if !c.initialized {
c.es = colorMatrixEsI()
c.initialized = true
@ -67,10 +68,12 @@ func (c *ColorM) Concat(other ColorM) {
result := ColorM{}
mul(&other, c, &result)
*c = result
return *c
}
// Add adds a color matrix with the other color matrix.
func (c *ColorM) Add(other ColorM) {
// This returns c.
func (c *ColorM) Add(other ColorM) ColorM {
if !c.initialized {
c.es = colorMatrixEsI()
c.initialized = true
@ -78,6 +81,7 @@ func (c *ColorM) Add(other ColorM) {
result := ColorM{}
add(&other, c, &result)
*c = result
return *c
}
// SetElement sets an element at (i, j).

View File

@ -52,7 +52,8 @@ func (g GeoM) Element(i, j int) float64 {
}
// Concat multiplies a geometry matrix with the other geometry matrix.
func (g *GeoM) Concat(other GeoM) {
// This returns g.
func (g *GeoM) Concat(other GeoM) GeoM {
if !g.initialized {
g.es = geometryMatrixEsI()
g.initialized = true
@ -60,10 +61,12 @@ func (g *GeoM) Concat(other GeoM) {
result := GeoM{}
mul(&other, g, &result)
*g = result
return *g
}
// Add adds a geometry matrix with the other geometry matrix.
func (g *GeoM) Add(other GeoM) {
// This returns g.
func (g *GeoM) Add(other GeoM) GeoM {
if !g.initialized {
g.es = geometryMatrixEsI()
g.initialized = true
@ -71,6 +74,7 @@ func (g *GeoM) Add(other GeoM) {
result := GeoM{}
add(&other, g, &result)
*g = result
return *g
}
// SetElement sets an element at (i, j).