mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
CHange Context.Fill
This commit is contained in:
parent
f8c0f0faaa
commit
531b24dd9b
@ -26,7 +26,6 @@ import (
|
||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||
"github.com/hajimehoshi/go.ebiten/graphics/matrix"
|
||||
"image"
|
||||
"image/color"
|
||||
"os"
|
||||
)
|
||||
|
||||
@ -60,7 +59,7 @@ func (game *Input) Update(context ebiten.GameContext) {
|
||||
}
|
||||
|
||||
func (game *Input) Draw(g graphics.Context) {
|
||||
g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255})
|
||||
g.Fill(128, 128, 255)
|
||||
str := fmt.Sprintf(`Input State:
|
||||
X: %d
|
||||
Y: %d`, game.inputState.X, game.inputState.Y)
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||
"github.com/hajimehoshi/go.ebiten/graphics/matrix"
|
||||
"image"
|
||||
"image/color"
|
||||
_ "image/png"
|
||||
"os"
|
||||
)
|
||||
@ -116,7 +115,7 @@ func (game *Monochrome) Update(context ebiten.GameContext) {
|
||||
}
|
||||
|
||||
func (game *Monochrome) Draw(g graphics.Context) {
|
||||
g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255})
|
||||
g.Fill(128, 128, 255)
|
||||
|
||||
g.DrawTexture(game.ebitenTexture.ID(),
|
||||
game.geometryMatrix, game.colorMatrix)
|
||||
|
@ -95,13 +95,13 @@ func (game *Rects) rectColorMatrix() matrix.Color {
|
||||
func (game *Rects) Draw(g graphics.Context) {
|
||||
if !game.rectTextureInited {
|
||||
g.SetOffscreen(game.rectTexture.ID())
|
||||
g.Fill(&color.White)
|
||||
g.Fill(255, 255, 255)
|
||||
game.rectTextureInited = true
|
||||
}
|
||||
|
||||
g.SetOffscreen(game.offscreen.ID())
|
||||
if !game.offscreenInited {
|
||||
g.Fill(&color.RGBA{0, 0, 0, 255})
|
||||
g.Fill(0, 0, 0)
|
||||
game.offscreenInited = true
|
||||
}
|
||||
g.DrawTexture(game.rectTexture.Texture().ID(),
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||
"github.com/hajimehoshi/go.ebiten/graphics/matrix"
|
||||
"image"
|
||||
"image/color"
|
||||
_ "image/png"
|
||||
"math"
|
||||
"os"
|
||||
@ -71,7 +70,7 @@ func (game *Rotating) Update(context ebiten.GameContext) {
|
||||
}
|
||||
|
||||
func (game *Rotating) Draw(g graphics.Context) {
|
||||
g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255})
|
||||
g.Fill(128, 128, 255)
|
||||
g.DrawTexture(game.ebitenTexture.ID(),
|
||||
game.geometryMatrix,
|
||||
matrix.IdentityColor())
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||
"github.com/hajimehoshi/go.ebiten/graphics/matrix"
|
||||
"image"
|
||||
"image/color"
|
||||
"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
@ -123,7 +122,7 @@ func (game *Sprites) Update(context ebiten.GameContext) {
|
||||
}
|
||||
|
||||
func (game *Sprites) Draw(g graphics.Context) {
|
||||
g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255})
|
||||
g.Fill(128, 128, 255)
|
||||
|
||||
// Draw the sprites
|
||||
locations := make([]graphics.TexturePart, 0, len(game.sprites))
|
||||
|
@ -23,7 +23,6 @@ package graphics
|
||||
import (
|
||||
"github.com/hajimehoshi/go.ebiten/graphics/matrix"
|
||||
"image"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
type Rect struct {
|
||||
@ -42,7 +41,7 @@ type TexturePart struct {
|
||||
type Context interface {
|
||||
Screen() RenderTarget
|
||||
Clear()
|
||||
Fill(clr color.Color)
|
||||
Fill(r, g, b uint8)
|
||||
DrawTexture(textureID TextureID,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
|
@ -30,7 +30,6 @@ import (
|
||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||
"github.com/hajimehoshi/go.ebiten/graphics/matrix"
|
||||
"image"
|
||||
"image/color"
|
||||
"math"
|
||||
"unsafe"
|
||||
)
|
||||
@ -77,18 +76,16 @@ func (context *Context) Screen() graphics.RenderTarget {
|
||||
}
|
||||
|
||||
func (context *Context) Clear() {
|
||||
C.glClearColor(0, 0, 0, 255)
|
||||
C.glClear(C.GL_COLOR_BUFFER_BIT)
|
||||
context.Fill(0, 0, 0)
|
||||
}
|
||||
|
||||
func (context *Context) Fill(clr color.Color) {
|
||||
r, g, b, a := clr.RGBA()
|
||||
const max = float64(math.MaxUint16)
|
||||
func (context *Context) Fill(r, g, b uint8) {
|
||||
const max = float64(math.MaxUint8)
|
||||
C.glClearColor(
|
||||
C.GLclampf(float64(r)/max),
|
||||
C.GLclampf(float64(g)/max),
|
||||
C.GLclampf(float64(b)/max),
|
||||
C.GLclampf(float64(a)/max))
|
||||
1)
|
||||
C.glClear(C.GL_COLOR_BUFFER_BIT)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user