ebiten/graphicscontext.go

57 lines
1.4 KiB
Go
Raw Normal View History

2014-12-09 15:16:04 +01:00
/*
Copyright 2014 Hajime Hoshi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
2014-12-09 14:09:22 +01:00
package ebiten
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 {
2014-12-09 14:09:22 +01:00
Draw(parts []TexturePart, geo GeometryMatrix, color ColorMatrix)
2014-05-01 15:45:48 +02:00
}
2014-12-07 17:07:39 +01:00
// DrawWhole draws the whole texture.
2014-12-09 14:09:22 +01:00
func DrawWhole(drawer Drawer, width, height int, geo GeometryMatrix, color ColorMatrix) {
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-12-09 14:09:22 +01:00
type GraphicsContext interface {
2014-05-01 15:45:48 +02:00
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
}