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 {
|
||||
InitTextures(tf graphics.TextureFactory)
|
||||
Update(context GameContext)
|
||||
Draw(context graphics.Context)
|
||||
Draw(canvas graphics.Canvas)
|
||||
}
|
||||
|
||||
type GameContext interface {
|
||||
|
@ -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) {
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -18,7 +18,7 @@ type TexturePart struct {
|
||||
Source Rect
|
||||
}
|
||||
|
||||
type Context interface {
|
||||
type Canvas interface {
|
||||
ToTexture(id RenderTargetId) TextureId
|
||||
|
||||
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.Init()
|
||||
context.ResetOffscreen()
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user