Skip to content

Commit

Permalink
docs: Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Mar 21, 2018
1 parent f92a274 commit 61005e3
Show file tree
Hide file tree
Showing 29 changed files with 242 additions and 118 deletions.
2 changes: 1 addition & 1 deletion _docs/index.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Binary file removed docs/examples/_resources/audio/game.ogg
Binary file not shown.
8 changes: 0 additions & 8 deletions docs/examples/_resources/audio/license.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 18 additions & 6 deletions docs/examples/airship.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">// &#43;build example
<div class="card"><pre class="card-body"><code class="language-go">// &#43;build example jsgo

package main

import (
&#34;bytes&#34;
&#34;fmt&#34;
&#34;image&#34;
&#34;image/color&#34;
Expand All @@ -41,6 +42,7 @@ <h2>Ebiten example - airship</h2>

&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/resources/images&#34;
)

const (
Expand All @@ -65,11 +67,21 @@ <h2>Ebiten example - airship</h2>
)

func init() {
var err error
gophersImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/gophers.jpg&#34;, 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&#39;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&#43;50, ebiten.FilterDefault)
perspectiveGroundImage, _ = ebiten.NewImage(screenWidth*2, screenHeight, ebiten.FilterDefault)

Expand Down Expand Up @@ -210,9 +222,9 @@ <h2>Ebiten example - airship</h2>
gw, _ := ground.Size()
pw, ph := perspectiveGroundImage.Size()
for j := 0; j &lt; ph; j&#43;&#43; {
// z is in [1, -1]
// z is in [2, -1]
rate := float64(j) / float64(ph)
z := (1-rate)*1 &#43; rate*-1
z := (1-rate)*2 &#43; rate*-1
if z &lt;= 0 {
break
}
Expand Down
20 changes: 16 additions & 4 deletions docs/examples/alphablending.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">// &#43;build example
<div class="card"><pre class="card-body"><code class="language-go">// &#43;build example jsgo

package main

import (
&#34;bytes&#34;
&#34;image&#34;
&#34;image/color&#34;
_ &#34;image/png&#34;
&#34;log&#34;

&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/resources/images&#34;
)

const (
Expand Down Expand Up @@ -81,11 +83,21 @@ <h2>Ebiten example - alphablending</h2>
}

func main() {
var err error
ebitenImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/ebiten.png&#34;, 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&#39;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, &#34;Alpha Blending (Ebiten Demo)&#34;); err != nil {
log.Fatal(err)
}
Expand Down
15 changes: 4 additions & 11 deletions docs/examples/audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">// &#43;build example
<div class="card"><pre class="card-body"><code class="language-go">// &#43;build example jsgo

// This is an example to implement an audio player.
// See examples/wav for a simpler example to play a sound file.
Expand All @@ -46,6 +46,7 @@ <h2>Ebiten example - audio</h2>
&#34;github.com/hajimehoshi/ebiten/audio/mp3&#34;
&#34;github.com/hajimehoshi/ebiten/audio/wav&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
raudio &#34;github.com/hajimehoshi/ebiten/examples/resources/audio&#34;
&#34;github.com/hajimehoshi/ebiten/inpututil&#34;
)

Expand Down Expand Up @@ -83,15 +84,7 @@ <h2>Ebiten example - audio</h2>

func NewPlayer(audioContext *audio.Context) (*Player, error) {
const bytesPerSample = 4 // TODO: This should be defined in audio package
wavF, err := ebitenutil.OpenFile(&#34;_resources/audio/jab.wav&#34;)
if err != nil {
return nil, err
}
mp3F, err := ebitenutil.OpenFile(&#34;_resources/audio/classic.mp3&#34;)
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
}
Expand All @@ -111,7 +104,7 @@ <h2>Ebiten example - audio</h2>
}
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
Expand Down
26 changes: 20 additions & 6 deletions docs/examples/filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">// &#43;build example
<div class="card"><pre class="card-body"><code class="language-go">// &#43;build example jsgo

package main

import (
&#34;bytes&#34;
&#34;image&#34;
_ &#34;image/png&#34;
&#34;log&#34;

&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/resources/images&#34;
)

const (
Expand Down Expand Up @@ -72,14 +75,25 @@ <h2>Ebiten example - filter</h2>
}

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(&#34;_resources/images/ebiten.png&#34;, 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&#39;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, &#34;Filter (Ebiten Demo)&#34;); err != nil {
log.Fatal(err)
}
Expand Down
20 changes: 16 additions & 4 deletions docs/examples/flood.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">// &#43;build example
<div class="card"><pre class="card-body"><code class="language-go">// &#43;build example jsgo

package main

import (
&#34;bytes&#34;
&#34;image&#34;
&#34;image/color&#34;
_ &#34;image/png&#34;
&#34;log&#34;

&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/resources/images&#34;
)

const (
Expand Down Expand Up @@ -97,11 +99,21 @@ <h2>Ebiten example - flood</h2>
}

func main() {
var err error
ebitenImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/ebiten.png&#34;, 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&#39;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, &#34;Flood fill with solid colors (Ebiten Demo)&#34;); err != nil {
log.Fatal(err)
}
Expand Down
18 changes: 3 additions & 15 deletions docs/examples/font.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">// &#43;build example
<div class="card"><pre class="card-body"><code class="language-go">// &#43;build example jsgo

package main

import (
&#34;fmt&#34;
&#34;image/color&#34;
&#34;io/ioutil&#34;
&#34;log&#34;
&#34;math/rand&#34;
&#34;strings&#34;
Expand All @@ -44,7 +43,7 @@ <h2>Ebiten example - font</h2>
&#34;golang.org/x/image/font&#34;

&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/resources/fonts&#34;
&#34;github.com/hajimehoshi/ebiten/text&#34;
)

Expand Down Expand Up @@ -109,18 +108,7 @@ <h2>Ebiten example - font</h2>
}

func init() {
f, err := ebitenutil.OpenFile(&#34;_resources/fonts/mplus-1p-regular.ttf&#34;)
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)
}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/gamepad.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">// &#43;build example
<div class="card"><pre class="card-body"><code class="language-go">// &#43;build example jsgo

package main

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/highdpi.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">// &#43;build example
<div class="card"><pre class="card-body"><code class="language-go">// &#43;build example jsgo

package main

Expand Down
19 changes: 16 additions & 3 deletions docs/examples/hsv.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">// &#43;build example
<div class="card"><pre class="card-body"><code class="language-go">// &#43;build example jsgo

package main

import (
&#34;bytes&#34;
&#34;fmt&#34;
&#34;image&#34;
_ &#34;image/jpeg&#34;
&#34;log&#34;
&#34;math&#34;

&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/examples/resources/images&#34;
)

const (
Expand Down Expand Up @@ -139,11 +142,21 @@ <h2>Ebiten example - hsv</h2>
}

func main() {
var err error
gophersImage, _, err = ebitenutil.NewImageFromFile(&#34;_resources/images/gophers.jpg&#34;, 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&#39;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, &#34;HSV (Ebiten Demo)&#34;); err != nil {
log.Fatal(err)
}
Expand Down
Loading

0 comments on commit 61005e3

Please sign in to comment.