2013-06-19 01:49:54 +02:00
|
|
|
package graphics
|
|
|
|
|
|
|
|
import (
|
2013-10-14 04:34:58 +02:00
|
|
|
"github.com/hajimehoshi/go-ebiten/graphics/matrix"
|
2013-06-19 01:49:54 +02:00
|
|
|
"image"
|
|
|
|
)
|
|
|
|
|
2013-06-21 18:52:10 +02:00
|
|
|
type Rect struct {
|
|
|
|
X int
|
|
|
|
Y int
|
|
|
|
Width int
|
2013-06-21 17:03:45 +02:00
|
|
|
Height int
|
|
|
|
}
|
|
|
|
|
2013-06-22 19:16:22 +02:00
|
|
|
type TexturePart struct {
|
2013-06-21 18:52:10 +02:00
|
|
|
LocationX int
|
|
|
|
LocationY int
|
|
|
|
Source Rect
|
2013-06-21 17:50:55 +02:00
|
|
|
}
|
|
|
|
|
2013-06-27 17:33:03 +02:00
|
|
|
type Context interface {
|
2013-10-21 15:18:10 +02:00
|
|
|
ToTexture(id RenderTargetId) TextureId
|
2013-10-16 17:14:32 +02:00
|
|
|
|
2013-06-19 01:49:54 +02:00
|
|
|
Clear()
|
2013-10-11 20:20:13 +02:00
|
|
|
Fill(r, g, b uint8)
|
2013-10-21 15:18:10 +02:00
|
|
|
DrawTexture(id TextureId,
|
2013-06-21 19:42:14 +02:00
|
|
|
geometryMatrix matrix.Geometry,
|
|
|
|
colorMatrix matrix.Color)
|
2013-10-21 15:18:10 +02:00
|
|
|
DrawTextureParts(id TextureId,
|
2013-07-02 18:27:04 +02:00
|
|
|
parts []TexturePart,
|
2013-06-21 19:42:14 +02:00
|
|
|
geometryMatrix matrix.Geometry,
|
|
|
|
colorMatrix matrix.Color)
|
2013-10-16 16:06:35 +02:00
|
|
|
ResetOffscreen()
|
2013-10-21 15:18:10 +02:00
|
|
|
SetOffscreen(id RenderTargetId)
|
2013-06-19 16:08:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type TextureFactory interface {
|
2013-10-21 15:18:10 +02:00
|
|
|
NewRenderTarget(width, height int) (RenderTargetId, error)
|
|
|
|
NewTextureFromImage(img image.Image) (TextureId, error)
|
2013-06-19 03:31:44 +02:00
|
|
|
}
|
|
|
|
|
2013-10-21 15:18:10 +02:00
|
|
|
type TextureId int
|
2013-10-11 18:29:19 +02:00
|
|
|
|
2013-10-16 17:14:32 +02:00
|
|
|
// A render target is essentially same as a texture, but it is assumed that the
|
|
|
|
// all alpha of a render target is maximum.
|
2013-10-21 15:18:10 +02:00
|
|
|
type RenderTargetId int
|