diff --git a/_docs/public/example/images/keyboard/keyboard.png b/_docs/public/example/images/keyboard/keyboard.png index dc3693760..70a761978 100644 Binary files a/_docs/public/example/images/keyboard/keyboard.png and b/_docs/public/example/images/keyboard/keyboard.png differ diff --git a/example/images/keyboard/keyboard.png b/example/images/keyboard/keyboard.png index dc3693760..70a761978 100644 Binary files a/example/images/keyboard/keyboard.png and b/example/images/keyboard/keyboard.png differ diff --git a/example/keyboard/keyboard/gen.go b/example/keyboard/keyboard/gen.go index 3fb8b4f2e..4b2b61ae4 100644 --- a/example/keyboard/keyboard/gen.go +++ b/example/keyboard/keyboard/gen.go @@ -22,6 +22,7 @@ import ( einternal "github.com/hajimehoshi/ebiten/internal" "image" "image/color" + "image/draw" "image/png" "log" "os" @@ -103,12 +104,18 @@ func outputKeyboardImage() (map[string]image.Rectangle, error) { y += height } + palette := color.Palette([]color.Color{ + color.Transparent, color.Opaque, + }) + palettedImg := image.NewPaletted(img.Bounds(), palette) + draw.Draw(palettedImg, palettedImg.Bounds(), img, image.ZP, draw.Src) + f, err := os.Create("images/keyboard/keyboard.png") if err != nil { return nil, err } defer f.Close() - if err := png.Encode(f, img); err != nil { + if err := png.Encode(f, palettedImg); err != nil { return nil, err } return keyMap, nil