mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
examples: Use FilterDefault (#453)
This commit is contained in:
parent
6ef4bbde2d
commit
5ed5cceb43
@ -66,7 +66,7 @@ func (g *Game) Update() error {
|
||||
func (g *Game) Draw(screen *ebiten.Image) {
|
||||
if g.boardImage == nil {
|
||||
w, h := g.board.Size()
|
||||
g.boardImage, _ = ebiten.NewImage(w, h, ebiten.FilterNearest)
|
||||
g.boardImage, _ = ebiten.NewImage(w, h, ebiten.FilterDefault)
|
||||
}
|
||||
screen.Fill(backgroundColor)
|
||||
g.board.Draw(g.boardImage)
|
||||
|
@ -336,7 +336,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
tileImage, _ = ebiten.NewImage(tileSize, tileSize, ebiten.FilterNearest)
|
||||
tileImage, _ = ebiten.NewImage(tileSize, tileSize, ebiten.FilterDefault)
|
||||
tileImage.Fill(color.White)
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func update(screen *ebiten.Image) error {
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterNearest)
|
||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -51,16 +51,16 @@ var (
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
groundImage, _ = ebiten.NewImage(screenWidth*2, screenHeight*2/3+50, ebiten.FilterNearest)
|
||||
perspectiveGroundImage, _ = ebiten.NewImage(screenWidth*2, screenHeight, ebiten.FilterNearest)
|
||||
groundImage, _ = ebiten.NewImage(screenWidth*2, screenHeight*2/3+50, ebiten.FilterDefault)
|
||||
perspectiveGroundImage, _ = ebiten.NewImage(screenWidth*2, screenHeight, ebiten.FilterDefault)
|
||||
|
||||
const repeat = 5
|
||||
w, h := gophersImage.Size()
|
||||
repeatedGophersImage, _ = ebiten.NewImage(w*repeat, h*repeat, ebiten.FilterNearest)
|
||||
repeatedGophersImage, _ = ebiten.NewImage(w*repeat, h*repeat, ebiten.FilterDefault)
|
||||
for j := 0; j < repeat; j++ {
|
||||
for i := 0; i < repeat; i++ {
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
@ -84,7 +84,7 @@ func init() {
|
||||
fogRGBA.SetRGBA(i, j, clr)
|
||||
}
|
||||
}
|
||||
fogImage, _ = ebiten.NewImageFromImage(fogRGBA, ebiten.FilterNearest)
|
||||
fogImage, _ = ebiten.NewImageFromImage(fogRGBA, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
type player struct {
|
||||
|
@ -67,7 +67,7 @@ func update(screen *ebiten.Image) error {
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterNearest)
|
||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -72,13 +72,13 @@ func linesTextBoxPosition() (x, y int) {
|
||||
func init() {
|
||||
// Background
|
||||
var err error
|
||||
imageGameBG, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterLinear)
|
||||
imageGameBG, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Windows
|
||||
imageWindows, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterNearest)
|
||||
imageWindows, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterDefault)
|
||||
|
||||
// Windows: Field
|
||||
x, y := fieldWindowPosition()
|
||||
@ -103,7 +103,7 @@ func init() {
|
||||
drawTextBox(imageWindows, "LINES", x, y, textBoxWidth())
|
||||
|
||||
// Gameover
|
||||
imageGameover, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterNearest)
|
||||
imageGameover, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterDefault)
|
||||
imageGameover.Fill(color.NRGBA{0x00, 0x00, 0x00, 0x80})
|
||||
y = (ScreenHeight - blockHeight) / 2
|
||||
drawTextWithShadowCenter(imageGameover, "GAME OVER", 0, y, 1, color.White, ScreenWidth)
|
||||
@ -185,6 +185,7 @@ func (s *GameScene) drawBackground(r *ebiten.Image) {
|
||||
op.GeoM.Scale(scale, scale)
|
||||
op.GeoM.Translate(ScreenWidth/2, ScreenHeight/2)
|
||||
op.ColorM = lightGray
|
||||
op.Filter = ebiten.FilterLinear
|
||||
r.DrawImage(imageGameBG, op)
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ var imageBlocks *ebiten.Image
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
imageBlocks, _, err = ebitenutil.NewImageFromFile("_resources/images/blocks/blocks.png", ebiten.FilterNearest)
|
||||
imageBlocks, _, err = ebitenutil.NewImageFromFile("_resources/images/blocks/blocks.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
transitionFrom, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterNearest)
|
||||
transitionTo, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterNearest)
|
||||
transitionFrom, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterDefault)
|
||||
transitionTo, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
type Scene interface {
|
||||
|
@ -29,7 +29,7 @@ var imageBackground *ebiten.Image
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
imageBackground, _, err = ebitenutil.NewImageFromFile("_resources/images/blocks/background.png", ebiten.FilterNearest)
|
||||
imageBackground, _, err = ebitenutil.NewImageFromFile("_resources/images/blocks/background.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func update(screen *ebiten.Image) error {
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterNearest)
|
||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func init() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
eimg, err := ebiten.NewImageFromImage(img, ebiten.FilterLinear)
|
||||
eimg, err := ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -98,6 +98,8 @@ func update(screen *ebiten.Image) error {
|
||||
|
||||
// Move the image's center to the screen's center.
|
||||
op.GeoM.Translate(float64(sw)/2, float64(sh)/2)
|
||||
|
||||
op.Filter = ebiten.FilterLinear
|
||||
screen.DrawImage(highDPIImage, op)
|
||||
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("Device Scale Ratio: %0.2f", scale))
|
||||
|
@ -125,7 +125,7 @@ Inverted: %s [I]`, hue, saturation, value, msgInverted)
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ func update(screen *ebiten.Image) error {
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ var (
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
bgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/tile.png", ebiten.FilterNearest)
|
||||
bgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/tile.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ var keyboardKeys = [][]string{
|
||||
func drawKey(t *ebiten.Image, name string, x, y, width int) {
|
||||
const height = 16
|
||||
width--
|
||||
img, _ := ebiten.NewImage(width, height, ebiten.FilterNearest)
|
||||
img, _ := ebiten.NewImage(width, height, ebiten.FilterDefault)
|
||||
p := make([]byte, width*height*4)
|
||||
for j := 0; j < height; j++ {
|
||||
for i := 0; i < width; i++ {
|
||||
@ -131,7 +131,7 @@ func drawKey(t *ebiten.Image, name string, x, y, width int) {
|
||||
|
||||
func outputKeyboardImage() (map[string]image.Rectangle, error) {
|
||||
keyMap := map[string]image.Rectangle{}
|
||||
img, _ := ebiten.NewImage(320, 240, ebiten.FilterNearest)
|
||||
img, _ := ebiten.NewImage(320, 240, ebiten.FilterDefault)
|
||||
x, y := 0, 0
|
||||
for j, line := range keyboardKeys {
|
||||
x = 0
|
||||
|
@ -35,7 +35,7 @@ var keyboardImage *ebiten.Image
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
keyboardImage, _, err = ebitenutil.NewImageFromFile("_resources/images/keyboard/keyboard.png", ebiten.FilterNearest)
|
||||
keyboardImage, _, err = ebitenutil.NewImageFromFile("_resources/images/keyboard/keyboard.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
offscreen, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest)
|
||||
offscreen, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterDefault)
|
||||
offscreenPix = make([]byte, screenWidth*screenHeight*4)
|
||||
for i := range palette {
|
||||
palette[i] = byte(math.Sqrt(float64(i)/float64(len(palette))) * 0x80)
|
||||
|
@ -45,17 +45,17 @@ var (
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
bgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||
bgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/fiveyears.jpg", ebiten.FilterNearest)
|
||||
fgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/fiveyears.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
maskedFgImage, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest)
|
||||
maskedFgImage, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterDefault)
|
||||
|
||||
// Initialize the spot light image.
|
||||
const r = 64
|
||||
@ -70,7 +70,7 @@ func init() {
|
||||
a.SetAlpha(i, j, color.Alpha{b})
|
||||
}
|
||||
}
|
||||
spotLightImage, _ = ebiten.NewImageFromImage(a, ebiten.FilterNearest)
|
||||
spotLightImage, _ = ebiten.NewImageFromImage(a, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
|
@ -38,7 +38,7 @@ var (
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -64,7 +64,7 @@ func update(screen *ebiten.Image) error {
|
||||
|
||||
func main() {
|
||||
w, h := gophersImage.Size()
|
||||
gophersRenderTarget, _ = ebiten.NewImage(w/mosaicRatio, h/mosaicRatio, ebiten.FilterNearest)
|
||||
gophersRenderTarget, _ = ebiten.NewImage(w/mosaicRatio, h/mosaicRatio, ebiten.FilterDefault)
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Mosaic (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -54,9 +54,9 @@ func init() {
|
||||
Pix: pixels,
|
||||
Stride: 4,
|
||||
Rect: image.Rect(0, 0, 4, 4),
|
||||
}, ebiten.FilterNearest)
|
||||
}, ebiten.FilterDefault)
|
||||
|
||||
canvasImage, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest)
|
||||
canvasImage, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterDefault)
|
||||
canvasImage.Fill(color.White)
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ func update(screen *ebiten.Image) error {
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
pianoImage, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest)
|
||||
pianoImage, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterDefault)
|
||||
|
||||
const (
|
||||
keyWidth = 24
|
||||
|
@ -41,19 +41,19 @@ var (
|
||||
func init() {
|
||||
// Preload images
|
||||
var err error
|
||||
rightSprite, _, err = ebitenutil.NewImageFromFile("_resources/images/platformer/right.png", ebiten.FilterNearest)
|
||||
rightSprite, _, err = ebitenutil.NewImageFromFile("_resources/images/platformer/right.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
leftSprite, _, err = ebitenutil.NewImageFromFile("_resources/images/platformer/left.png", ebiten.FilterNearest)
|
||||
leftSprite, _, err = ebitenutil.NewImageFromFile("_resources/images/platformer/left.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
idleSprite, _, err = ebitenutil.NewImageFromFile("_resources/images/platformer/mainchar.png", ebiten.FilterNearest)
|
||||
idleSprite, _, err = ebitenutil.NewImageFromFile("_resources/images/platformer/mainchar.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
backgroundImage, _, err = ebitenutil.NewImageFromFile("_resources/images/platformer/background.png", ebiten.FilterNearest)
|
||||
backgroundImage, _, err = ebitenutil.NewImageFromFile("_resources/images/platformer/background.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func update(screen *ebiten.Image) error {
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -90,12 +90,12 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
img, _, err := ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterNearest)
|
||||
img, _, err := ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
w, h := img.Size()
|
||||
ebitenImage, _ = ebiten.NewImage(w, h, ebiten.FilterNearest)
|
||||
ebitenImage, _ = ebiten.NewImage(w, h, ebiten.FilterDefault)
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.ColorM.Scale(1, 1, 1, 0.5)
|
||||
ebitenImage.DrawImage(img, op)
|
||||
|
@ -42,7 +42,7 @@ var (
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
tilesImage, _, err = ebitenutil.NewImageFromFile("_resources/images/tiles.png", ebiten.FilterNearest)
|
||||
tilesImage, _, err = ebitenutil.NewImageFromFile("_resources/images/tiles.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ var (
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
uiImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ui.png", ebiten.FilterNearest)
|
||||
uiImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ui.png", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -347,7 +347,7 @@ func (t *TextBox) Draw(dst *ebiten.Image) {
|
||||
}
|
||||
if t.contentBuf == nil {
|
||||
w, h := t.viewSize()
|
||||
t.contentBuf, _ = ebiten.NewImage(w, h, ebiten.FilterNearest)
|
||||
t.contentBuf, _ = ebiten.NewImage(w, h, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
t.contentBuf.Clear()
|
||||
|
@ -153,7 +153,7 @@ func main() {
|
||||
fmt.Printf("Device scale factor: %0.2f\n", ebiten.DeviceScaleFactor())
|
||||
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user