mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Rename graphics.Context -> graphics.Canvas
This commit is contained in:
parent
5fbfb3a3a3
commit
e8c518735b
@ -7,7 +7,7 @@ import (
|
|||||||
type Game interface {
|
type Game interface {
|
||||||
InitTextures(tf graphics.TextureFactory)
|
InitTextures(tf graphics.TextureFactory)
|
||||||
Update(context GameContext)
|
Update(context GameContext)
|
||||||
Draw(context graphics.Context)
|
Draw(canvas graphics.Canvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GameContext interface {
|
type GameContext interface {
|
||||||
|
@ -18,5 +18,5 @@ func (game *Blank) InitTextures(tf graphics.TextureFactory) {
|
|||||||
func (game *Blank) Update(context ebiten.GameContext) {
|
func (game *Blank) Update(context ebiten.GameContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (game *Blank) Draw(context graphics.Context) {
|
func (game *Blank) Draw(canvas graphics.Canvas) {
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func (game *Input) Update(context ebiten.GameContext) {
|
|||||||
game.inputState = context.InputState()
|
game.inputState = context.InputState()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (game *Input) Draw(g graphics.Context) {
|
func (game *Input) Draw(g graphics.Canvas) {
|
||||||
g.Fill(128, 128, 255)
|
g.Fill(128, 128, 255)
|
||||||
str := fmt.Sprintf(`Input State:
|
str := fmt.Sprintf(`Input State:
|
||||||
X: %d
|
X: %d
|
||||||
@ -46,7 +46,7 @@ func (game *Input) Draw(g graphics.Context) {
|
|||||||
game.drawText(g, str, 5, 5)
|
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 letterWidth = 6
|
||||||
const letterHeight = 16
|
const letterHeight = 16
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ func (game *Monochrome) Update(context ebiten.GameContext) {
|
|||||||
game.geometryMatrix.Translate(float64(tx), float64(ty))
|
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.Fill(128, 128, 255)
|
||||||
|
|
||||||
g.DrawTexture(game.ebitenTextureId,
|
g.DrawTexture(game.ebitenTextureId,
|
||||||
|
@ -86,7 +86,7 @@ func (game *Rects) rectColorMatrix() matrix.Color {
|
|||||||
return colorMatrix
|
return colorMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
func (game *Rects) Draw(g graphics.Context) {
|
func (game *Rects) Draw(g graphics.Canvas) {
|
||||||
if !game.rectTextureInited {
|
if !game.rectTextureInited {
|
||||||
g.SetOffscreen(game.rectTextureId)
|
g.SetOffscreen(game.rectTextureId)
|
||||||
g.Fill(255, 255, 255)
|
g.Fill(255, 255, 255)
|
||||||
|
@ -56,7 +56,7 @@ func (game *Rotating) Update(context ebiten.GameContext) {
|
|||||||
game.geometryMatrix.Translate(centerX-tx/2, centerY-ty/2)
|
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.Fill(128, 128, 255)
|
||||||
g.DrawTexture(game.ebitenTextureId,
|
g.DrawTexture(game.ebitenTextureId,
|
||||||
game.geometryMatrix,
|
game.geometryMatrix,
|
||||||
|
@ -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)
|
g.Fill(128, 128, 255)
|
||||||
|
|
||||||
// Draw the sprites
|
// Draw the sprites
|
||||||
|
@ -72,7 +72,7 @@ func (game *TestPattern) Update(context ebiten.GameContext) {
|
|||||||
game.geos = append(game.geos, geo)
|
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 {
|
for _, geo := range game.geos {
|
||||||
g.DrawTexture(game.textureId, geo, matrix.IdentityColor())
|
g.DrawTexture(game.textureId, geo, matrix.IdentityColor())
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
for {
|
for {
|
||||||
ui.PollEvents()
|
ui.PollEvents()
|
||||||
ui.Draw(func(c graphics.Context) {
|
ui.Draw(func(c graphics.Canvas) {
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
game.Draw(c)
|
game.Draw(c)
|
||||||
|
@ -18,7 +18,7 @@ type TexturePart struct {
|
|||||||
Source Rect
|
Source Rect
|
||||||
}
|
}
|
||||||
|
|
||||||
type Context interface {
|
type Canvas interface {
|
||||||
ToTexture(id RenderTargetId) TextureId
|
ToTexture(id RenderTargetId) TextureId
|
||||||
|
|
||||||
Clear()
|
Clear()
|
||||||
|
@ -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 := device.context
|
||||||
context.Init()
|
context.Init()
|
||||||
context.ResetOffscreen()
|
context.ResetOffscreen()
|
||||||
|
@ -110,7 +110,7 @@ func (ui *UI) Update(f func(ebiten.GameContext)) {
|
|||||||
f(ui.gameContext)
|
f(ui.gameContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *UI) Draw(f func(graphics.Context)) {
|
func (ui *UI) Draw(f func(graphics.Canvas)) {
|
||||||
C.BeginDrawing(ui.window)
|
C.BeginDrawing(ui.window)
|
||||||
ui.graphicsDevice.Update(f)
|
ui.graphicsDevice.Update(f)
|
||||||
C.EndDrawing(ui.window)
|
C.EndDrawing(ui.window)
|
||||||
|
Loading…
Reference in New Issue
Block a user