Rename graphics.Context -> graphics.Canvas

This commit is contained in:
Hajime Hoshi 2013-11-29 22:06:22 +09:00
parent 5fbfb3a3a3
commit e8c518735b
12 changed files with 13 additions and 13 deletions

View File

@ -7,7 +7,7 @@ import (
type Game interface {
InitTextures(tf graphics.TextureFactory)
Update(context GameContext)
Draw(context graphics.Context)
Draw(canvas graphics.Canvas)
}
type GameContext interface {

View File

@ -18,5 +18,5 @@ func (game *Blank) InitTextures(tf graphics.TextureFactory) {
func (game *Blank) Update(context ebiten.GameContext) {
}
func (game *Blank) Draw(context graphics.Context) {
func (game *Blank) Draw(canvas graphics.Canvas) {
}

View File

@ -38,7 +38,7 @@ func (game *Input) Update(context ebiten.GameContext) {
game.inputState = context.InputState()
}
func (game *Input) Draw(g graphics.Context) {
func (game *Input) Draw(g graphics.Canvas) {
g.Fill(128, 128, 255)
str := fmt.Sprintf(`Input State:
X: %d
@ -46,7 +46,7 @@ func (game *Input) Draw(g graphics.Context) {
game.drawText(g, str, 5, 5)
}
func (game *Input) drawText(g graphics.Context, text string, x, y int) {
func (game *Input) drawText(g graphics.Canvas, text string, x, y int) {
const letterWidth = 6
const letterHeight = 16

View File

@ -100,7 +100,7 @@ func (game *Monochrome) Update(context ebiten.GameContext) {
game.geometryMatrix.Translate(float64(tx), float64(ty))
}
func (game *Monochrome) Draw(g graphics.Context) {
func (game *Monochrome) Draw(g graphics.Canvas) {
g.Fill(128, 128, 255)
g.DrawTexture(game.ebitenTextureId,

View File

@ -86,7 +86,7 @@ func (game *Rects) rectColorMatrix() matrix.Color {
return colorMatrix
}
func (game *Rects) Draw(g graphics.Context) {
func (game *Rects) Draw(g graphics.Canvas) {
if !game.rectTextureInited {
g.SetOffscreen(game.rectTextureId)
g.Fill(255, 255, 255)

View File

@ -56,7 +56,7 @@ func (game *Rotating) Update(context ebiten.GameContext) {
game.geometryMatrix.Translate(centerX-tx/2, centerY-ty/2)
}
func (game *Rotating) Draw(g graphics.Context) {
func (game *Rotating) Draw(g graphics.Canvas) {
g.Fill(128, 128, 255)
g.DrawTexture(game.ebitenTextureId,
game.geometryMatrix,

View File

@ -109,7 +109,7 @@ func (game *Sprites) Update(context ebiten.GameContext) {
}
}
func (game *Sprites) Draw(g graphics.Context) {
func (game *Sprites) Draw(g graphics.Canvas) {
g.Fill(128, 128, 255)
// Draw the sprites

View File

@ -72,7 +72,7 @@ func (game *TestPattern) Update(context ebiten.GameContext) {
game.geos = append(game.geos, geo)
}
func (game *TestPattern) Draw(g graphics.Context) {
func (game *TestPattern) Draw(g graphics.Canvas) {
for _, geo := range game.geos {
g.DrawTexture(game.textureId, geo, matrix.IdentityColor())
}

View File

@ -68,7 +68,7 @@ func main() {
}()
for {
ui.PollEvents()
ui.Draw(func(c graphics.Context) {
ui.Draw(func(c graphics.Canvas) {
lock.Lock()
defer lock.Unlock()
game.Draw(c)

View File

@ -18,7 +18,7 @@ type TexturePart struct {
Source Rect
}
type Context interface {
type Canvas interface {
ToTexture(id RenderTargetId) TextureId
Clear()

View File

@ -18,7 +18,7 @@ func NewDevice(screenWidth, screenHeight, screenScale int) *Device {
}
}
func (device *Device) Update(draw func(graphics.Context)) {
func (device *Device) Update(draw func(graphics.Canvas)) {
context := device.context
context.Init()
context.ResetOffscreen()

View File

@ -110,7 +110,7 @@ func (ui *UI) Update(f func(ebiten.GameContext)) {
f(ui.gameContext)
}
func (ui *UI) Draw(f func(graphics.Context)) {
func (ui *UI) Draw(f func(graphics.Canvas)) {
C.BeginDrawing(ui.window)
ui.graphicsDevice.Update(f)
C.EndDrawing(ui.window)