- Getting Started
- Tutorials
- Command Reference
- 2D Graphics
- 3D Graphics
- Arithmetic
- Binary
- File Handling
- Input
- Screen Display
- Sound and Music
- Text Handling
- Time and Date
- Keywords
- Operators
- Arithmetic
- Bitwise
- Comparison
textWidth()
Purpose
Find the width in pixels of a string
Description
Receives a single string argument, returns the width (in pixels) of the given string
Syntax
result = textWidth( text )
Arguments
text text to find the size of
result width of the text at the current textSize
Example
message = "Hello World"
for size = 1 to 200 step 1 loop
clear()
textSize( size )
tw = textWidth( message )
drawText( ( gWidth() - tw ) / 2, ( gHeight() - size ) / 2, size, white, message )
update()
repeat
Associated Commands
cursor(), drawText(), ink(), len(), print(), printAt(), stringHash(), textSize(), tHeight(), tWidth()