ebiten/graphics/graphics.go

45 lines
790 B
Go
Raw Normal View History

2013-06-19 01:49:54 +02:00
package graphics
2013-12-11 17:46:32 +01:00
import (
"image/color"
)
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 {
LocationX int
LocationY int
Source Rect
}
2013-12-11 17:46:32 +01:00
type Line struct {
X1, Y1 int
X2, Y2 int
Color color.Color
}
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
2013-10-25 02:30:39 +02:00
func OrthoProjectionMatrix(left, right, bottom, top int) [4][4]float64 {
e11 := float64(2) / float64(right-left)
e22 := float64(2) / float64(top-bottom)
e14 := -1 * float64(right+left) / float64(right-left)
e24 := -1 * float64(top+bottom) / float64(top-bottom)
return [4][4]float64{
{e11, 0, 0, e14},
{0, e22, 0, e24},
{0, 0, 1, 0},
{0, 0, 0, 1},
}
}