mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
examples/font: Show more Kanji characters
This commit is contained in:
parent
1e84e21857
commit
4b4292a856
@ -42,7 +42,7 @@ var (
|
|||||||
mplusNormalFont font.Face
|
mplusNormalFont font.Face
|
||||||
mplusBigFont font.Face
|
mplusBigFont font.Face
|
||||||
counter = 0
|
counter = 0
|
||||||
kanjiCode = rune(0)
|
kanjiText = []rune{}
|
||||||
)
|
)
|
||||||
|
|
||||||
var jaKanjis = []rune{}
|
var jaKanjis = []rune{}
|
||||||
@ -134,10 +134,15 @@ func codeToColor(c rune) color.RGBA {
|
|||||||
|
|
||||||
func update(screen *ebiten.Image) error {
|
func update(screen *ebiten.Image) error {
|
||||||
if counter%ebiten.FPS == 0 {
|
if counter%ebiten.FPS == 0 {
|
||||||
kanjiCode = jaKanjis[rand.Intn(len(jaKanjis))]
|
kanjiText = []rune{}
|
||||||
|
for j := 0; j < 4; j++ {
|
||||||
|
for i := 0; i < 8; i++ {
|
||||||
|
kanjiText = append(kanjiText, jaKanjis[rand.Intn(len(jaKanjis))])
|
||||||
|
}
|
||||||
|
kanjiText = append(kanjiText, '\n')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
counter++
|
counter++
|
||||||
kanjiText := fmt.Sprintf("%s: U+%04x", string(kanjiCode), kanjiCode)
|
|
||||||
|
|
||||||
if ebiten.IsRunningSlowly() {
|
if ebiten.IsRunningSlowly() {
|
||||||
return nil
|
return nil
|
||||||
@ -147,7 +152,7 @@ func update(screen *ebiten.Image) error {
|
|||||||
const x = 20
|
const x = 20
|
||||||
text.Draw(screen, mplusNormalFont, msg, x, 40, 30, color.White)
|
text.Draw(screen, mplusNormalFont, msg, x, 40, 30, color.White)
|
||||||
text.Draw(screen, mplusNormalFont, sampleText, x, 80, 30, color.White)
|
text.Draw(screen, mplusNormalFont, sampleText, x, 80, 30, color.White)
|
||||||
text.Draw(screen, mplusBigFont, kanjiText, x, 160, 30, codeToColor(kanjiCode))
|
text.Draw(screen, mplusBigFont, string(kanjiText), x, 160, 54, codeToColor(kanjiText[0]))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user