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