27 lines
428 B
Go
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)
|
|
}
|