41 lines
755 B
Go
41 lines
755 B
Go
package main
|
||
|
||
import (
|
||
"surdeus.su/core/gg"
|
||
"surdeus.su/core/gg/ox"
|
||
"github.com/hajimehoshi/ebiten/v2/examples/resources/fonts"
|
||
"bytes"
|
||
//"fmt"
|
||
)
|
||
|
||
type Text struct {
|
||
ox.ObjectImpl
|
||
ox.Text
|
||
}
|
||
|
||
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
|
||
}
|
||
|
||
func (txt *Text) Update(c *gg.Context) {
|
||
//txt.Data += string(c.Runes())
|
||
}
|