diff --git a/colormatrix.go b/colormatrix.go index 6a78a0bab..554dad97e 100644 --- a/colormatrix.go +++ b/colormatrix.go @@ -28,7 +28,7 @@ const ColorMatrixDim = 5 // Before applying a matrix, a color is un-multiplied, and after applying the matrix, // the color is multiplied again. type ColorMatrix struct { - Elements [ColorMatrixDim - 1][ColorMatrixDim]float64 + es [ColorMatrixDim - 1][ColorMatrixDim]float64 } // ColorMatrixI returns an identity color matrix. @@ -49,7 +49,7 @@ func (c *ColorMatrix) dim() int { // Element returns a value of a matrix at (i, j). func (c *ColorMatrix) Element(i, j int) float64 { - return c.Elements[i][j] + return c.es[i][j] } // Concat multiplies a color matrix with the other color matrix. @@ -65,7 +65,7 @@ func (c *ColorMatrix) IsIdentity() bool { } func (c *ColorMatrix) setElement(i, j int, element float64) { - c.Elements[i][j] = element + c.es[i][j] = element } // Monochrome returns a color matrix to make an image monochrome. diff --git a/geometrymatrix.go b/geometrymatrix.go index b933c0dd2..f478860f6 100644 --- a/geometrymatrix.go +++ b/geometrymatrix.go @@ -23,7 +23,7 @@ const GeometryMatrixDim = 3 // A GeometryMatrix represents a matrix to transform geometry when rendering an image. type GeometryMatrix struct { - Elements [GeometryMatrixDim - 1][GeometryMatrixDim]float64 + es [GeometryMatrixDim - 1][GeometryMatrixDim]float64 } // GeometryMatrixI returns an identity geometry matrix. @@ -42,7 +42,7 @@ func (g *GeometryMatrix) dim() int { // Element returns a value of a matrix at (i, j). func (g *GeometryMatrix) Element(i, j int) float64 { - return g.Elements[i][j] + return g.es[i][j] } // Concat multiplies a geometry matrix with the other geometry matrix. @@ -58,7 +58,7 @@ func (g *GeometryMatrix) IsIdentity() bool { } func (g *GeometryMatrix) setElement(i, j int, element float64) { - g.Elements[i][j] = element + g.es[i][j] = element } // ScaleGeometry returns a matrix that scales a geometry matrix by (x, y). diff --git a/geometrymatrix_test.go b/geometrymatrix_test.go index ca4539f5e..9251430ff 100644 --- a/geometrymatrix_test.go +++ b/geometrymatrix_test.go @@ -29,16 +29,8 @@ func TestGeometryIdentity(t *testing.T) { } func TestGeometryConcat(t *testing.T) { - matrix1 := GeometryMatrix{} - matrix2 := GeometryMatrix{} - matrix1.Elements = [2][3]float64{ - {2, 0, 0}, - {0, 2, 0}, - } - matrix2.Elements = [2][3]float64{ - {1, 0, 1}, - {0, 1, 1}, - } + matrix1 := ScaleGeometry(2, 2) + matrix2 := TranslateGeometry(1, 1) matrix3 := matrix1 matrix3.Concat(matrix2) @@ -48,7 +40,7 @@ func TestGeometryConcat(t *testing.T) { } for i := 0; i < 2; i++ { for j := 0; j < 3; j++ { - got := matrix3.Elements[i][j] + got := matrix3.Element(i, j) want := expected[i][j] if want != got { t.Errorf("matrix3.Element(%d, %d) = %f,"+ @@ -66,7 +58,7 @@ func TestGeometryConcat(t *testing.T) { } for i := 0; i < 2; i++ { for j := 0; j < 3; j++ { - got := matrix4.Elements[i][j] + got := matrix4.Element(i, j) want := expected[i][j] if want != got { t.Errorf("matrix4.Element(%d, %d) = %f, want %f",