text_width()
Contents
text_width()¶
Calculates and returns the width of any character or text string.
Examples¶

1 2 3 4 5 6 7 8 9 10 11 12 | def setup():
py5.text_size(28)
c = 't'
cw = py5.text_width(c)
py5.text(c, 0, 40)
py5.line(cw, 0, cw, 50)
s = "Tokyo"
sw = py5.text_width(s)
py5.text(s, 0, 85)
py5.line(sw, 50, sw, 100)
|
Description¶
Calculates and returns the width of any character or text string.
Underlying Processing method: textWidth
Syntax¶
text_width(c: chr, /) -> float
text_width(chars: list[chr], start: int, length: int, /) -> float
text_width(str: str, /) -> float
Parameters¶
c: chr - the character to measure
chars: list[chr] - the character to measure
length: int - number of characters to measure
start: int - first character to measure
str: str - the String of characters to measure
Updated on March 01, 2022 12:15:01pm UTC