tx.word()
Syntax
word(string)
Description
The word() command is called by Tx itself, each time paragraph() draws a word. By default, the word() command is sleeping, it doesn't do anything. However, you could assign your own custom command to it, one that sets different font colors and sizes depending on what string contains, for example.
Example
Below is the same example as the paragraph() example, except that a custom word() command has been assigned to the Tx word() command. This custom command checks if a word in the paragraph is normal, and if so, replaces it with normal(?) and drawing it in red instead of white.
font("Dolly-Bold", 11)
import tx
string = "A very normal looking paragraph... on the surface..."
def word(string):
if string == "normal":
fill(1,0.25,0)
return "normal(?)"
else:
fill(0)
tx.word = word
tx.paragraph(string, 20, 30, 150)