39 lines
619 B
Go
39 lines
619 B
Go
package widgets
|
|
|
|
import (
|
|
"image/color"
|
|
|
|
"tetris/engine/core"
|
|
"tetris/engine/render"
|
|
|
|
rl "github.com/gen2brain/raylib-go/raylib"
|
|
)
|
|
|
|
type Label struct {
|
|
text string
|
|
size int32
|
|
color color.RGBA
|
|
}
|
|
|
|
func NewLabel(text string, size int32) *Label {
|
|
return &Label{
|
|
text: text,
|
|
size: size,
|
|
color: rl.White,
|
|
}
|
|
}
|
|
|
|
func (label Label) Size() core.Vec2i {
|
|
return core.Vec2i{
|
|
X: int(label.size) * len(label.text),
|
|
Y: int(label.size),
|
|
}
|
|
}
|
|
|
|
func (label *Label) SetColor(col color.RGBA) {
|
|
label.color = col
|
|
}
|
|
|
|
func (label Label) Draw(x, y int32) {
|
|
render.DrawText(x, y, label.size, label.text, label.color)
|
|
}
|