display-test/drawer/text.go
2024-08-21 19:07:29 +03:00

27 lines
428 B
Go

package drawer
import (
"image"
"image/color"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
func (d *drawer) PutText(x, y int, text string) {
d.Lock()
defer d.Unlock()
// Create font drawer
col := color.Gray{255}
point := fixed.Point26_6{X: fixed.I(x), Y: fixed.I(y)}
drawer := &font.Drawer{
Dst: d.img,
Src: image.NewUniform(col),
Face: d.font,
Dot: point,
}
drawer.DrawString(text)
}