q5play
    Preparing search index...

    Function textImage

    • 📘 Renders an image generated from text onto the canvas.

      If the first parameter is a string, an image of the text will be created and cached automatically.

      The positioning of the image is affected by the current text alignment and baseline settings.

      This function can be used to draw emojis, which can not be drawn with MSDF text rendering.

      Using this function to draw text that changes every frame has a very high performance cost.

      Parameters

      • img: String | Image

        image or text

      • x: number

        x-coordinate where the image should be placed

      • y: number

        y-coordinate where the image should be placed

      Returns void

      await Canvas(200);
      background(0.8);
      textSize(96);
      textAlign(CENTER, CENTER);

      textImage('🐶', 0, 0);