textWidth

Static textWidth 

Source
pub static textWidth: TextWidthInternalType
Expand description

Calculates and returns the width of any character or text string.

Examples

textSize(28);

let aChar = 'P';
let cWidth = textWidth(aChar);
text(aChar, 0, 40);
line(cWidth, 0, cWidth, 50);

let aString = 'p5.js';
let sWidth = textWidth(aString);
text(aString, 0, 85);
line(sWidth, 50, sWidth, 100);

Parameters

theText the String of characters to measure