text_width()#
Calculates and returns the width of any character or text string.
Examples#
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
Signatures#
text_width(
c: chr, # the character to measure
/,
) -> float
text_width(
chars: list[chr], # the character to measure
start: int, # first character to measure
length: int, # number of characters to measure
/,
) -> float
text_width(
str: str, # the String of characters to measure
/,
) -> float
Updated on March 06, 2023 02:49:26am UTC