ebiten/graphics/context.go

45 lines
924 B
Go
Raw Normal View History

2013-12-02 13:45:10 +01:00
package graphics
import (
2014-12-05 14:16:58 +01:00
"github.com/hajimehoshi/ebiten/graphics/matrix"
2013-12-02 13:45:10 +01:00
)
2014-12-07 17:07:39 +01:00
// A Rect represents a rectangle.
2014-05-02 17:06:20 +02:00
type Rect struct {
X int
Y int
Width int
Height int
}
2014-12-07 17:07:39 +01:00
// A TexturePart represents a part of a texture.
2014-05-02 17:06:20 +02:00
type TexturePart struct {
LocationX int
LocationY int
Source Rect
}
2014-12-07 17:07:39 +01:00
// A Drawer is the interface that draws itself.
2014-05-01 15:45:48 +02:00
type Drawer interface {
Draw(parts []TexturePart, geo matrix.Geometry, color matrix.Color)
2014-05-01 15:45:48 +02:00
}
2014-12-07 17:07:39 +01:00
// DrawWhole draws the whole texture.
2014-12-06 20:14:35 +01:00
func DrawWhole(drawer Drawer, width, height int, geo matrix.Geometry, color matrix.Color) {
2014-05-03 06:58:18 +02:00
parts := []TexturePart{
{0, 0, Rect{0, 0, width, height}},
}
drawer.Draw(parts, geo, color)
}
2014-12-07 17:07:39 +01:00
// A Context is the interface that means a context of rendering.
2014-05-01 15:45:48 +02:00
type Context interface {
Clear()
Fill(r, g, b uint8)
2014-12-06 21:21:20 +01:00
Texture(id TextureID) Drawer
RenderTarget(id RenderTargetID) Drawer
2013-12-02 13:45:10 +01:00
ResetOffscreen()
2014-12-06 21:21:20 +01:00
SetOffscreen(id RenderTargetID)
2013-12-02 13:45:10 +01:00
}