q5play
    Preparing search index...

    Function textWidth

    • 📘 Calculates and returns the width of a given string of text.

      Parameters

      • str: string

        string to measure

      Returns number

      width of the text in pixels

      q5.draw = function () {
      background(0.8);

      textSize(abs(mouseX));
      rect(-90, 90, textWidth('A'), -textLeading());
      text('A', -90, 90);
      };