mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
examples/blocks: Use ebitenutil.DrawRect
This commit is contained in:
parent
0fc28f6e98
commit
f08d21866a
@ -29,7 +29,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
imageEmpty *ebiten.Image
|
|
||||||
imageGameBG *ebiten.Image
|
imageGameBG *ebiten.Image
|
||||||
imageWindows *ebiten.Image
|
imageWindows *ebiten.Image
|
||||||
imageGameover *ebiten.Image
|
imageGameover *ebiten.Image
|
||||||
@ -70,10 +69,6 @@ func linesTextBoxPosition() (x, y int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Empty
|
|
||||||
imageEmpty, _ = ebiten.NewImage(16, 16, ebiten.FilterNearest)
|
|
||||||
imageEmpty.Fill(color.White)
|
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
var err error
|
var err error
|
||||||
imageGameBG, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterLinear)
|
imageGameBG, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterLinear)
|
||||||
@ -109,12 +104,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func drawWindow(r *ebiten.Image, x, y, width, height int) {
|
func drawWindow(r *ebiten.Image, x, y, width, height int) {
|
||||||
op := &ebiten.DrawImageOptions{}
|
ebitenutil.DrawRect(r, float64(x), float64(y), float64(width), float64(height), color.RGBA{0, 0, 0, 0xc0})
|
||||||
w, h := imageEmpty.Size()
|
|
||||||
op.GeoM.Scale(float64(width)/float64(w), float64(height)/float64(h))
|
|
||||||
op.GeoM.Translate(float64(x), float64(y))
|
|
||||||
op.ColorM.Scale(0, 0, 0, 0.75)
|
|
||||||
r.DrawImage(imageEmpty, op)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var fontColor = color.NRGBA{0x40, 0x40, 0xff, 0xff}
|
var fontColor = color.NRGBA{0x40, 0x40, 0xff, 0xff}
|
||||||
|
Loading…
Reference in New Issue
Block a user