mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
graphics: Refactoring: Initialize 'quadFloat32Num' and reuse it
This commit is contained in:
parent
4e22bd770f
commit
bf163b5617
@ -14,8 +14,14 @@
|
||||
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
)
|
||||
|
||||
// texelAdjustment represents a number to be used to adjust texel.
|
||||
// Texels are adjusted by amount propotional to inverse of texelAdjustment.
|
||||
// This is necessary not to use unexpected pixels outside of texels.
|
||||
// See #317.
|
||||
const texelAdjustment = 256
|
||||
|
||||
var quadFloat32Num = graphics.QuadVertexSizeInBytes() / 4
|
||||
|
@ -20,14 +20,12 @@ import (
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
)
|
||||
|
||||
func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 {
|
||||
// TODO: This function should be in graphics package?
|
||||
totalSize := graphics.QuadVertexSizeInBytes() / 4
|
||||
l := parts.Len()
|
||||
vs := js.Global.Get("Float32Array").New(l * totalSize)
|
||||
vs := js.Global.Get("Float32Array").New(l * quadFloat32Num)
|
||||
g := geo.UnsafeElements()
|
||||
g0 := g[0]
|
||||
g1 := g[1]
|
||||
@ -103,7 +101,7 @@ func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 {
|
||||
vs.SetIndex(n+38, g4)
|
||||
vs.SetIndex(n+39, g5)
|
||||
|
||||
n += totalSize
|
||||
n += quadFloat32Num
|
||||
}
|
||||
return vs.Interface().([]float32)
|
||||
}
|
||||
|
@ -18,14 +18,12 @@ package ebiten
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
)
|
||||
|
||||
func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 {
|
||||
// TODO: This function should be in graphics package?
|
||||
totalSize := graphics.QuadVertexSizeInBytes() / 4
|
||||
l := parts.Len()
|
||||
vs := make([]float32, l*totalSize)
|
||||
vs := make([]float32, l*quadFloat32Num)
|
||||
g := geo.UnsafeElements()
|
||||
g0 := float32(g[0])
|
||||
g1 := float32(g[1])
|
||||
@ -102,7 +100,7 @@ func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 {
|
||||
vs[n+38] = g4
|
||||
vs[n+39] = g5
|
||||
|
||||
n += totalSize
|
||||
n += quadFloat32Num
|
||||
}
|
||||
return vs
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user