Buffer, DamageBuffer, and Application are io.Writers

This commit is contained in:
2022-11-06 14:17:43 -05:00
parent 18ea5681de
commit 4b129a8391
3 changed files with 79 additions and 31 deletions

View File

@@ -19,6 +19,7 @@ type Backend struct {
backgroundStamper *imdraw.IMDraw
fontAtlas *text.Atlas
textDrawer *text.Text
showBounds bool
metrics struct {
cellWidth int
@@ -176,15 +177,18 @@ func (backend *Backend) draw () {
backend.textDrawer.Draw(backend.window, pixel.IM)
}
}
backend.backgroundStamper.Clear()
backend.backgroundStamper.Color =
backend.config.Color(stone.ColorBackground)
backend.backgroundStamper.Push (
backend.vectorAtPosition(0, 0),
backend.vectorAtPosition(width, height))
backend.backgroundStamper.Rectangle(1)
backend.backgroundStamper.Draw(backend.window)
// draw a rectangle around the buffer if we are showing bounds
if backend.showBounds {
backend.backgroundStamper.Clear()
backend.backgroundStamper.Color =
backend.config.Color(stone.ColorBackground)
backend.backgroundStamper.Push (
backend.vectorAtPosition(0, 0),
backend.vectorAtPosition(width, height))
backend.backgroundStamper.Rectangle(1)
backend.backgroundStamper.Draw(backend.window)
}
backend.window.SwapBuffers()
}