graphics: Refactoring: Remove PutVertex

This commit is contained in:
Hajime Hoshi 2019-02-15 00:22:32 +09:00
parent 7c506bc5bc
commit 3f28592700
2 changed files with 13 additions and 32 deletions

View File

@ -161,25 +161,3 @@ var (
func QuadIndices() []uint16 { func QuadIndices() []uint16 {
return quadIndices return quadIndices
} }
func PutVertex(vs []float32, width, height int, dx, dy, su, sv float32, u0, v0, u1, v1 float32, cr, cg, cb, ca float32) {
if !isInternalImageSize(width) {
panic(fmt.Sprintf("graphics: width must be an internal image size at PutVertices: %d", width))
}
if !isInternalImageSize(height) {
panic(fmt.Sprintf("graphics: height must be an internal image size at PutVertices: %d", height))
}
vs[0] = dx
vs[1] = dy
vs[2] = su
vs[3] = sv
vs[4] = u0
vs[5] = v0
vs[6] = u1
vs[7] = v1
vs[8] = cr
vs[9] = cg
vs[10] = cb
vs[11] = ca
}

View File

@ -241,17 +241,20 @@ func (i *Image) QuadVertices(sx0, sy0, sx1, sy1 int, a, b, c, d, tx, ty float32,
return graphics.QuadVertices(w, h, sx0, sy0, sx1, sy1, a, b, c, d, tx, ty, cr, cg, cb, ca) return graphics.QuadVertices(w, h, sx0, sy0, sx1, sy1, a, b, c, d, tx, ty, cr, cg, cb, ca)
} }
func (i *Image) PutVertex(dest []float32, dx, dy, sx, sy float32, bx0, by0, bx1, by1 float32, cr, cg, cb, ca float32) { func (i *Image) PutVertex(vs []float32, dx, dy, sx, sy float32, bx0, by0, bx1, by1 float32, cr, cg, cb, ca float32) {
w, h := i.internalSize() w, h := i.internalSize()
vs[0] = dx
su := sx / float32(w) vs[1] = dy
sv := sy / float32(h) vs[2] = sx / float32(w)
u0 := bx0 / float32(w) vs[3] = sy / float32(h)
v0 := by0 / float32(h) vs[4] = bx0 / float32(w)
u1 := bx1 / float32(w) vs[5] = by0 / float32(h)
v1 := by1 / float32(h) vs[6] = bx1 / float32(w)
vs[7] = by1 / float32(h)
graphics.PutVertex(dest, w, h, dx, dy, su, sv, u0, v0, u1, v1, cr, cg, cb, ca) vs[8] = cr
vs[9] = cg
vs[10] = cb
vs[11] = ca
} }
// makeStale makes the image stale. // makeStale makes the image stale.