Table of contents
The BounceFX module allows printing a string with a bouncing effect from left to right.
You can find more text printing effects here.
The given string is printed on the left of the current line, moving to the right side column by column until the string reaches the end of the line. The length of the line can either be a given value (e.g. 80 characters) or automatically determined (depending on the terminal size). Then, the string bounces and moves left column by column again.
First of all, the module must be imported.
import bouncefx
Notice that the delay must be given in milliseconds.
The method requires four arguments:
string
- The string that should be bounced in the line.
line_length
- The length in characters that should be used for bouncing. Setting this to
0
will automatically determine the length (columns) of the terminal line.
- The length in characters that should be used for bouncing. Setting this to
delay
- The delay between moving the string left or right.
bounces
- The number of bounces that should be done. Setting this to
0
results in unlimited bounces.
- The number of bounces that should be done. Setting this to
bouncefx.bounce_line(string, line_length=80, delay=0.1, bounces=3)
The following code
import bouncefx
bouncefx.bounce_line("This is an example.", line_length=38, delay=0.1, bounces=0)
produces this output:
In order to use BounceFX, the Python 3.x framework (version 3.2 or higher is recommended) must be installed on the system.
There is no official version for Python 2.x, but if you need that for whatever reason, you can try refactoring the syntax from Python 3.x to version 2.x using the 3to2 tool.
However, there is no guarantee that this works properly or at all.
Any suggestions, questions, bugs to report or feedback to give?
You can contact me by sending an email to dev@urbanware.org or by opening a GitHub issue (which I would prefer if you have a GitHub account).
- The project name is an abbreviation for Bounce Effects.