mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
Hide AffineMatrixElement
This commit is contained in:
parent
b5df3231e3
commit
7c23c6b326
@ -120,8 +120,8 @@ func (game *DemoGame) Draw(g graphics.GraphicsContext, offscreen graphics.Textur
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
geometryMatrix := graphics.IdentityGeometryMatrix()
|
geometryMatrix := graphics.IdentityGeometryMatrix()
|
||||||
geometryMatrix.SetTx(graphics.AffineMatrixElement(game.x))
|
geometryMatrix.SetTx(float64(game.x))
|
||||||
geometryMatrix.SetTy(graphics.AffineMatrixElement(game.x))
|
geometryMatrix.SetTy(float64(game.x))
|
||||||
g.DrawTexture(game.ebitenTexture,
|
g.DrawTexture(game.ebitenTexture,
|
||||||
0, 0, game.ebitenTexture.Width(), game.ebitenTexture.Height(),
|
0, 0, game.ebitenTexture.Width(), game.ebitenTexture.Height(),
|
||||||
geometryMatrix,
|
geometryMatrix,
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package graphics
|
package graphics
|
||||||
|
|
||||||
type AffineMatrixElement float64
|
type affineMatrixElement float64
|
||||||
|
|
||||||
type AffineMatrix struct {
|
type AffineMatrix struct {
|
||||||
elements []AffineMatrixElement
|
elements []affineMatrixElement
|
||||||
dimension int
|
dimension int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ func NewAffineMatrix(dimension int) *AffineMatrix {
|
|||||||
}
|
}
|
||||||
matrix := &AffineMatrix{}
|
matrix := &AffineMatrix{}
|
||||||
elementsNumber := dimension * (dimension - 1)
|
elementsNumber := dimension * (dimension - 1)
|
||||||
matrix.elements = make([]AffineMatrixElement, elementsNumber)
|
matrix.elements = make([]affineMatrixElement, elementsNumber)
|
||||||
matrix.dimension = dimension
|
matrix.dimension = dimension
|
||||||
return matrix
|
return matrix
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ func (matrix *AffineMatrix) Clone() *AffineMatrix {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *AffineMatrix) Element(i, j int) AffineMatrixElement {
|
func (matrix *AffineMatrix) Element(i, j int) float64 {
|
||||||
dimension := matrix.dimension
|
dimension := matrix.dimension
|
||||||
if i < 0 || dimension <= i {
|
if i < 0 || dimension <= i {
|
||||||
panic("out of range index i")
|
panic("out of range index i")
|
||||||
@ -55,10 +55,10 @@ func (matrix *AffineMatrix) Element(i, j int) AffineMatrixElement {
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return matrix.elements[i*dimension+j]
|
return float64(matrix.elements[i*dimension+j])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *AffineMatrix) SetElement(i, j int, element AffineMatrixElement) {
|
func (matrix *AffineMatrix) SetElement(i, j int, element float64) {
|
||||||
dimension := matrix.dimension
|
dimension := matrix.dimension
|
||||||
if i < 0 || dimension-1 <= i {
|
if i < 0 || dimension-1 <= i {
|
||||||
panic("out of range index i")
|
panic("out of range index i")
|
||||||
@ -66,7 +66,7 @@ func (matrix *AffineMatrix) SetElement(i, j int, element AffineMatrixElement) {
|
|||||||
if j < 0 || dimension <= j {
|
if j < 0 || dimension <= j {
|
||||||
panic("out of range index j")
|
panic("out of range index j")
|
||||||
}
|
}
|
||||||
matrix.elements[i*dimension+j] = element
|
matrix.elements[i*dimension+j] = affineMatrixElement(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *AffineMatrix) IsIdentity() bool {
|
func (matrix *AffineMatrix) IsIdentity() bool {
|
||||||
@ -96,7 +96,7 @@ func (rhs *AffineMatrix) Concat(lhs *AffineMatrix) *AffineMatrix {
|
|||||||
|
|
||||||
for i := 0; i < dimension-1; i++ {
|
for i := 0; i < dimension-1; i++ {
|
||||||
for j := 0; j < dimension; j++ {
|
for j := 0; j < dimension; j++ {
|
||||||
var element AffineMatrixElement = 0.0
|
element := affineMatrixElement(0.0)
|
||||||
for k := 0; k < dimension-1; k++ {
|
for k := 0; k < dimension-1; k++ {
|
||||||
element += lhs.elements[i*dimension+k] *
|
element += lhs.elements[i*dimension+k] *
|
||||||
rhs.elements[k*dimension+j]
|
rhs.elements[k*dimension+j]
|
||||||
|
@ -18,50 +18,50 @@ func (matrix *GeometryMatrix) Clone() *GeometryMatrix {
|
|||||||
return &GeometryMatrix{*(matrix.AffineMatrix.Clone())}
|
return &GeometryMatrix{*(matrix.AffineMatrix.Clone())}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) A() AffineMatrixElement {
|
func (matrix *GeometryMatrix) A() float64 {
|
||||||
return matrix.Element(0, 0)
|
return matrix.Element(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) B() AffineMatrixElement {
|
func (matrix *GeometryMatrix) B() float64 {
|
||||||
return matrix.Element(0, 1)
|
return matrix.Element(0, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) C() AffineMatrixElement {
|
func (matrix *GeometryMatrix) C() float64 {
|
||||||
return matrix.Element(1, 0)
|
return matrix.Element(1, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) D() AffineMatrixElement {
|
func (matrix *GeometryMatrix) D() float64 {
|
||||||
return matrix.Element(1, 1)
|
return matrix.Element(1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) Tx() AffineMatrixElement {
|
func (matrix *GeometryMatrix) Tx() float64 {
|
||||||
return matrix.Element(0, 2)
|
return matrix.Element(0, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) Ty() AffineMatrixElement {
|
func (matrix *GeometryMatrix) Ty() float64 {
|
||||||
return matrix.Element(1, 2)
|
return matrix.Element(1, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) SetA(a AffineMatrixElement) {
|
func (matrix *GeometryMatrix) SetA(a float64) {
|
||||||
matrix.SetElement(0, 0, a)
|
matrix.SetElement(0, 0, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) SetB(b AffineMatrixElement) {
|
func (matrix *GeometryMatrix) SetB(b float64) {
|
||||||
matrix.SetElement(0, 1, b)
|
matrix.SetElement(0, 1, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) SetC(c AffineMatrixElement) {
|
func (matrix *GeometryMatrix) SetC(c float64) {
|
||||||
matrix.SetElement(1, 0, c)
|
matrix.SetElement(1, 0, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) SetD(d AffineMatrixElement) {
|
func (matrix *GeometryMatrix) SetD(d float64) {
|
||||||
matrix.SetElement(1, 1, d)
|
matrix.SetElement(1, 1, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) SetTx(tx AffineMatrixElement) {
|
func (matrix *GeometryMatrix) SetTx(tx float64) {
|
||||||
matrix.SetElement(0, 2, tx)
|
matrix.SetElement(0, 2, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (matrix *GeometryMatrix) SetTy(ty AffineMatrixElement) {
|
func (matrix *GeometryMatrix) SetTy(ty float64) {
|
||||||
matrix.SetElement(1, 2, ty)
|
matrix.SetElement(1, 2, ty)
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ func (device *Device) Update() {
|
|||||||
g.resetOffscreen()
|
g.resetOffscreen()
|
||||||
g.Clear()
|
g.Clear()
|
||||||
geometryMatrix := graphics.IdentityGeometryMatrix()
|
geometryMatrix := graphics.IdentityGeometryMatrix()
|
||||||
geometryMatrix.SetA(graphics.AffineMatrixElement(g.screenScale))
|
geometryMatrix.SetA(float64(g.screenScale))
|
||||||
geometryMatrix.SetD(graphics.AffineMatrixElement(g.screenScale))
|
geometryMatrix.SetD(float64(g.screenScale))
|
||||||
g.DrawTexture(device.offscreenTexture,
|
g.DrawTexture(device.offscreenTexture,
|
||||||
0, 0, device.screenWidth, device.screenHeight,
|
0, 0, device.screenWidth, device.screenHeight,
|
||||||
geometryMatrix, graphics.IdentityColorMatrix())
|
geometryMatrix, graphics.IdentityColorMatrix())
|
||||||
|
Loading…
Reference in New Issue
Block a user