ASCII objects
Multiple objects can be defined:
Banner
: This is a specially formatted text, e.g. for displaying the name of a tool in a nice fashion.Cowsay
: This wraps the text into an ASCII art using a cowsay character.Image
: This allows to represent a JPG/PNG image as a text.Quote
: This allows to format a quote as an italic text framed by double quotes and showing the name of its author.
Banner
¶
This object has the following options:
text
(string ; required): text to be displayedwidth
(integer ; default is the terminal size): desired width in charactersfont
(string ; default isNone
, meaning a randomly chosen font): name of a custom font ; the available font names are stored infonts.txt
, provide with the packagemultiline
(boolean ; defaults toFalse
): whether the output should be accepted even if the text is generated on multiple linesautofont
(boolean ; defaults toTrue
): automatically choose a replacement font ifmultiline
isFalse
and the output has multiple lines
The following example shows attributes and methods' outputs as it appears using Idle-Python:
>>> from asciistuff import Banner
>>> b = Banner("MyText")
>>> b.font
'xcour'
>>> print(b)
#
# # ##### #
## ## ## ## # # # ## ## ## ####
# # # # # # # # # # #
# # # # # # ### # #
# # # # # # # # # #
## ## ## ### ### ## ## ##
#
##
>>> b.rebrand()
>>> print(b)
^ ^ ^ ^ ^ ^
/M\ /y\ /T\ /e\ /x\ /t\
<___><___><___><___><___><___>
>>> Banner.font_exists("does_not_exist")
False
>>> Banner.font_exists("xcour")
True
>>> b.font = "stacey"
>>> b.font = "does_not_exist"
Traceback (most recent call last):
[...]
ValueError: Bad font name
>>>
Available fonts
The list of fonts with examples can be found here.
Cowsay
¶
This object has the following options:
text
(string ; required): text to be displayedwidth
(integer ; default is the terminal size): desired width in characterscowacter
(string ; defaults to "default
"): the Cowsay character to be usedoptions
(dictionary): parameters for setting the CowPy object selected usingcowacter
For a complete list of cowacter and option values, please refer to CowPy's documentation.
The following example shows attributes and methods' outputs as it appears using Idle-Python:
>>> from asciistuff import Cowsay
>>> c = Cowsay("MyText")
>>> c
________
< MyText >
--------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
>>> c.cowacter = "ghostbusters"
>>> c
________
< MyText >
--------
\
\
\ __---__
_- /--______
__--( / \ )XXXXXXXXXXX\v.
.-XXX( O O )XXXXXXXXXXXXXXX-
/XXX( U ) XXXXXXX\
/XXXXX( )--_ XXXXXXXXXXX\
/XXXXX/ ( O ) XXXXXX \XXXXX\
XXXXX/ / XXXXXX \__ \XXXXX
XXXXXX__/ XXXXXX \__---->
---___ XXX__/ XXXXXX \__ /
\- --__/ ___/\ XXXXXX / ___--/=
\-\ ___/ XXXXXX '--- XXXXXX
\-\/XXX\ XXXXXX /XXXXX
\XXXXXXXXX \ /XXXXX/
\XXXXXX > _/XXXXX/
\XXXXX--__/ __-- XXXX/
-XXXXXXXX--------------- XXXXXX-
\XXXXXXXXXXXXXXXXXXXXXXXXXX/
""VXXXXXXXXXXXXXXXXXXV""
>>> c.cowacter = "bunny"
>>> c.options['thoughts'] = True
>>> c
________
< MyText >
--------
o
o \
\ /\
( )
.( o ).
Image
¶
This object has the following options:
path
(string ; required): path to the imagewidth
(integer ; default is the terminal size): desired width in charactersfont
(string ; defaults toNone
, meaningImageFont.load_default()
): name of a custom font to be considered for rendering the ASCII imagebrightness
(float<=1
; defaults to1.0
): image's brightness, used to setup original image usingImageEnhance.Brightness
contrast
(float<=1
; defaults to1.0
): image's contrast, used to setup original image usingImageEnhance.Contrast
charset
(string ; defaults to '.,*@%#/(
'): character set for the ASCII art (will be sorted and used by pixel density)
The following example shows attributes and methods' outputs as it appears using Idle-Python:
>>> from asciistuff import Image
>>> i = Image("hello.png")
>>> i
@@@@@@@@@@@@@@@@@@@@@@@ / @@@@@@@@@%*,,,,,,,*#@@@@@@@@@ *@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@ @@@@@@/,. ../#@@@@@@ @@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@ @@@@#,. .,/**(%%%####%%((/,. .,*@@@ @@@@@@@@@@@@@
@@@@@@@@@@@@@@@ @@@,. .,*%%###%(**//,,,,,/**(%####%(*, ,%@@ @@@@@@@@@@@@
@@@@@@@@@@@@@ @@/. ./(###%*,.. .,/(%##%/ .#@ @@@@@@@@@@@
@@@@@@@@@@@@/@@,. .(##%*,. ,*##* .,@@@@@@@@@@@@
@@@@@@@@@@@ @(. ,%@#/. *@#, .@@ @@@@@@@@
@@@@@@@@@@ @,. (@%, .%@* .@ @@@@@@@
@@@@@@@@@ @, ,#@* .%/ *@( ,@ @@@@@@@
@@@@@@@@ @. *@%. .#( ,@( *@* ,@ @@@@@@
@@@@@@@ @, *@% .. .@% .@( %@, *@ @@@@@
@@@@@@ @/ /@% %# %# .@% ,((*. .##. .@ @@@@@
@@@@@@ @. .@#. *@, *@. #% *@%*%@( (@, .@ @@@@@
@@@@@ @/ (@/ .@( /##%, /@, %# *@/ *@* *@. .@ @@@@@
@@@@@ @. .@# %@(###*. (#/.(@/ ,@/ (@. %# .@% (@, .@ @@@@@
@@@@ @@. /@* *@%,./@#. (@//*%@@, .@* /@, %# *@/ %@. ,@ @@@@@
@@@@ @@. *@* /@/ .@% ,@#%%*/.. @% ,@* /@(.,%@( ## ,@ @@@@@
@@@@ @@. /@* .@( (@./@/ ## .@% /###%, /@* (@ @@@@@
@@@@@ @. ,@% @% ,@*/@/ %@. #@. .##. .@ @@@@@@
@@@@@ @, .##. ## .@% %@((%#%, *@/ ,*. .#@, .*@ @@@@@@
@@@@@ @* /@( #@. ## ,*(*,. ,@% /@#, ,@ @@@@@@@
@@@@@@ @, %@, ,/ (@. ** ,#@( .,@ @@@@@@@@
@@@@@@ %. .##, /#/ /%@(. .(@ @@@@@@@@@
@@@@@@@ @/ .%@* . ,(#@(. ./@@ @@@@@@@@@@
@@@@@@@@ @/. /##* ./(##(, ./@@ @@@@@@@@@@@
[...]
>>> i.charset
'@#%(*/,. '
>>> i.charset = "@#¼½^([()\\"
>>> i
@@@@@@@@@@@@@@@@@@@@@@@^(^^^@@@@@@@@@½¼)))))))¼#@@@@@@@@@^^^¼@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@^^^^@@@@@@()\^^^^^^^^^^^^^^^^^^^^\\(#@@@@@@^^@@@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(^^^[@\^^½#^^^^\@½^^^^^^^[@)^\@^@@@@@
@@@@^@@\^(@¼^^^^^^^¼@½)\(@#\^^[@((¼½@@)^\@¼^^^(@)^^½#^^^^¼@(^^^^^^^½@\^)@^@@@@@
@@@@^@@\^¼@¼^^^^^^^(@(^^^\@½^)@#½½¼(\\^^^@½^^^)@¼^^(@[\)½@[^^^^^^^^##^^)@^@@@@@
@@@@^@@\^(@¼^^^^^^^\@[^^^^[@\(@(^^^^^^^^^##^^^\@½^^^(###½)^^^^^^^^(@¼^^[@^@@@@@
@@@@@^@\^)@½^^^^^^^^@½^^^^)@¼(@(^^^^^^^^^½@\^^^#@\^^^^^^^^^^^^^^^\##\^\@^@@@@@@
[...]
>>> i.contrast = .5
>>> i
@@@@@@@@@@@@@@@@@@@@@@@^()^^@@@@@@@@@[¼¼¼¼¼¼¼¼¼½@@@@@@@@@^^(¼@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@^(^@@@@@#¼((()))))))))))))))))))((¼½@@@@@@(@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@¼^@@@@½¼(()))))((¼¼[[[½½½½½½½[[[¼(())))))((¼@@@(@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@¼^@@#¼())))((¼[½½½½[[[¼¼¼((((¼¼¼¼[½½½½½[[¼()))((½@@^@@@@@@@@@@@@
@@@@@@@@@@@@@^^@@¼()))(¼[½½½[¼¼(())))))))))))))))))((¼¼[[½½½¼)))(½@(@@@@@@@@@@@
@@@@@@@@@@@@(@@¼())([½½½[(()))))))))))))))))))))))))))))))([½½¼))(¼@@@@@@@@@@@@
@@@@@@@@@@@(@[())([#½¼()))))))))))))))))))))))))))))))))))))(¼½½())(@@@@@@@@@@@
@@@@@@@@@@^@¼())[#½¼))))))))))))))))))))))))))))))))))))))))))([#¼))(@^@@@@@@@@
@@@@@@@@@^@())(½#¼))))))))))))))))))))))(()))([¼))))))))))))))))[#[))(@(@@@@@@@
@@@@@@@@^@())¼#½())))))))))))))))))))))(½[)))(#[)))))))))))))))))[#¼))¼@^@@@@@@
@@@@@@@¼@())¼#[))((()))))))))))))))))))(½[)))(½[))))))))))))))))))[#()(¼@^@@@@@
@@@@@@^@¼))¼#[))))½½()))))))))))))))))))½½())(½[)))))([[¼())))))))(½½()(@^@@@@@
@@@@@@^@()(#½())))¼#¼)))))))))))))()))))[½()))½½))))¼#[¼[½[))))))))[#()(@^@@@@@
@@@@@^@¼))[#¼)()))(#[))())))))))¼½½½()))¼#()))½½())¼#¼)))¼#¼)))))))[#()(@^@@@@@
@@@@@^@()(#½)))))))½½[½½½[())))[½¼([½¼))(#¼)()[½())½½))()(½[)))))))[#()(@^@@@@@
@@@@@@½()¼#¼)))))))[#[((¼½½())[#¼¼¼[½½()(#¼)()¼#())[½))))[#¼)))))))[½()(@^@@@@@
@@@@@@½()¼#¼)))))))¼#¼)))(#[)(#½½[[¼(())(½[)()(#¼))¼#[(([#[))))))))½½))¼@^@@@@@
@@@@@@#()¼#[)))))))(#[))()[#(¼#¼)))))))))½½)))(½[)))¼½½½[())))))()¼#¼)([@^@@@@@
@@@@@^@()(#[)))))))(½[))))¼#¼¼#¼)))(())))[½()))½#())))())))))))()(½½()(@^@@@@@@
@@@@@^@()(½½()))))))½½))))(½[)[#[[[½½()()¼#¼)()¼¼())))))))))))))(½#¼)([@^@@@@@@
[...]
Lolcat
¶
This object has the following options:
mode
(8
,16
or256
; default is256
): color mode to be usedspread
(positive float ; default is3.
): rainbow spread factorfreq
(positive float ; default is.1
): rainbow colors frequencyseed
(integer ; default is0
): seed for color randomization
The following example shows attributes and methods' outputs as it appears using a terminal:
Quote
¶
This object has the following options:
quote
(string ; required): quote to be displayedsource
(string ; default to 'unknown
'): quote's source/authorwidth
(integer ; default is the terminal size): desired text width in charactersmargin
(float ; defaults to.1
): value (belongs to [0, .5[) for symmetrical left/right marginscowsay
(string ; defaults toNone
, meaning no cowsay): cowsay character (cowacter) to be considered
The following example shows attributes and methods' outputs as it appears using Idle-Python (note that, using Idle, text does not appear as italic):
>>> from asciistuff import Quote
>>> q = Quote("A nice quote", "John Doe")
>>> q
"A nice quote",
John Doe
>>> q = Quote("A nice quote", "John Doe", cowsay="random")
>>> q
_________________
/ "A nice quote", \
\ John Doe /
-----------------
\
\ (__)
(\/)
/-------\/
/ | 666 ||
* ||----||
~~ ~~
>>> q
_________________
/ "A nice quote", \
\ John Doe /
-----------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||