Update docs

This commit is contained in:
Hajime Hoshi 2015-01-21 00:51:55 +09:00
parent f88f48f0ae
commit 106984e9c7
5 changed files with 87 additions and 9 deletions

View File

@ -81,6 +81,26 @@ pre {
<li>v1.2.0-rc1 released.
<ul>
<li>Support for gamepads</li>
<li>Added new functions for image rendering:
<ul>
<li>Image.DrawFilledRect</li>
<li>Image.DrawFilledRects</li>
<li>Image.DrawLine</li>
<li>Image.DrawLines</li>
<li>Image.DrawRect</li>
<li>Image.DrawRects</li>
<li>Image.ReplacePixels</li>
</ul>
</li>
<li>Some bug fix</li>
</ul>
</li>
</ul>
<h3>2015-??-??</h3>
<ul>
<li>v1.1.0 released.
<ul>
<li>Some bug fix</li>
</ul>
</li>
</ul>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -41,10 +41,9 @@ pre {
import (
&#34;github.com/hajimehoshi/ebiten&#34;
&#34;github.com/hajimehoshi/ebiten/ebitenutil&#34;
&#34;github.com/hajimehoshi/ebiten/example/keyboard/keyboard&#34;
&#34;log&#34;
&#34;sort&#34;
&#34;strconv&#34;
&#34;strings&#34;
)
const (
@ -52,13 +51,23 @@ const (
screenHeight = 240
)
var keyboardImage *ebiten.Image
func init() {
var err error
keyboardImage, _, err = ebitenutil.NewImageFromFile(&#34;images/keyboard/keyboard.png&#34;, ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
}
var keyNames = map[ebiten.Key]string{
ebiten.KeyBackspace: &#34;Backspace&#34;,
ebiten.KeyComma: &#34;&#39;,&#39;&#34;,
ebiten.KeyDelete: &#34;Delete&#34;,
ebiten.KeyBackspace: &#34;BS&#34;,
ebiten.KeyComma: &#34;,&#34;,
ebiten.KeyDelete: &#34;Del&#34;,
ebiten.KeyEnter: &#34;Enter&#34;,
ebiten.KeyEscape: &#34;Esc&#34;,
ebiten.KeyPeriod: &#34;&#39;.&#39;&#34;,
ebiten.KeyPeriod: &#34;.&#34;,
ebiten.KeySpace: &#34;Space&#34;,
ebiten.KeyTab: &#34;Tab&#34;,
@ -74,7 +83,32 @@ var keyNames = map[ebiten.Key]string{
ebiten.KeyAlt: &#34;Alt&#34;,
}
type pressedKeysParts []string
func (p pressedKeysParts) Len() int {
return len(p)
}
func (p pressedKeysParts) Dst(i int) (x0, y0, x1, y1 int) {
k := p[i]
r, ok := keyboard.KeyRect(k)
if !ok {
return 0, 0, 0, 0
}
return r.Min.X, r.Min.Y, r.Max.X, r.Max.Y
}
func (p pressedKeysParts) Src(i int) (x0, y0, x1, y1 int) {
return p.Dst(i)
}
func update(screen *ebiten.Image) error {
const offsetX, offsetY = 24, 40
op := &amp;ebiten.DrawImageOptions{}
op.GeoM.Translate(offsetX, offsetY)
op.ColorM.Scale(0.5, 0.5, 0.5, 1)
screen.DrawImage(keyboardImage, op)
pressed := []string{}
for i := 0; i &lt;= 9; i&#43;&#43; {
if ebiten.IsKeyPressed(ebiten.Key(i) &#43; ebiten.Key0) {
@ -96,9 +130,13 @@ func update(screen *ebiten.Image) error {
pressed = append(pressed, name)
}
}
sort.Strings(pressed)
str := &#34;Pressed Keys: &#34; &#43; strings.Join(pressed, &#34;, &#34;)
ebitenutil.DebugPrint(screen, str)
op = &amp;ebiten.DrawImageOptions{
ImageParts: pressedKeysParts(pressed),
}
op.GeoM.Translate(offsetX, offsetY)
screen.DrawImage(keyboardImage, op)
return nil
}

View File

@ -107,6 +107,26 @@ pre {
<li>v1.2.0-rc1 released.
<ul>
<li>Support for gamepads</li>
<li>Added new functions for image rendering:
<ul>
<li>Image.DrawFilledRect</li>
<li>Image.DrawFilledRects</li>
<li>Image.DrawLine</li>
<li>Image.DrawLines</li>
<li>Image.DrawRect</li>
<li>Image.DrawRects</li>
<li>Image.ReplacePixels</li>
</ul>
</li>
<li>Some bug fix</li>
</ul>
</li>
</ul>
<h3>2015-??-??</h3>
<ul>
<li>v1.1.0 released.
<ul>
<li>Some bug fix</li>
</ul>
</li>
</ul>