MCPcopy
hub / github.com/g3n/engine / DrawText

Method DrawText

text/font.go:207–215  ·  view source on GitHub ↗

DrawText draws the specified text on a new, tightly fitting image, and returns a pointer to the image.

(text string)

Source from the content-addressed store, hash-verified

205
206// DrawText draws the specified text on a new, tightly fitting image, and returns a pointer to the image.
207func (f *Font) DrawText(text string) *image.RGBA {
208
209 width, height := f.MeasureText(text)
210 img := image.NewRGBA(image.Rect(0, 0, width, height))
211 draw.Draw(img, img.Bounds(), f.bg, image.ZP, draw.Src)
212 f.DrawTextOnImage(text, 0, 0, img)
213
214 return img
215}
216
217// DrawTextOnImage draws the specified text on the specified image at the specified coordinates.
218func (f *Font) DrawTextOnImage(text string, x, y int, dst *image.RGBA) {

Callers 1

SetTextMethod · 0.45

Calls 2

MeasureTextMethod · 0.95
DrawTextOnImageMethod · 0.95

Tested by

no test coverage detected