mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
affine: Add Reset function
This commit is contained in:
parent
de7215f3fc
commit
dad427920d
@ -33,6 +33,11 @@ type ColorM struct {
|
|||||||
impl affine.ColorM
|
impl affine.ColorM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset resets the ColorM as identity.
|
||||||
|
func (c *ColorM) Reset() {
|
||||||
|
c.impl.Reset()
|
||||||
|
}
|
||||||
|
|
||||||
// Concat multiplies a color matrix with the other color matrix.
|
// Concat multiplies a color matrix with the other color matrix.
|
||||||
// This is same as muptiplying the matrix other and the matrix c in this order.
|
// This is same as muptiplying the matrix other and the matrix c in this order.
|
||||||
func (c *ColorM) Concat(other ColorM) {
|
func (c *ColorM) Concat(other ColorM) {
|
||||||
|
@ -110,7 +110,7 @@ func update(screen *ebiten.Image) error {
|
|||||||
}
|
}
|
||||||
for i := 0; i < sprites.num; i++ {
|
for i := 0; i < sprites.num; i++ {
|
||||||
s := sprites.sprites[i]
|
s := sprites.sprites[i]
|
||||||
op.GeoM = ebiten.GeoM{}
|
op.GeoM.Reset()
|
||||||
op.GeoM.Translate(float64(s.x), float64(s.y))
|
op.GeoM.Translate(float64(s.x), float64(s.y))
|
||||||
screen.DrawImage(ebitenImage, op)
|
screen.DrawImage(ebitenImage, op)
|
||||||
}
|
}
|
||||||
|
5
geom.go
5
geom.go
@ -28,6 +28,11 @@ type GeoM struct {
|
|||||||
impl affine.GeoM
|
impl affine.GeoM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset resets the GeoM as identity.
|
||||||
|
func (g *GeoM) Reset() {
|
||||||
|
g.impl.Reset()
|
||||||
|
}
|
||||||
|
|
||||||
// Element returns a value of a matrix at (i, j).
|
// Element returns a value of a matrix at (i, j).
|
||||||
func (g *GeoM) Element(i, j int) float64 {
|
func (g *GeoM) Element(i, j int) float64 {
|
||||||
a, b, c, d, tx, ty := g.impl.Elements()
|
a, b, c, d, tx, ty := g.impl.Elements()
|
||||||
|
@ -44,6 +44,10 @@ type ColorM struct {
|
|||||||
elements []float64
|
elements []float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ColorM) Reset() {
|
||||||
|
c.elements = nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *ColorM) UnsafeElements() []float64 {
|
func (c *ColorM) UnsafeElements() []float64 {
|
||||||
if c.elements == nil {
|
if c.elements == nil {
|
||||||
c.elements = colorMIdentityElements
|
c.elements = colorMIdentityElements
|
||||||
|
@ -34,6 +34,10 @@ type GeoM struct {
|
|||||||
inited bool
|
inited bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GeoM) Reset() {
|
||||||
|
g.inited = false
|
||||||
|
}
|
||||||
|
|
||||||
func (g *GeoM) Elements() (a, b, c, d, tx, ty float64) {
|
func (g *GeoM) Elements() (a, b, c, d, tx, ty float64) {
|
||||||
if !g.inited {
|
if !g.inited {
|
||||||
return 1, 0, 0, 1, 0, 0
|
return 1, 0, 0, 1, 0, 0
|
||||||
|
Loading…
Reference in New Issue
Block a user