mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 13:07:26 +01:00
48 lines
750 B
Go
48 lines
750 B
Go
package graphics
|
|
|
|
import (
|
|
"github.com/hajimehoshi/go-ebiten/graphics/matrix"
|
|
)
|
|
|
|
type Rect struct {
|
|
X int
|
|
Y int
|
|
Width int
|
|
Height int
|
|
}
|
|
|
|
type TexturePart struct {
|
|
LocationX int
|
|
LocationY int
|
|
Source Rect
|
|
}
|
|
|
|
type Drawer interface {
|
|
Draw(parts []TexturePart,
|
|
geometryMatrix matrix.Geometry,
|
|
colorMatrix matrix.Color)
|
|
}
|
|
|
|
func DrawWhole(
|
|
drawer Drawer,
|
|
width, height int,
|
|
geo matrix.Geometry,
|
|
color matrix.Color) {
|
|
parts := []TexturePart{
|
|
{0, 0, Rect{0, 0, width, height}},
|
|
}
|
|
drawer.Draw(parts, geo, color)
|
|
}
|
|
|
|
type Context interface {
|
|
Clear()
|
|
Fill(r, g, b uint8)
|
|
Texture(id TextureId) Drawer
|
|
RenderTarget(id RenderTargetId) Drawer
|
|
|
|
ResetOffscreen()
|
|
SetOffscreen(id RenderTargetId)
|
|
|
|
// TODO: glTextureSubImage2D
|
|
}
|