mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
image: Deprecate ScaleGeo, TranslateGeo and RotateGeo
This commit is contained in:
parent
439c8a62d3
commit
2a935f645d
15
geom.go
15
geom.go
@ -91,7 +91,14 @@ func (g *GeoM) Translate(tx, ty float64) {
|
||||
}
|
||||
|
||||
func (g *GeoM) Rotate(theta float64) {
|
||||
g.Concat(RotateGeo(theta))
|
||||
sin, cos := math.Sincos(theta)
|
||||
g.Concat(GeoM{
|
||||
initialized: true,
|
||||
es: [2][3]float64{
|
||||
{cos, -sin, 0},
|
||||
{sin, cos, 0},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// SetElement sets an element at (i, j).
|
||||
@ -102,7 +109,7 @@ func (g *GeoM) SetElement(i, j int, element float64) {
|
||||
g.es[i][j] = element
|
||||
}
|
||||
|
||||
// ScaleGeo returns a matrix that scales a geometry matrix by (x, y).
|
||||
// Deprecated as of 1.2.0-alpha. Use Scale instead.
|
||||
func ScaleGeo(x, y float64) GeoM {
|
||||
return GeoM{
|
||||
initialized: true,
|
||||
@ -113,7 +120,7 @@ func ScaleGeo(x, y float64) GeoM {
|
||||
}
|
||||
}
|
||||
|
||||
// TranslateGeo returns a matrix that translates a geometry matrix by (tx, ty).
|
||||
// Deprecated as of 1.2.0-alpha. Use Translate instead.
|
||||
func TranslateGeo(tx, ty float64) GeoM {
|
||||
return GeoM{
|
||||
initialized: true,
|
||||
@ -124,7 +131,7 @@ func TranslateGeo(tx, ty float64) GeoM {
|
||||
}
|
||||
}
|
||||
|
||||
// RotateGeo returns a matrix that rotates a geometry matrix by theta.
|
||||
// Deprecated as of 1.2.0-alpha. Use Rotate instead.
|
||||
func RotateGeo(theta float64) GeoM {
|
||||
sin, cos := math.Sincos(theta)
|
||||
return GeoM{
|
||||
|
11
geom_test.go
11
geom_test.go
@ -50,8 +50,9 @@ func TestGeometryInit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGeometryAssign(t *testing.T) {
|
||||
m := ScaleGeo(1, 1) // Create elements explicitly
|
||||
m2 := m
|
||||
m := &GeoM{}
|
||||
m.Scale(1, 1) // Create elements explicitly
|
||||
m2 := *m
|
||||
m.SetElement(0, 0, 0)
|
||||
got := m2.Element(0, 0)
|
||||
want := 1.0
|
||||
@ -61,8 +62,10 @@ func TestGeometryAssign(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGeometryConcat(t *testing.T) {
|
||||
matrix1 := ScaleGeo(2, 2)
|
||||
matrix2 := TranslateGeo(1, 1)
|
||||
matrix1 := GeoM{}
|
||||
matrix1.Scale(2, 2)
|
||||
matrix2 := GeoM{}
|
||||
matrix2.Translate(1, 1)
|
||||
|
||||
matrix3 := matrix1
|
||||
matrix3.Concat(matrix2)
|
||||
|
Loading…
Reference in New Issue
Block a user