Skip to main content

Create an image from text (image.new_text_image)

Declaration

img = image.new_text_image(text[, {
font = font_name,
size = font_size,
color = font_color,
alpha = font_alpha,
back_color = background_color,
back_alpha = background_alpha,
}])

Parameters

  • text
    String. Text content to render
  • font
    String, optional. Font family. Default "Arial"
  • font_size
    Number, optional. Font size. Default 20.0
  • font_color
    Integer, optional. Font color. Default 0xffffff (white)
  • font_alpha
    Integer, optional. Font opacity, range 0~255. Default 255
  • background_color
    Integer, optional. Background color. Default 0x000000 (black)
  • background_alpha
    Integer, optional. Background opacity, range 0~255. Default 255

Returns

  • img
    Image object. The newly created image

Description

Create a properly sized image and render the text on it
This call creates a new image object. For efficient frequent usage, please pair with image:destroy