2024-01-13 18:17:34 +03:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2024-05-19 21:11:58 +03:00
|
|
|
|
"surdeus.su/core/gg"
|
2024-06-01 16:07:28 +03:00
|
|
|
|
"surdeus.su/core/gg/ox"
|
|
|
|
|
"github.com/hajimehoshi/ebiten/v2/examples/resources/fonts"
|
|
|
|
|
"bytes"
|
2024-01-14 03:51:11 +03:00
|
|
|
|
//"fmt"
|
2024-01-13 18:17:34 +03:00
|
|
|
|
)
|
|
|
|
|
|
2024-06-01 16:07:28 +03:00
|
|
|
|
type Text struct {
|
|
|
|
|
ox.ObjectImpl
|
|
|
|
|
ox.Text
|
2024-01-13 18:17:34 +03:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-01 16:07:28 +03:00
|
|
|
|
func NewText() (*Text, error) {
|
|
|
|
|
txt := &Text{}
|
|
|
|
|
txt.Transform = ox.T()
|
|
|
|
|
//txt.Position = gg.V2(400)
|
|
|
|
|
txt.Color = gg.RGBA(1, 1, 1, 1)
|
|
|
|
|
txt.Layer = LayerHighest
|
|
|
|
|
txt.Visible = true
|
|
|
|
|
txt.Data = "Hello, World!\nПривет, Мир!"
|
|
|
|
|
var err error
|
|
|
|
|
txt.Face, err = gg.MakeFaceFromTTF(
|
|
|
|
|
bytes.NewReader(fonts.MPlus1pRegular_ttf),
|
|
|
|
|
&gg.FaceOptionsTTF{
|
|
|
|
|
Size: 32,
|
|
|
|
|
DPI: 72,
|
|
|
|
|
Hinting: gg.FontHintingNone,
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return txt, nil
|
2024-01-14 03:51:11 +03:00
|
|
|
|
}
|
2024-01-13 21:45:56 +03:00
|
|
|
|
|
2024-06-01 16:07:28 +03:00
|
|
|
|
func (txt *Text) Update(c *gg.Context) {
|
2024-01-16 07:37:53 +03:00
|
|
|
|
//txt.Data += string(c.Runes())
|
2024-01-14 03:51:11 +03:00
|
|
|
|
}
|