2013-07-01 15:25:41 +02:00
|
|
|
// Copyright 2013 Hajime Hoshi
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
// SOFTWARE.
|
|
|
|
|
2013-06-19 01:49:54 +02:00
|
|
|
package graphics
|
|
|
|
|
|
|
|
import (
|
2013-06-20 18:47:39 +02:00
|
|
|
"github.com/hajimehoshi/go.ebiten/graphics/matrix"
|
2013-06-19 01:49:54 +02:00
|
|
|
"image"
|
|
|
|
"image/color"
|
|
|
|
)
|
|
|
|
|
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-11 18:29:19 +02:00
|
|
|
Screen() RenderTarget
|
2013-06-19 01:49:54 +02:00
|
|
|
Clear()
|
2013-06-25 17:56:01 +02:00
|
|
|
Fill(clr color.Color)
|
2013-06-23 14:51:23 +02:00
|
|
|
DrawTexture(textureID TextureID,
|
2013-06-21 19:42:14 +02:00
|
|
|
geometryMatrix matrix.Geometry,
|
|
|
|
colorMatrix matrix.Color)
|
2013-06-23 14:51:23 +02:00
|
|
|
DrawTextureParts(textureID 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-11 18:29:19 +02:00
|
|
|
SetOffscreen(renderTargetID RenderTargetID)
|
2013-06-19 16:08:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type TextureFactory interface {
|
2013-10-11 18:29:19 +02:00
|
|
|
NewRenderTarget(width, height int) RenderTarget
|
2013-06-23 09:06:32 +02:00
|
|
|
NewTextureFromImage(img image.Image) (Texture, error)
|
2013-06-19 01:49:54 +02:00
|
|
|
}
|
|
|
|
|
2013-07-12 18:36:01 +02:00
|
|
|
type Texture interface {
|
|
|
|
ID() TextureID
|
|
|
|
Width() int
|
|
|
|
Height() int
|
2013-06-19 03:31:44 +02:00
|
|
|
}
|
|
|
|
|
2013-06-19 16:08:24 +02:00
|
|
|
type TextureID int
|
2013-10-11 18:29:19 +02:00
|
|
|
|
|
|
|
type RenderTarget interface {
|
|
|
|
Texture() Texture
|
|
|
|
ID() RenderTargetID
|
|
|
|
Width() int
|
|
|
|
Height() int
|
|
|
|
}
|
|
|
|
|
|
|
|
type RenderTargetID int
|
|
|
|
|