Rename TexturePart -> ImagePart

This commit is contained in:
Hajime Hoshi 2014-12-21 02:42:55 +09:00
parent 40c763724f
commit 6a2cfab839
8 changed files with 18 additions and 18 deletions

View File

@ -35,7 +35,7 @@ func DebugPrint(r *ebiten.RenderTarget, str string) {
}
func (d *debugPrintState) drawText(r *ebiten.RenderTarget, str string, x, y int, clr color.Color) {
parts := []ebiten.TexturePart{}
parts := []ebiten.ImagePart{}
locationX, locationY := 0, 0
for _, c := range str {
if c == '\n' {
@ -47,7 +47,7 @@ func (d *debugPrintState) drawText(r *ebiten.RenderTarget, str string, x, y int,
const xCharNum = assets.TextImageWidth / assets.TextImageCharWidth
srcX := float64(code%xCharNum) * assets.TextImageCharWidth
srcY := float64(code/xCharNum) * assets.TextImageCharHeight
parts = append(parts, ebiten.TexturePart{
parts = append(parts, ebiten.ImagePart{
Dst: ebiten.Rect{float64(locationX), float64(locationY), assets.TextImageCharWidth, assets.TextImageCharHeight},
Src: ebiten.Rect{srcX, srcY, assets.TextImageCharWidth, assets.TextImageCharHeight},
})

View File

@ -34,7 +34,7 @@ func textWidth(str string) int {
func drawText(r *ebiten.RenderTarget, textures *Textures, str string, ox, oy, scale int, clr color.Color) {
fontTextureId := textures.GetTexture("font")
parts := []ebiten.TexturePart{}
parts := []ebiten.ImagePart{}
locationX, locationY := 0, 0
for _, c := range str {
@ -46,7 +46,7 @@ func drawText(r *ebiten.RenderTarget, textures *Textures, str string, ox, oy, sc
code := int(c)
x := float64(code%16) * charWidth
y := float64((code-32)/16) * charHeight
parts = append(parts, ebiten.TexturePart{
parts = append(parts, ebiten.ImagePart{
Dst: ebiten.Rect{float64(locationX), float64(locationY), charWidth, charHeight},
Src: ebiten.Rect{x, y, charWidth, charHeight},
})

View File

@ -139,7 +139,7 @@ const fieldBlockNumX = 10
const fieldBlockNumY = 20
func drawBlocks(r *ebiten.RenderTarget, textures *Textures, blocks [][]BlockType, geo ebiten.GeometryMatrix) {
parts := []ebiten.TexturePart{}
parts := []ebiten.ImagePart{}
for i, blockCol := range blocks {
for j, block := range blockCol {
if block == BlockTypeNone {
@ -149,7 +149,7 @@ func drawBlocks(r *ebiten.RenderTarget, textures *Textures, blocks [][]BlockType
locationY := float64(j * blockHeight)
dst := ebiten.Rect{locationX, locationY, blockWidth, blockHeight}
src := ebiten.Rect{float64(int(block)-1) * blockWidth, 0, blockWidth, blockHeight}
parts = append(parts, ebiten.TexturePart{dst, src})
parts = append(parts, ebiten.ImagePart{dst, src})
}
}
blocksTexture := textures.GetTexture("blocks")

View File

@ -55,10 +55,10 @@ func drawTitleBackground(r *ebiten.RenderTarget, textures *Textures, c int) {
const textureHeight = 32
backgroundTexture := textures.GetTexture("background")
parts := []ebiten.TexturePart{}
parts := []ebiten.ImagePart{}
for j := -1; j < ScreenHeight/textureHeight+1; j++ {
for i := 0; i < ScreenWidth/textureWidth+1; i++ {
parts = append(parts, ebiten.TexturePart{
parts = append(parts, ebiten.ImagePart{
Dst: ebiten.Rect{float64(i * textureWidth), float64(j * textureHeight), textureWidth, textureHeight},
Src: ebiten.Rect{0, 0, textureWidth, textureHeight},
})

View File

@ -33,12 +33,12 @@ type Game struct {
}
func (g *Game) Update(r *ebiten.RenderTarget) error {
parts := []ebiten.TexturePart{}
parts := []ebiten.ImagePart{}
w, h := g.gophersTexture.Size()
for i := 0; i < h; i++ {
width := float64(w) + float64(i)*0.75
x := float64(h-i) * 0.75 / 2
part := ebiten.TexturePart{
part := ebiten.ImagePart{
Dst: ebiten.Rect{x, float64(i), width, 1},
Src: ebiten.Rect{0, float64(i), float64(w), 1},
}

View File

@ -28,16 +28,16 @@ type Rect struct {
Height float64
}
// A TexturePart represents a part of a texture.
type TexturePart struct {
// An ImagePart represents a part of an image.
type ImagePart struct {
Dst Rect
Src Rect
}
// DrawWholeTexture draws the whole texture.
// DrawWholeImage draws the whole image.
func DrawWholeImage(r *RenderTarget, texture *Texture, geo GeometryMatrix, color ColorMatrix) error {
w, h := texture.Size()
parts := []TexturePart{
parts := []ImagePart{
{Rect{0, 0, float64(w), float64(h)}, Rect{0, 0, float64(w), float64(h)}},
}
return r.DrawImage(texture, parts, geo, color)

View File

@ -66,7 +66,7 @@ func (c *graphicsContext) postUpdate() error {
geo := ScaleGeometry(scale, scale)
clr := ColorMatrixI()
w, h := c.screen.texture.Size()
parts := []TexturePart{
parts := []ImagePart{
{Rect{0, 0, float64(w), float64(h)}, Rect{0, 0, float64(w), float64(h)}},
}
if err := c.defaultR.DrawImage(c.screen.texture, parts, geo, clr); err != nil {

View File

@ -68,7 +68,7 @@ func (r *innerRenderTarget) Fill(clr color.Color) error {
return nil
}
func (r *innerRenderTarget) DrawImage(texture *Texture, parts []TexturePart, geo GeometryMatrix, color ColorMatrix) error {
func (r *innerRenderTarget) DrawImage(texture *Texture, parts []ImagePart, geo GeometryMatrix, color ColorMatrix) error {
if err := r.glRenderTarget.SetAsViewport(); err != nil {
return err
}
@ -93,7 +93,7 @@ func v(y float64, height int) float32 {
return float32(y) / float32(internal.NextPowerOf2Int(height))
}
func textureQuads(parts []TexturePart, width, height int) []shader.TextureQuad {
func textureQuads(parts []ImagePart, width, height int) []shader.TextureQuad {
quads := make([]shader.TextureQuad, 0, len(parts))
for _, part := range parts {
x1 := float32(part.Dst.X)
@ -141,7 +141,7 @@ func (r *RenderTarget) Fill(clr color.Color) (err error) {
return
}
func (r *RenderTarget) DrawImage(texture *Texture, parts []TexturePart, geo GeometryMatrix, color ColorMatrix) (err error) {
func (r *RenderTarget) DrawImage(texture *Texture, parts []ImagePart, geo GeometryMatrix, color ColorMatrix) (err error) {
r.syncer.Sync(func() {
err = r.inner.DrawImage(texture, parts, geo, color)
})