This commit is contained in:
Hajime Hoshi 2013-06-21 11:16:19 +09:00
parent 970b087035
commit faa9c1bfe8
4 changed files with 5 additions and 7 deletions

View File

@ -44,8 +44,8 @@ func (game *RotatingImage) Draw(g graphics.GraphicsContext, offscreen graphics.T
geometryMatrix.Translate(-tx/2, -ty/2)
geometryMatrix.Rotate(float64(game.x) / 60)
geometryMatrix.Translate(tx/2, ty/2)
centerX, centerY := float64(offscreen.Width) / 2, float64(offscreen.Height) / 2
geometryMatrix.Translate(centerX - tx/2, centerY - ty/2)
centerX, centerY := float64(offscreen.Width)/2, float64(offscreen.Height)/2
geometryMatrix.Translate(centerX-tx/2, centerY-ty/2)
g.DrawTexture(game.ebitenTexture.ID,
0, 0, int(tx), int(ty),
geometryMatrix,

View File

@ -1,3 +1 @@
package matrix_test

View File

@ -52,7 +52,7 @@ func (matrix *Geometry) Rotate(theta float64) {
rotate := Geometry{
[2][3]float64{
{cos, -sin, 0},
{sin, cos, 0},
{sin, cos, 0},
},
}
matrix.Concat(rotate)

View File

@ -51,8 +51,8 @@ func (device *Device) Update() {
scale := float64(g.screenScale)
geometryMatrix := matrix.Geometry{
[2][3]float64{
{scale, 0, 0},
{0, scale, 0},
{scale, 0, 0},
{0, scale, 0},
},
}
g.DrawTexture(device.offscreenTexture.ID,