image: Deprecate ScaleGeo, TranslateGeo and RotateGeo

This commit is contained in:
Hajime Hoshi 2016-02-06 23:43:43 +09:00
parent 439c8a62d3
commit 2a935f645d
2 changed files with 18 additions and 8 deletions

15
geom.go
View File

@ -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{

View File

@ -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)