# NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

# tx.character()

## Syntax

    character(char)

## Description

The character() command is called by Tx itself, each time paragraph() draws a character. By default, the character() 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 char contains, for example.

You can attain interesting results when using for example nudge() and shiver() inside the character() command as well.

## Example

Below is the same example as the paragraph() example, except that a custom character() command has been assigned to the Tx character() command. This custom command sets a random font for each character.

    font("Dolly-Bold", 11)
    import tx
    string = "A very normal looking paragraph... on the surface..."

    def character(char):
        fonts = ["Dolly-Bold", "Dolly-Roman"]
        font(choice(fonts))

    tx.character = character
    tx.paragraph(string, 20, 30, 150)