doc: Update

This commit is contained in:
Hajime Hoshi 2017-07-20 02:23:45 +09:00
parent 2f6953ff7f
commit 47734f28e3

View File

@ -57,6 +57,7 @@ var (
mplusBigFont font.Face
counter = 0
kanjiText = []rune{}
kanjiTextColor color.RGBA
)
var jaKanjis = []rune{}
@ -139,13 +140,6 @@ func init() {
rand.Seed(time.Now().UnixNano())
}
func codeToColor(c rune) color.RGBA {
r := 0x80 + ((uint8(c) & 0x0f) << 3)
g := 0x80 + ((uint8(c>>4) & 0x0f) << 3)
b := 0x80 + ((uint8(c>>8) & 0x0f) << 3)
return color.RGBA{r, g, b, 0xff}
}
func update(screen *ebiten.Image) error {
if counter%ebiten.FPS == 0 {
kanjiText = []rune{}
@ -155,6 +149,11 @@ func update(screen *ebiten.Image) error {
}
kanjiText = append(kanjiText, '\n')
}
kanjiTextColor.R = 0x80 + uint8(rand.Intn(0x7f))
kanjiTextColor.G = 0x80 + uint8(rand.Intn(0x7f))
kanjiTextColor.B = 0x80 + uint8(rand.Intn(0x7f))
kanjiTextColor.A = 0xff
}
counter++
@ -164,10 +163,10 @@ func update(screen *ebiten.Image) error {
msg := fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS())
const x = 20
text.Draw(screen, mplusNormalFont, msg, x, 40, color.White)
text.Draw(screen, mplusNormalFont, sampleText, x, 80, color.White)
text.Draw(screen, msg, mplusNormalFont, x, 40, color.White)
text.Draw(screen, sampleText, mplusNormalFont, x, 80, color.White)
for i, line := range strings.Split(string(kanjiText), "\n") {
text.Draw(screen, mplusBigFont, line, x, 160+54*i, codeToColor(kanjiText[0]))
text.Draw(screen, line, mplusBigFont, x, 160+54*i, kanjiTextColor)
}
return nil
}