mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
docs: Update
This commit is contained in:
parent
f92a2748a4
commit
61005e3d4b
@ -25,7 +25,7 @@
|
||||
<li class="nav-item"><a class="nav-link" href="https://github.com/hajimehoshi/ebiten">GitHub</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="https://godoc.org/github.com/hajimehoshi/ebiten">GoDoc</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="https://github.com/hajimehoshi/ebiten/wiki">Wiki</a>
|
||||
<li class="nav-item"><a class="nav-link" href="https://ebiten-playground.github.io/">Playground</a>
|
||||
<li class="nav-item"><a class="nav-link" href="https://jsgo.io/dave/jsgo/playground#c3ff01cd9b8e897cf0438a78c87bf1f5aee38095">Playground (jsgo.io)</a>
|
||||
</ul>
|
||||
</div>
|
||||
</div></nav>
|
||||
|
Binary file not shown.
@ -18,14 +18,6 @@ Recorded by Mike Koenig
|
||||
Attribution 3.0: https://creativecommons.org/licenses/by/3.0/
|
||||
```
|
||||
|
||||
## game.ogg
|
||||
|
||||
```
|
||||
http://mart.kitunebi.com/music_act.html
|
||||
|
||||
Harpie's Feather (ハルピュイアの羽) by Napi
|
||||
```
|
||||
|
||||
|
||||
## ragtime.ogg
|
||||
|
||||
|
@ -27,11 +27,12 @@
|
||||
|
||||
<h2>Ebiten example - airship</h2>
|
||||
<iframe src="airship.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
@ -41,6 +42,7 @@ import (
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -65,11 +67,21 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Gophers_jpg))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
gophersImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
groundImage, _ = ebiten.NewImage(screenWidth*2, screenHeight*2/3+50, ebiten.FilterDefault)
|
||||
perspectiveGroundImage, _ = ebiten.NewImage(screenWidth*2, screenHeight, ebiten.FilterDefault)
|
||||
|
||||
@ -210,9 +222,9 @@ func drawGroundImage(screen *ebiten.Image, ground *ebiten.Image) {
|
||||
gw, _ := ground.Size()
|
||||
pw, ph := perspectiveGroundImage.Size()
|
||||
for j := 0; j < ph; j++ {
|
||||
// z is in [1, -1]
|
||||
// z is in [2, -1]
|
||||
rate := float64(j) / float64(ph)
|
||||
z := (1-rate)*1 + rate*-1
|
||||
z := (1-rate)*2 + rate*-1
|
||||
if z <= 0 {
|
||||
break
|
||||
}
|
||||
|
@ -27,17 +27,19 @@
|
||||
|
||||
<h2>Ebiten example - alphablending</h2>
|
||||
<iframe src="alphablending.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
_ "image/png"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -81,11 +83,21 @@ func update(screen *ebiten.Image) error {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Ebiten_png))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ebitenImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Alpha Blending (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<h2>Ebiten example - audio</h2>
|
||||
<iframe src="audio.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
// This is an example to implement an audio player.
|
||||
// See examples/wav for a simpler example to play a sound file.
|
||||
@ -46,6 +46,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/audio/mp3"
|
||||
"github.com/hajimehoshi/ebiten/audio/wav"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
raudio "github.com/hajimehoshi/ebiten/examples/resources/audio"
|
||||
"github.com/hajimehoshi/ebiten/inpututil"
|
||||
)
|
||||
|
||||
@ -83,15 +84,7 @@ func playerBarRect() (x, y, w, h int) {
|
||||
|
||||
func NewPlayer(audioContext *audio.Context) (*Player, error) {
|
||||
const bytesPerSample = 4 // TODO: This should be defined in audio package
|
||||
wavF, err := ebitenutil.OpenFile("_resources/audio/jab.wav")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mp3F, err := ebitenutil.OpenFile("_resources/audio/classic.mp3")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s, err := mp3.Decode(audioContext, mp3F)
|
||||
s, err := mp3.Decode(audioContext, audio.BytesReadSeekCloser(raudio.Classic_mp3))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -111,7 +104,7 @@ func NewPlayer(audioContext *audio.Context) (*Player, error) {
|
||||
}
|
||||
player.audioPlayer.Play()
|
||||
go func() {
|
||||
s, err := wav.Decode(audioContext, wavF)
|
||||
s, err := wav.Decode(audioContext, audio.BytesReadSeekCloser(raudio.Jab_wav))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
|
@ -27,16 +27,19 @@
|
||||
|
||||
<h2>Ebiten example - filter</h2>
|
||||
<iframe src="filter.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
_ "image/png"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -72,14 +75,25 @@ func update(screen *ebiten.Image) error {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
// Specifying filter on NewImage(FromImage) is just for backward compatibility.
|
||||
// Now specifying filter at DrawImageOptions is recommended.
|
||||
// Specify FilterDefault here, that means to prefer filter specified at DrawImageOptions.
|
||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Ebiten_png))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Specifying filter on NewImage[FromImage] is just for backward compatibility.
|
||||
// Now specifying filter at DrawImageOptions is recommended.
|
||||
// Specify FilterDefault here, that means to prefer filter specified at DrawImageOptions.
|
||||
ebitenImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Filter (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,17 +27,19 @@
|
||||
|
||||
<h2>Ebiten example - flood</h2>
|
||||
<iframe src="flood.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
_ "image/png"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -97,11 +99,21 @@ func update(screen *ebiten.Image) error {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Ebiten_png))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ebitenImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Flood fill with solid colors (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,14 +27,13 @@
|
||||
|
||||
<h2>Ebiten example - font</h2>
|
||||
<iframe src="font.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"strings"
|
||||
@ -44,7 +43,7 @@ import (
|
||||
"golang.org/x/image/font"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/fonts"
|
||||
"github.com/hajimehoshi/ebiten/text"
|
||||
)
|
||||
|
||||
@ -109,18 +108,7 @@ func init() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
f, err := ebitenutil.OpenFile("_resources/fonts/mplus-1p-regular.ttf")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
tt, err := truetype.Parse(b)
|
||||
tt, err := truetype.Parse(fonts.MPlus1pRegular_ttf)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<h2>Ebiten example - gamepad</h2>
|
||||
<iframe src="gamepad.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<h2>Ebiten example - highdpi</h2>
|
||||
<iframe src="highdpi.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
|
@ -27,18 +27,21 @@
|
||||
|
||||
<h2>Ebiten example - hsv</h2>
|
||||
<iframe src="hsv.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
"math"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -139,11 +142,21 @@ Inverted: %s [I]`, hue, saturation, value, msgInverted)
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Gophers_jpg))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
gophersImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "HSV (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,17 +27,19 @@
|
||||
|
||||
<h2>Ebiten example - hue</h2>
|
||||
<iframe src="hue.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
"math"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -70,11 +72,21 @@ func update(screen *ebiten.Image) error {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Gophers_jpg))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
gophersImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Hue (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,17 +27,20 @@
|
||||
|
||||
<h2>Ebiten example - infinitescroll</h2>
|
||||
<iframe src="infinitescroll.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image"
|
||||
_ "image/png"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -50,11 +53,20 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
bgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/tile.png", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Tile_png))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
bgImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -27,18 +27,20 @@
|
||||
|
||||
<h2>Ebiten example - keyboard</h2>
|
||||
<iframe src="keyboard.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
_ "image/png"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/keyboard/keyboard"
|
||||
rkeyabord "github.com/hajimehoshi/ebiten/examples/resources/images/keyboard"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -49,11 +51,12 @@ const (
|
||||
var keyboardImage *ebiten.Image
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
keyboardImage, _, err = ebitenutil.NewImageFromFile("_resources/images/keyboard/keyboard.png", ebiten.FilterDefault)
|
||||
img, _, err := image.Decode(bytes.NewReader(rkeyabord.Keyboard_png))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
keyboardImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
var keyNames = map[ebiten.Key]string{
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<h2>Ebiten example - life</h2>
|
||||
<iframe src="life.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<h2>Ebiten example - mandelbrot</h2>
|
||||
<iframe src="mandelbrot.content.html" width="640" height="640"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
|
@ -27,11 +27,12 @@
|
||||
|
||||
<h2>Ebiten example - masking</h2>
|
||||
<iframe src="masking.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
_ "image/jpeg"
|
||||
@ -39,7 +40,7 @@ import (
|
||||
"math"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -59,16 +60,26 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
bgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Gophers_jpg))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
bgImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
fgImage, _, err = ebitenutil.NewImageFromFile("_resources/images/fiveyears.jpg", ebiten.FilterDefault)
|
||||
img, _, err = image.Decode(bytes.NewReader(images.FiveYears_jpg))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fgImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
maskedFgImage, _ = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterDefault)
|
||||
|
||||
|
@ -27,16 +27,18 @@
|
||||
|
||||
<h2>Ebiten example - mosaic</h2>
|
||||
<iframe src="mosaic.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -52,11 +54,20 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Gophers_jpg))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
gophersImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<h2>Ebiten example - noise</h2>
|
||||
<iframe src="noise.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<h2>Ebiten example - paint</h2>
|
||||
<iframe src="paint.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
|
@ -27,17 +27,18 @@
|
||||
|
||||
<h2>Ebiten example - perspective</h2>
|
||||
<iframe src="perspective.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -80,11 +81,21 @@ func update(screen *ebiten.Image) error {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Gophers_jpg))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
gophersImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Perspective (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,14 +27,13 @@
|
||||
|
||||
<h2>Ebiten example - piano</h2>
|
||||
<iframe src="piano.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math"
|
||||
|
||||
@ -44,6 +43,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/audio"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/fonts"
|
||||
"github.com/hajimehoshi/ebiten/inpututil"
|
||||
"github.com/hajimehoshi/ebiten/text"
|
||||
)
|
||||
@ -53,18 +53,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
f, err := ebitenutil.OpenFile("_resources/fonts/arcade_n.ttf")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
tt, err := truetype.Parse(b)
|
||||
tt, err := truetype.Parse(fonts.ArcadeN_ttf)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,17 +27,19 @@
|
||||
|
||||
<h2>Ebiten example - rotate</h2>
|
||||
<iframe src="rotate.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
"math"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -74,11 +76,21 @@ func update(screen *ebiten.Image) error {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Gophers_jpg))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
gophersImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Rotate (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<h2>Ebiten example - sinewave</h2>
|
||||
<iframe src="sinewave.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
|
@ -27,12 +27,14 @@
|
||||
|
||||
<h2>Ebiten example - sprites</h2>
|
||||
<iframe src="sprites.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image"
|
||||
_ "image/png"
|
||||
"log"
|
||||
"math"
|
||||
@ -40,6 +42,7 @@ import (
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -105,15 +108,28 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
img, _, err := ebitenutil.NewImageFromFile("_resources/images/ebiten.png", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Ebiten_png))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
w, h := img.Size()
|
||||
ebitenImage, _ = ebiten.NewImage(w, h, ebiten.FilterDefault)
|
||||
origEbitenImage, _ := ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
|
||||
w, h := origEbitenImage.Size()
|
||||
ebitenImage, _ = ebiten.NewImage(w, h, ebiten.FilterNearest)
|
||||
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.ColorM.Scale(1, 1, 1, 0.5)
|
||||
ebitenImage.DrawImage(img, op)
|
||||
ebitenImage.DrawImage(origEbitenImage, op)
|
||||
|
||||
for i := range sprites.sprites {
|
||||
w, h := ebitenImage.Size()
|
||||
x, y := rand.Intn(screenWidth-w), rand.Intn(screenHeight-h)
|
||||
|
@ -27,11 +27,12 @@
|
||||
|
||||
<h2>Ebiten example - tiles</h2>
|
||||
<iframe src="tiles.content.html" width="480" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image"
|
||||
_ "image/png"
|
||||
@ -39,6 +40,7 @@ import (
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -56,11 +58,20 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
tilesImage, _, err = ebitenutil.NewImageFromFile("_resources/images/tiles.png", ebiten.FilterDefault)
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
// If you want to use a file, there are some options:
|
||||
// 1) Use os.Open and pass the file to the image decoder.
|
||||
// This is a very regular way, but doesn't work on browsers.
|
||||
// 2) Use ebitenutil.OpenFile and pass the file to the image decoder.
|
||||
// This works even on browsers.
|
||||
// 3) Use ebitenutil.NewImageFromFile to create an ebiten.Image directly from a file.
|
||||
// This also works on browsers.
|
||||
img, _, err := image.Decode(bytes.NewReader(images.Tiles_png))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
tilesImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<h2>Ebiten example - typewriter</h2>
|
||||
<iframe src="typewriter.content.html" width="640" height="480"></iframe>
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example
|
||||
<div class="card"><pre class="card-body"><code class="language-go">// +build example jsgo
|
||||
|
||||
package main
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
<li class="nav-item"><a class="nav-link" href="https://github.com/hajimehoshi/ebiten">GitHub</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="https://godoc.org/github.com/hajimehoshi/ebiten">GoDoc</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="https://github.com/hajimehoshi/ebiten/wiki">Wiki</a>
|
||||
<li class="nav-item"><a class="nav-link" href="https://ebiten-playground.github.io/">Playground</a>
|
||||
<li class="nav-item"><a class="nav-link" href="https://jsgo.io/dave/jsgo/playground#c3ff01cd9b8e897cf0438a78c87bf1f5aee38095">Playground (jsgo.io)</a>
|
||||
</ul>
|
||||
</div>
|
||||
</div></nav>
|
||||
@ -36,7 +36,7 @@
|
||||
</div></header>
|
||||
|
||||
<main><div class="container">
|
||||
<p>Stable version: v1.6.1 / Development version: v1.7.0-alpha</p>
|
||||
<p>Stable version: v1.6.2 / Development version: v1.7.0-alpha</p>
|
||||
|
||||
<h2 id="platforms">Platforms</h2>
|
||||
<dl class="row">
|
||||
|
Loading…
Reference in New Issue
Block a user