mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
Hide matrix members
This commit is contained in:
parent
494d07387d
commit
cb510fafa7
@ -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.
|
||||
|
@ -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).
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user