From 5ed5cceb432643162311e47ee271d015cdcb9dad Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 14 Feb 2018 02:55:51 +0900 Subject: [PATCH] examples: Use FilterDefault (#453) --- examples/2048/2048/game.go | 2 +- examples/2048/2048/tile.go | 2 +- examples/additive/main.go | 2 +- examples/airship/main.go | 10 +++++----- examples/alphablending/main.go | 2 +- examples/blocks/blocks/gamescene.go | 7 ++++--- examples/blocks/blocks/piece.go | 2 +- examples/blocks/blocks/scenemanager.go | 4 ++-- examples/blocks/blocks/titlescene.go | 2 +- examples/flood/main.go | 2 +- examples/highdpi/main.go | 4 +++- examples/hsv/main.go | 2 +- examples/hue/main.go | 2 +- examples/infinitescroll/main.go | 2 +- examples/keyboard/keyboard/gen.go | 4 ++-- examples/keyboard/main.go | 2 +- examples/mandelbrot/main.go | 2 +- examples/masking/main.go | 8 ++++---- examples/mosaic/main.go | 4 ++-- examples/paint/main.go | 4 ++-- examples/perspective/main.go | 2 +- examples/piano/main.go | 2 +- examples/platformer/main.go | 8 ++++---- examples/rotate/main.go | 2 +- examples/sprites/main.go | 4 ++-- examples/tiles/main.go | 2 +- examples/ui/main.go | 4 ++-- examples/windowsize/main.go | 2 +- 28 files changed, 49 insertions(+), 46 deletions(-) diff --git a/examples/2048/2048/game.go b/examples/2048/2048/game.go index dcdbdefef..50860166e 100644 --- a/examples/2048/2048/game.go +++ b/examples/2048/2048/game.go @@ -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) diff --git a/examples/2048/2048/tile.go b/examples/2048/2048/tile.go index 71b0e420d..c4f9b4fe9 100644 --- a/examples/2048/2048/tile.go +++ b/examples/2048/2048/tile.go @@ -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) } diff --git a/examples/additive/main.go b/examples/additive/main.go index 781837492..5257a83cc 100644 --- a/examples/additive/main.go +++ b/examples/additive/main.go @@ -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) } diff --git a/examples/airship/main.go b/examples/airship/main.go index 5003a772b..5ffcd7e24 100644 --- a/examples/airship/main.go +++ b/examples/airship/main.go @@ -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 { diff --git a/examples/alphablending/main.go b/examples/alphablending/main.go index 1c3bf11c1..cecb7567d 100644 --- a/examples/alphablending/main.go +++ b/examples/alphablending/main.go @@ -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) } diff --git a/examples/blocks/blocks/gamescene.go b/examples/blocks/blocks/gamescene.go index a10daecb7..22e61456b 100644 --- a/examples/blocks/blocks/gamescene.go +++ b/examples/blocks/blocks/gamescene.go @@ -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) } diff --git a/examples/blocks/blocks/piece.go b/examples/blocks/blocks/piece.go index e8d5bbc89..726d7b4c0 100644 --- a/examples/blocks/blocks/piece.go +++ b/examples/blocks/blocks/piece.go @@ -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) } diff --git a/examples/blocks/blocks/scenemanager.go b/examples/blocks/blocks/scenemanager.go index 281d623b9..90aaf9d40 100644 --- a/examples/blocks/blocks/scenemanager.go +++ b/examples/blocks/blocks/scenemanager.go @@ -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 { diff --git a/examples/blocks/blocks/titlescene.go b/examples/blocks/blocks/titlescene.go index 709b18b49..a48a0ba35 100644 --- a/examples/blocks/blocks/titlescene.go +++ b/examples/blocks/blocks/titlescene.go @@ -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) } diff --git a/examples/flood/main.go b/examples/flood/main.go index 6418f4411..58180236d 100644 --- a/examples/flood/main.go +++ b/examples/flood/main.go @@ -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) } diff --git a/examples/highdpi/main.go b/examples/highdpi/main.go index ab4754f70..f488ea92d 100644 --- a/examples/highdpi/main.go +++ b/examples/highdpi/main.go @@ -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)) diff --git a/examples/hsv/main.go b/examples/hsv/main.go index e2cc68cf0..f8ea66f8a 100644 --- a/examples/hsv/main.go +++ b/examples/hsv/main.go @@ -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) } diff --git a/examples/hue/main.go b/examples/hue/main.go index 428b333cb..c8d4e57e4 100644 --- a/examples/hue/main.go +++ b/examples/hue/main.go @@ -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) } diff --git a/examples/infinitescroll/main.go b/examples/infinitescroll/main.go index 8e53e420c..9c1e79b3a 100644 --- a/examples/infinitescroll/main.go +++ b/examples/infinitescroll/main.go @@ -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) } diff --git a/examples/keyboard/keyboard/gen.go b/examples/keyboard/keyboard/gen.go index 53cb8b864..a7e721f53 100644 --- a/examples/keyboard/keyboard/gen.go +++ b/examples/keyboard/keyboard/gen.go @@ -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 diff --git a/examples/keyboard/main.go b/examples/keyboard/main.go index 075ca36b1..d1dee03fe 100644 --- a/examples/keyboard/main.go +++ b/examples/keyboard/main.go @@ -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) } diff --git a/examples/mandelbrot/main.go b/examples/mandelbrot/main.go index 53b70bb6c..a2f9f1197 100644 --- a/examples/mandelbrot/main.go +++ b/examples/mandelbrot/main.go @@ -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) diff --git a/examples/masking/main.go b/examples/masking/main.go index ddc508f85..8df92ea74 100644 --- a/examples/masking/main.go +++ b/examples/masking/main.go @@ -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 { diff --git a/examples/mosaic/main.go b/examples/mosaic/main.go index 4ab621eda..afbf6488d 100644 --- a/examples/mosaic/main.go +++ b/examples/mosaic/main.go @@ -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) } diff --git a/examples/paint/main.go b/examples/paint/main.go index 01ae13e76..5267a8440 100644 --- a/examples/paint/main.go +++ b/examples/paint/main.go @@ -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) } diff --git a/examples/perspective/main.go b/examples/perspective/main.go index 918fa9f65..985cf5a04 100644 --- a/examples/perspective/main.go +++ b/examples/perspective/main.go @@ -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) } diff --git a/examples/piano/main.go b/examples/piano/main.go index 768c8b6d7..206bf5dd9 100644 --- a/examples/piano/main.go +++ b/examples/piano/main.go @@ -164,7 +164,7 @@ var ( ) func init() { - pianoImage, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest) + pianoImage, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterDefault) const ( keyWidth = 24 diff --git a/examples/platformer/main.go b/examples/platformer/main.go index 467232196..1beb316d9 100644 --- a/examples/platformer/main.go +++ b/examples/platformer/main.go @@ -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) } diff --git a/examples/rotate/main.go b/examples/rotate/main.go index 7464ca549..15e973369 100644 --- a/examples/rotate/main.go +++ b/examples/rotate/main.go @@ -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) } diff --git a/examples/sprites/main.go b/examples/sprites/main.go index 8a7f31503..67bfa44ed 100644 --- a/examples/sprites/main.go +++ b/examples/sprites/main.go @@ -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) diff --git a/examples/tiles/main.go b/examples/tiles/main.go index 6bf8065c1..db6805fbc 100644 --- a/examples/tiles/main.go +++ b/examples/tiles/main.go @@ -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) } diff --git a/examples/ui/main.go b/examples/ui/main.go index 89260d3d9..4ea5e52f2 100644 --- a/examples/ui/main.go +++ b/examples/ui/main.go @@ -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() diff --git a/examples/windowsize/main.go b/examples/windowsize/main.go index b637228da..e0b851058 100644 --- a/examples/windowsize/main.go +++ b/examples/windowsize/main.go @@ -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) }