diff --git a/_docs/index.tmpl.html b/_docs/index.tmpl.html index 2d0c32459..6c0bbc3da 100644 --- a/_docs/index.tmpl.html +++ b/_docs/index.tmpl.html @@ -4,23 +4,7 @@
Stable version: v{{.StableVersion}} / Development version: v{{.DevVersion}}
diff --git a/_docs/public/examples/_resources/images/license.md b/_docs/public/examples/_resources/images/license.md index 0cd416aae..600f3160c 100644 --- a/_docs/public/examples/_resources/images/license.md +++ b/_docs/public/examples/_resources/images/license.md @@ -23,6 +23,14 @@ Photograph by Chris Nokleberg the Creative Commons Attribution 3.0 License ``` +## tile.png + +``` +http://opengameart.org/node/8016 + +CC0 1.0 +``` + ## Other image files ``` diff --git a/_docs/public/examples/_resources/images/tile.png b/_docs/public/examples/_resources/images/tile.png new file mode 100644 index 000000000..33c138f41 Binary files /dev/null and b/_docs/public/examples/_resources/images/tile.png differ diff --git a/_docs/public/examples/alphablending.html b/_docs/public/examples/alphablending.html index 633ca8f67..b02099803 100644 --- a/_docs/public/examples/alphablending.html +++ b/_docs/public/examples/alphablending.html @@ -36,7 +36,9 @@ pre {package main
+// +build example
+
+package main
import (
"image/color"
@@ -88,7 +90,9 @@ func update(screen *ebiten.Image) error {
diff = float64(480-count) * 0.2
}
- screen.Fill(color.NRGBA{0x00, 0x00, 0x80, 0xff})
+ if err := screen.Fill(color.NRGBA{0x00, 0x00, 0x80, 0xff}); err != nil {
+ return err
+ }
op := &ebiten.DrawImageOptions{}
op.ColorM.Scale(1.0, 1.0, 1.0, 0.5)
op.ImageParts = &imageParts{
diff --git a/_docs/public/examples/audio.html b/_docs/public/examples/audio.html
index c12d84f5d..6354d376d 100644
--- a/_docs/public/examples/audio.html
+++ b/_docs/public/examples/audio.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - audio
-package main
+// +build example
+
+package main
import (
"fmt"
@@ -68,13 +70,17 @@ func init() {
if err != nil {
log.Fatal(err)
}
- playerBarImage.Fill(&color.RGBA{0x80, 0x80, 0x80, 0xff})
+ if err := playerBarImage.Fill(&color.RGBA{0x80, 0x80, 0x80, 0xff}); err != nil {
+ log.Fatal(err)
+ }
playerCurrentImage, err = ebiten.NewImage(4, 10, ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
- playerCurrentImage.Fill(&color.RGBA{0xff, 0xff, 0xff, 0xff})
+ if err := playerCurrentImage.Fill(&color.RGBA{0xff, 0xff, 0xff, 0xff}); err != nil {
+ log.Fatal(err)
+ }
}
type Player struct {
@@ -217,7 +223,9 @@ func update(screen *ebiten.Image) error {
op := &ebiten.DrawImageOptions{}
x, y, w, h := playerBarRect()
op.GeoM.Translate(float64(x), float64(y))
- screen.DrawImage(playerBarImage, op)
+ if err := screen.DrawImage(playerBarImage, op); err != nil {
+ return err
+ }
currentTimeStr := "00:00"
if musicPlayer != nil {
c := musicPlayer.audioPlayer.Current()
@@ -233,7 +241,9 @@ func update(screen *ebiten.Image) error {
cy := y - (ch-h)/2
op := &ebiten.DrawImageOptions{}
op.GeoM.Translate(float64(cx), float64(cy))
- screen.DrawImage(playerCurrentImage, op)
+ if err := screen.DrawImage(playerCurrentImage, op); err != nil {
+ return err
+ }
}
msg := fmt.Sprintf(`FPS: %0.2f
@@ -244,7 +254,9 @@ Press Z or X to change volume of the music
if musicPlayer == nil {
msg += "\nNow Loading..."
}
- ebitenutil.DebugPrint(screen, msg)
+ if err := ebitenutil.DebugPrint(screen, msg); err != nil {
+ return err
+ }
if err := audioContext.Update(); err != nil {
return err
}
@@ -297,7 +309,10 @@ func main() {
}
close(musicCh)
// TODO: Is this goroutine-safe?
- p.Play()
+ if err := p.Play(); err != nil {
+ log.Fatal(err)
+ return
+ }
}()
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Audio (Ebiten Demo)"); err != nil {
log.Fatal(err)
diff --git a/_docs/public/examples/font.html b/_docs/public/examples/font.html
index 4285b03ed..2ba276344 100644
--- a/_docs/public/examples/font.html
+++ b/_docs/public/examples/font.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - font
-package main
+// +build example
+
+package main
import (
"image"
@@ -76,7 +78,9 @@ func parseFont() error {
if err != nil {
return err
}
- defer f.Close()
+ defer func() {
+ _ = f.Close()
+ }()
b, err := ioutil.ReadAll(f)
if err != nil {
return err
@@ -98,12 +102,11 @@ func parseFont() error {
Hinting: font.HintingFull,
}),
}
- dy := size * dpi / 72
- y := dy
+ y := size
for _, s := range text {
d.Dot = fixed.P(0, y)
d.DrawString(s)
- y += dy
+ y += size
}
return textImage.ReplacePixels(dst.Pix)
}
diff --git a/_docs/public/examples/gamepad.html b/_docs/public/examples/gamepad.html
index 0797b04c2..8714b0102 100644
--- a/_docs/public/examples/gamepad.html
+++ b/_docs/public/examples/gamepad.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - gamepad
-package main
+// +build example
+
+package main
import (
"fmt"
@@ -78,7 +80,9 @@ func update(screen *ebiten.Image) error {
Pressed Buttons: {{.Buttons}}`
str = strings.Replace(str, "{{.Axes}}", strings.Join(axes, "\n "), -1)
str = strings.Replace(str, "{{.Buttons}}", strings.Join(pressedButtons, ", "), -1)
- ebitenutil.DebugPrint(screen, str)
+ if err := ebitenutil.DebugPrint(screen, str); err != nil {
+ return err
+ }
return nil
}
diff --git a/_docs/public/examples/hsv.html b/_docs/public/examples/hsv.html
index 5ab38b242..6c33546d5 100644
--- a/_docs/public/examples/hsv.html
+++ b/_docs/public/examples/hsv.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - hsv
-package main
+// +build example
+
+package main
import (
"fmt"
diff --git a/_docs/public/examples/hue.html b/_docs/public/examples/hue.html
index 9f8078e13..1e69141f3 100644
--- a/_docs/public/examples/hue.html
+++ b/_docs/public/examples/hue.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - hue
-package main
+// +build example
+
+package main
import (
_ "image/jpeg"
diff --git a/_docs/public/examples/keyboard.html b/_docs/public/examples/keyboard.html
index e4c30918f..142b34795 100644
--- a/_docs/public/examples/keyboard.html
+++ b/_docs/public/examples/keyboard.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - keyboard
-package main
+// +build example
+
+package main
import (
"log"
@@ -108,7 +110,9 @@ func update(screen *ebiten.Image) error {
op := &ebiten.DrawImageOptions{}
op.GeoM.Translate(offsetX, offsetY)
op.ColorM.Scale(0.5, 0.5, 0.5, 1)
- screen.DrawImage(keyboardImage, op)
+ if err := screen.DrawImage(keyboardImage, op); err != nil {
+ return err
+ }
pressed := []string{}
for i := 0; i <= 9; i++ {
@@ -136,7 +140,9 @@ func update(screen *ebiten.Image) error {
ImageParts: pressedKeysParts(pressed),
}
op.GeoM.Translate(offsetX, offsetY)
- screen.DrawImage(keyboardImage, op)
+ if err := screen.DrawImage(keyboardImage, op); err != nil {
+ return err
+ }
return nil
}
diff --git a/_docs/public/examples/masking.html b/_docs/public/examples/masking.html
index ec0c4e67f..217945dec 100644
--- a/_docs/public/examples/masking.html
+++ b/_docs/public/examples/masking.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - masking
-package main
+// +build example
+
+package main
import (
"image"
diff --git a/_docs/public/examples/mosaic.html b/_docs/public/examples/mosaic.html
index a2386cd48..6f1fe5a17 100644
--- a/_docs/public/examples/mosaic.html
+++ b/_docs/public/examples/mosaic.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - mosaic
-package main
+// +build example
+
+package main
import (
_ "image/jpeg"
@@ -61,10 +63,14 @@ var (
func update(screen *ebiten.Image) error {
op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(1.0/mosaicRatio, 1.0/mosaicRatio)
- gophersRenderTarget.DrawImage(gophersImage, op)
+ if err := gophersRenderTarget.DrawImage(gophersImage, op); err != nil {
+ return err
+ }
op = &ebiten.DrawImageOptions{}
op.GeoM.Scale(mosaicRatio, mosaicRatio)
- screen.DrawImage(gophersRenderTarget, op)
+ if err := screen.DrawImage(gophersRenderTarget, op); err != nil {
+ return err
+ }
return nil
}
diff --git a/_docs/public/examples/noise.html b/_docs/public/examples/noise.html
index fb4ec3b3f..64493124f 100644
--- a/_docs/public/examples/noise.html
+++ b/_docs/public/examples/noise.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - noise
-package main
+// +build example
+
+package main
import (
"fmt"
@@ -80,8 +82,12 @@ func update(screen *ebiten.Image) error {
noiseImage.Pix[4*i+2] = uint8(x >> 8)
noiseImage.Pix[4*i+3] = 0xff
}
- screen.ReplacePixels(noiseImage.Pix)
- ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %f", ebiten.CurrentFPS()))
+ if err := screen.ReplacePixels(noiseImage.Pix); err != nil {
+ return err
+ }
+ if err := ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %f", ebiten.CurrentFPS())); err != nil {
+ return err
+ }
return nil
}
diff --git a/_docs/public/examples/paint.html b/_docs/public/examples/paint.html
index 40c14c8b8..7f76b6883 100644
--- a/_docs/public/examples/paint.html
+++ b/_docs/public/examples/paint.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - paint
-package main
+// +build example
+
+package main
import (
"fmt"
@@ -129,7 +131,9 @@ func main() {
if err != nil {
log.Fatal(err)
}
- canvasImage.Fill(color.White)
+ if err := canvasImage.Fill(color.White); err != nil {
+ log.Fatal(err)
+ }
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Paint (Ebiten Demo)"); err != nil {
log.Fatal(err)
diff --git a/_docs/public/examples/perspective.html b/_docs/public/examples/perspective.html
index 037f47d34..9100d8072 100644
--- a/_docs/public/examples/perspective.html
+++ b/_docs/public/examples/perspective.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - perspective
-package main
+// +build example
+
+package main
import (
_ "image/jpeg"
@@ -84,7 +86,9 @@ func update(screen *ebiten.Image) error {
maxWidth := float64(w) + float64(h)*0.75
op.GeoM.Translate(-maxWidth/2, -float64(h)/2)
op.GeoM.Translate(screenWidth/2, screenHeight/2)
- screen.DrawImage(gophersImage, op)
+ if err := screen.DrawImage(gophersImage, op); err != nil {
+ return err
+ }
return nil
}
diff --git a/_docs/public/examples/piano.html b/_docs/public/examples/piano.html
index ba0993258..cf39bc743 100644
--- a/_docs/public/examples/piano.html
+++ b/_docs/public/examples/piano.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - piano
-package main
+// +build example
+
+package main
import (
"fmt"
@@ -113,7 +115,9 @@ func addNote(freq float64, vol float64) error {
if err != nil {
return err
}
- p.Play()
+ if err := p.Play(); err != nil {
+ return err
+ }
return nil
}
length := len(pcm) * baseFreq / f
@@ -134,7 +138,9 @@ func addNote(freq float64, vol float64) error {
if err != nil {
return err
}
- p.Play()
+ if err := p.Play(); err != nil {
+ return err
+ }
return nil
}
@@ -185,7 +191,9 @@ func init() {
if err != nil {
panic(err)
}
- imageEmpty.Fill(color.White)
+ if err := imageEmpty.Fill(color.White); err != nil {
+ panic(err)
+ }
imagePiano, err = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest)
if err != nil {
panic(err)
@@ -201,8 +209,12 @@ func init() {
op.GeoM.Scale(float64(width-1)/float64(w), float64(height)/float64(h))
op.GeoM.Translate(float64(x), float64(y))
op.ColorM.Scale(1, 1, 1, 1)
- imagePiano.DrawImage(imageEmpty, op)
- common.ArcadeFont.DrawText(imagePiano, k, x+8, y+height-16, 1, color.Black)
+ if err := imagePiano.DrawImage(imageEmpty, op); err != nil {
+ panic(err)
+ }
+ if err := common.ArcadeFont.DrawText(imagePiano, k, x+8, y+height-16, 1, color.Black); err != nil {
+ panic(err)
+ }
}
blackKeys := []string{"Q", "W", "", "R", "T", "", "U", "I", "O"}
@@ -217,8 +229,12 @@ func init() {
op.GeoM.Scale(float64(width-1)/float64(w), float64(height)/float64(h))
op.GeoM.Translate(float64(x), float64(y))
op.ColorM.Scale(0, 0, 0, 1)
- imagePiano.DrawImage(imageEmpty, op)
- common.ArcadeFont.DrawText(imagePiano, k, x+8, y+height-16, 1, color.White)
+ if err := imagePiano.DrawImage(imageEmpty, op); err != nil {
+ panic(err)
+ }
+ if err := common.ArcadeFont.DrawText(imagePiano, k, x+8, y+height-16, 1, color.White); err != nil {
+ panic(err)
+ }
}
}
@@ -233,10 +249,16 @@ func update(screen *ebiten.Image) error {
}
}
- screen.Fill(color.RGBA{0x80, 0x80, 0xc0, 0xff})
- screen.DrawImage(imagePiano, nil)
+ if err := screen.Fill(color.RGBA{0x80, 0x80, 0xc0, 0xff}); err != nil {
+ return err
+ }
+ if err := screen.DrawImage(imagePiano, nil); err != nil {
+ return err
+ }
- ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS()))
+ if err := ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS())); err != nil {
+ return err
+ }
if err := audioContext.Update(); err != nil {
return err
diff --git a/_docs/public/examples/rotate.html b/_docs/public/examples/rotate.html
index a09f5ad3c..809e5622d 100644
--- a/_docs/public/examples/rotate.html
+++ b/_docs/public/examples/rotate.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - rotate
-package main
+// +build example
+
+package main
import (
_ "image/jpeg"
diff --git a/_docs/public/examples/sprites.html b/_docs/public/examples/sprites.html
index 463cc0070..c12096798 100644
--- a/_docs/public/examples/sprites.html
+++ b/_docs/public/examples/sprites.html
@@ -36,7 +36,9 @@ pre {
Ebiten example - sprites
-package main
+// +build example
+
+package main
import (
"fmt"
diff --git a/_docs/public/index.html b/_docs/public/index.html
index a207e96fb..ece4f7415 100644
--- a/_docs/public/index.html
+++ b/_docs/public/index.html
@@ -18,23 +18,7 @@ limitations under the License.
Ebiten - A simple SNES-like 2D game library in Go
-
+
Ebiten (海老天)
Stable version: v1.4.0-alpha / Development version: v1.4.0-alpha
@@ -70,10 +54,12 @@ pre {
-Execute the example
+Execute the examples
:; go get github.com/hajimehoshi/ebiten
:; cd $GOPATH/src/github.com/hajimehoshi/ebiten/examples
-:; go run rotate/main.go
+:; go run -tags example rotate/main.go
+
+Note that you need to specify example
tag.
Getting Started
diff --git a/_docs/public/style.css b/_docs/public/style.css
new file mode 100644
index 000000000..f719e5c43
--- /dev/null
+++ b/_docs/public/style.css
@@ -0,0 +1,15 @@
+body {
+ font-family: sans-serif;
+}
+img.example {
+ background-color: #000;
+ border-color: #999;
+ border-style: solid;
+ border-width: 1px;
+ image-rendering: crisp-edges;
+ image-rendering: pixelated;
+}
+pre {
+ background: #eee;
+ padding: 1em;
+}
diff --git a/internal/license.go b/internal/license.go
index ca84bd18d..8f36cbba6 100644
--- a/internal/license.go
+++ b/internal/license.go
@@ -21,6 +21,7 @@ import (
"strings"
)
+// LicenseComment returns the license string in Go comment style.
func LicenseComment() (string, error) {
_, path, _, _ := runtime.Caller(0)
licensePath := filepath.Join(filepath.Dir(path), "..", "LICENSE")