### Import art module in Python Source: https://github.com/sepandhaghighi/art/blob/master/ArtList.ipynb Imports all functions, classes, and constants from the art library, enabling access to ASCII art features. This snippet requires the art package to be installed via pip. No inputs are needed, and it sets up the environment for subsequent art operations. ```python from art import * ``` -------------------------------- ### ART Command Line Interface Usage Source: https://context7.com/sepandhaghighi/art/llms.txt Comprehensive guide to using ART library through command-line interface for quick ASCII art generation, font listing, art selection, and file operations. ```bash # Display help information art # List all available arts art list art arts # List all available fonts art fonts # Convert text to ASCII art with default font art text "Hello World" # Convert text with specific font art text "Python" block # Save ASCII art to file art save "Output" italic # Display one-line art art shape butterfly art art coffee # Generate all fonts for given text art all "Test" # Creates ARTFonts directory with all fonts in a ZIP file # Run tests art test art test2 ``` -------------------------------- ### List Decorations in Python Source: https://github.com/sepandhaghighi/art/blob/master/DecorList.ipynb This snippet demonstrates how to list all available decorations in the 'art' library. The function decor_list() returns a formatted list of decoration names and examples. ```python decor_list() ``` -------------------------------- ### Python ART Decor Function Examples Source: https://github.com/sepandhaghighi/art/blob/master/README.md The decor function in the ART library generates decorative ASCII strings for text art compositions. It accepts a decoration name as a string and optional flags like reverse or both, returning strings or lists; dependencies include the art library. Outputs vary from single decorated strings to paired lists, raising artError for invalid inputs like None. ```python >>> decor("barcode1") '▌│█║▌║▌║ ' >>> decor("barcode1",reverse=True) ' ║▌║▌║█│▌' >>> decor("barcode1") + text2art(" art ",font="fancy42") + decor("barcode1",reverse=True) '▌│█║▌║▌║ ąяţ ║▌║▌║█│▌' >>> decor("barcode1",both=True) ['▌│█║▌║▌║ ', ' ║▌║▌║█│▌'] >>> decor("random",both=True) ['「(◔ω◔「)三', '三三三ʅ(;◔౪◔)ʃ'] >>> decor("rand",both=True) ['‹–…·´`·…–›', '‹–…·´`·…–›'] >>> decor(None) Traceback (most recent call last): ... art.art.artError: The 'decoration' type must be str. ``` -------------------------------- ### List ASCII arts in Python Source: https://github.com/sepandhaghighi/art/blob/master/ArtList.ipynb Calls the art_list() function to print a formatted list of all available ASCII arts, including their indices and visual representations. This helps users explore the art collection. Outputs to the console; no inputs needed, but the art library must be imported first. ```python art_list() ``` -------------------------------- ### Demonstrating typo-tolerance in ART (Python) Source: https://github.com/sepandhaghighi/art/blob/master/README.md This code snippet demonstrates the typo-tolerance feature in the ART library using Python console examples. It shows how functions like aprint, art, text2art, and tprint handle typos in art names or font names by correcting them if the Levenshtein distance is less than half the name length. If the error is too large, it raises an artError exception. ```python >>> aprint("happi") # correct --> aprint("happy"), error < |artname|/2 ۜ\(סּںסּَ` )/ۜ >>> Art=art("birds2222222",number=1) # correct --> Art=art("birds",number=1), error >= |artname|/2 Traceback (most recent call last): ... art.art.artError: Invalid art name. >>> aprint("happi231") # correct --> aprint("happy"), error < |artname|/2 ⎦˚◡˚⎣ >>> aprint("happi2312344") # correct --> aprint("happy"), error >= |artname|/2 Traceback (most recent call last): ... art.art.artError: Invalid art name. >>> Art=text2art("test",font="black") # correct --> Art=text2art("test",font="block") >>> print(Art) .----------------. .----------------. .----------------. .----------------. | .--------------. || .--------------. || .--------------. || .--------------. | | | _________ | || | _________ | || | _______ | || | _________ | | | | | _ _ | | || | |_ ___ | | || | / ___ | | || | |_/ | | \_| | | | | |_/ | | \_| | || | | |_ \_| | || | | (__ \_| | || | | | | | | | | | | || | | _| _ | || | '.___`-. | || | _| |_ | | | | _| |_ | || | _| |___/ | | || | |`\____) | | || | |_____| | | | | |_____| | || | |_________| | || | | || | | | | | | || | | || '--------------' || '--------------' | | '--------------' || '--------------' || '--------------' || '--------------' | '----------------' '----------------' '----------------' '----------------' >>> tprint("test",font="cybermedum") # correct --> tprint("test",font="cybermedium") ___ ____ ____ ___ | |___ [__ | | |___ ___] | ``` -------------------------------- ### Get font count in Python Source: https://github.com/sepandhaghighi/art/blob/master/FontList.ipynb Access the FONT_COUNTER constant to get the total number of available fonts in the art library. The example shows there are 677 fonts available. ```python FONT_COUNTER ``` -------------------------------- ### Python ART tprint Random Small Font Example Source: https://github.com/sepandhaghighi/art/blob/master/README.md Using 'rnd-small' or similar keywords, tprint selects randomly from small-sized fonts for ASCII art generation. Dependent on the art library, it inputs text and font mode, producing compact multiline outputs. Feature available since version 2.8, with limitation on font size variety. ```python >>> tprint("test",font="rnd-small") _/ _ _ _/ / (- _) / ``` -------------------------------- ### Setting default values in ART library (Python) Source: https://github.com/sepandhaghighi/art/blob/master/README.md This code shows how to use the set_default function in the ART library to change default parameters for text2art, tprint, and tsave. The function takes parameters like font, chr_ignore, filename, etc., and returns None. Examples demonstrate printing 'test' before and after setting the default font to 'italic', showing different ASCII outputs. ```python >>> help(set_default) Help on function set_default in module art.art: set_default(font='standard', chr_ignore=True, filename='art', print_status=True, overwrite=False, decoration=None, sep='\n') Change text2art, tprint and tsave default values. :param font: input font :type font:str :param chr_ignore: ignore not supported character :type chr_ignore:bool :param filename: output file name (only tsave) :type filename:str :param print_status : save message print flag (only tsave) :type print_status:bool :param overwrite : overwrite the saved file if true (only tsave) :type overwrite:bool :param decoration: input decoration :type decoration:str :param sep: line separator char :type sep: str :return: None >>> tprint("test") _ _ | |_ ___ ___ | |_ | __| / _ \/ __|| __| | |_ | __/\__ \| |_ \__| \___||___/ \__| >>> set_default(font="italic") >>> tprint("test") _/ _ _ _/ / (- _) / ``` -------------------------------- ### List ASCII fonts for text in Python Source: https://github.com/sepandhaghighi/art/blob/master/FontList.ipynb The font_list function displays available ASCII font styles for given text. The example shows the output for 'TEST123' in ASCII fonts, with some fonts potentially not supporting all characters. ```python font_list("TEST123","ascii") ``` -------------------------------- ### Get Decoration Count in Python Source: https://github.com/sepandhaghighi/art/blob/master/DecorList.ipynb This snippet shows how to access the total number of available decorations in the 'art' library. The count is stored in the variable DECORATION_COUNTER. ```python DECORATION_COUNTER ``` -------------------------------- ### Python ART tprint Random Medium Font Example Source: https://github.com/sepandhaghighi/art/blob/master/README.md The tprint function with 'rnd-medium' mode randomly chooses from medium-sized fonts to create ASCII art. Requires art library, accepts text input with font specifier, outputs moderately sized designs. Introduced in version 2.8, limited to medium font range. ```python >>> tprint("test",font="rnd-medium") , , || || =||= _-_ _-_, =||= || || \\ ||_. || || ||/ ~ || || \\, \\,/ ,-_- \\, ``` -------------------------------- ### Python ART tprint Random Font Example Source: https://github.com/sepandhaghighi/art/blob/master/README.md The tprint function with 'random' font mode randomly selects from all available fonts to print ASCII art text. It requires the art library, taking text as input and outputting varied multiline art. Limitations include unpredictable output that may not suit all contexts or character sets. ```python >>> tprint("test",font="random") | | ~|~/~/(~~|~ | \/__) | ``` -------------------------------- ### Access art counter in Python Source: https://github.com/sepandhaghighi/art/blob/master/ArtList.ipynb Retrieves the ART_COUNTER constant, which represents the total number of available ASCII arts in the library. Useful for displaying or using the count programmatically. Outputs an integer value; no inputs required, and it's limited to the predefined arts in the library. ```python ART_COUNTER ``` -------------------------------- ### Python ART tprint Random Large Font Example Source: https://github.com/sepandhaghighi/art/blob/master/README.md With 'rnd-large' keywords, tprint randomly picks from large fonts for expansive ASCII art output. Depends on art library since version 2.8, taking text and mode parameters for large, detailed prints. Outputs can be very wide, with potential space limitations in displays. ```python >>> tprint("test",font="rnd-large") 8888888 8888888888 8 8888888888 d888888o. 8888888 8888888888 8 8888 8 8888 .`8888:' `88. 8 8888 8 8888 8 8888 8.`8888. Y8 8 8888 8 8888 8 8888 `8.`8888. 8 8888 8 8888 8 888888888888 `8.`8888. 8 8888 8 8888 8 8888 `8.`8888. 8 8888 8 8888 8 8888 `8.`8888. 8 8888 8 8888 8 8888 8b `8.`8888. 8 8888 8 8888 8 8888 `8b. ;8.`8888 8 8888 8 8888 8 888888888888 `Y8888P ,88P' 8 8888 ``` -------------------------------- ### Python ART tprint Font Name Example Source: https://github.com/sepandhaghighi/art/blob/master/README.md The tprint function prints ASCII art text using specified font names, with options like chr_ignore for unsupported characters. It depends on the art library, taking text and font parameters, outputting multiline ASCII art directly to console. Limitations include font incompatibility with certain characters, requiring careful selection. ```python >>> tprint("art",font="block",chr_ignore=True) .----------------. .----------------. .----------------. | .--------------. || .--------------. || .--------------. | | | __ | || | _______ | || | _________ | | | | / \ | || | |_ __ \ | || | | _ _ | | | | | / /\ \ | || | | |__) | | || | |_/ | | \_| | | | | / ____ \ | || | | __ / | || | | | | | | | _/ / \ \_ | || | _| | \ \_ | || | _| |_ | | | ||____| |____|| || | |____| |___| | || | |_____| | | | | | || | | || | | | | '--------------' || '--------------' || '--------------' | '----------------' '----------------' '----------------' >>> tprint("art","white_bubble") ⓐⓡⓣ ``` -------------------------------- ### List All Decorations with Preview Source: https://context7.com/sepandhaghighi/art/llms.txt Shows how to preview all available decorations with sample text using decor_list function. Supports custom text and font parameters for enhanced preview customization. ```python from art import decor_list # Show all decorations with default text decor_list() # Each decoration will be shown wrapping the text "test" # Custom text and font for preview decor_list(text="Demo", font="italic") ``` -------------------------------- ### Execute Python ART 1-Line Art using art library Source: https://github.com/sepandhaghighi/art/blob/master/README.md Demonstrates generating 1-line ASCII art using the art function from the ART Python library. The snippet shows typical REPL-style interactions, including assignments, printing results, and handling of various inputs. Dependencies: art package; inputs: art names and optional parameters; outputs: strings containing ASCII art. ```python from art import * art_1=art('coffee') # return art as str in normal mode print(art_1) art_2=art('woman',number=2) # return multiple art as str print(art_2) art('coffee', number=3, space=5) art('random') # random 1-line art mode art('rand') # random 1-line art mode art(22,number=1) # raise artError ``` -------------------------------- ### List All Fonts with Preview Text Source: https://context7.com/sepandhaghighi/art/llms.txt Shows how to preview all available fonts with sample text rendering using the font_list function. Supports different modes for ASCII and Non-ASCII fonts, and allows custom preview text. ```python from art import font_list # Preview all fonts font_list(text="Test") # This will print each font name followed by the text "Test" rendered in that font # Preview only ASCII fonts (safe for all environments) font_list(text="Hello", mode="ascii") # Preview only Non-ASCII fonts font_list(text="Cool", mode="non-ascii") # Use custom test text font_list(text="ABC123") ``` -------------------------------- ### Running ART library tests (Shell) Source: https://github.com/sepandhaghighi/art/blob/master/README.md Commands to run tests on the ART library in shell. 'art test' performs tests only on ASCII fonts and arts, while 'art test2' tests all available fonts, arts, and decorations. These ensure the library functions correctly. ```shell art test art test2 ``` -------------------------------- ### List All Arts with Preview Source: https://context7.com/sepandhaghighi/art/llms.txt Demonstrates the art_list function to preview all available one-line arts. Supports filtering by ASCII and Non-ASCII modes for different environments and use cases. ```python from art import art_list # Show all arts art_list() # This will print each art name followed by its visual representation # Show only ASCII arts art_list(mode="ascii") # Show only Non-ASCII arts art_list(mode="non-ascii") ``` -------------------------------- ### Check Font Counters and Font Availability Source: https://context7.com/sepandhaghighi/art/llms.txt Demonstrates usage of font counters to track available fonts, arts, and decorations in the ART library. Shows how to check if specific fonts exist using membership testing. ```python # Use counters print(f"Font counter: {FONT_COUNTER}") print(f"Art counter: {ART_COUNTER}") print(f"Decoration counter: {DECORATION_COUNTER}") # Check if specific font exists if "block" in FONT_NAMES: print("Block font is available!") ``` -------------------------------- ### Access Font and Art Collections Python Source: https://context7.com/sepandhaghighi/art/llms.txt Exposes library metadata including available fonts, arts, and decorations through module-level variables. Separates ASCII and non-ASCII content for environment compatibility. Provides counters for library size tracking. Useful for exploration and selection of available options. ```python from art import FONT_NAMES, ART_NAMES, DECORATION_NAMES from art import ASCII_FONTS, NON_ASCII_FONTS, ASCII_ARTS, NON_ASCII_ARTS from art import FONT_COUNTER, ART_COUNTER, DECORATION_COUNTER # Get all available fonts print(f"Total fonts: {len(FONT_NAMES)}") print(f"First 5 fonts: {FONT_NAMES[:5]}") # ['1943', '1row', '3-d', '3d_diagonal', '3x5'] # Get ASCII-only fonts (safe for all environments) print(f"ASCII fonts: {len(ASCII_FONTS)}") # Get all available arts print(f"Total arts: {len(ART_NAMES)}") print(f"Sample arts: {ART_NAMES[:5]}") # ['3', '5', '9/11 truth', 'acid', 'afraid'] # Get all decorations print(f"Total decorations: {len(DECORATION_NAMES)}") print(f"Sample decorations: {DECORATION_NAMES[:5]}") # ['angry1', 'arrow1', 'arrow2', 'arrow3', 'arrow4'] ``` -------------------------------- ### Generate Decorative Elements Python Source: https://context7.com/sepandhaghighi/art/llms.txt Creates decorative borders and wrappers using decor() function for enhancing text and art presentations. Supports left/right sides, both sides mode, and custom decoration patterns. Can combine with text2art for complete decorative text. Includes random decoration mode. ```python from art import decor, text2art # Get left side of decoration left_decor = decor("barcode1") print(left_decor) # ▌│█║▌║▌║ # Get right side of decoration right_decor = decor("barcode1", reverse=True) print(right_decor) # ║▌║▌║█│▌ # Get both sides as list both_decor = decor("heart1", both=True) print(both_decor) # ['♥╣[-_-]╠♥', '♥╣[-_-]╠♥'] # Manual decoration wrapping text = text2art("LOVE", font="fancy42") decorated = decor("heart1") + text + decor("heart1", reverse=True) print(decorated) # ♥╣[-_-]╠♥ ᏝᎧᏉᏋ ♥╣[-_-]╠♥ # Random decoration mode random_decor = decor("random", both=True) print(random_decor) # ['「(◔ω◔「)三', '三三三ʅ(;◔౪◔)ʃ'] ``` -------------------------------- ### Error Handling and Exception Management Source: https://context7.com/sepandhaghighi/art/llms.txt Demonstrates comprehensive error handling patterns using artError exceptions. Covers invalid art names, character validation, type checking, Unicode environment issues, and safe mode operation. ```python from art import art, text2art, tprint, artError # Handle invalid art name try: result = art("nonexistentart12345678") except artError as e: print(f"Error: {e}") # Error: Invalid art name. # Handle invalid character in text try: result = text2art("test سس", chr_ignore=False) except artError as e: print(f"Error: {e}") # Error: س is invalid. # Handle type errors try: result = art(123) except artError as e: print(f"Error: {e}") # Error: The 'artname' type must be str. # Handle Unicode environment issues gracefully try: tprint("test", font="fancy42") # Non-ASCII font except UnicodeEncodeError: print("Font not supported in this environment") # Safe mode with character ignore enabled (default) result = text2art("test سس", chr_ignore=True) print(result) # Non-supported characters are silently ignored ``` -------------------------------- ### Generate One-Line Art Python Source: https://context7.com/sepandhaghighi/art/llms.txt Creates single-line ASCII art strings with support for repetition and custom spacing. Uses art() function with optional number and space parameters. Handles typos automatically and provides random art selection. Returns formatted strings that can be stored or printed. ```python from art import art, aprint, randart # Basic one-line art coffee = art("coffee") print(coffee) # c[_] # Repeat art multiple times coffee_multiple = art("coffee", number=3) print(coffee_multiple) # c[_] c[_] c[_] # Custom spacing between repeats butterfly = art("butterfly", number=2, space=5) print(butterfly) # Ƹ̵̡Ӝ̵̨̄Ʒ Ƹ̵̡Ӝ̵̨̄Ʒ # Random art selection random_art = art("random") print(random_art) # (っ◕‿◕)っ # Error handling with typo-tolerance happy_art = art("happi") # Typo will be auto-corrected to "happy" print(happy_art) # ۜ\(סּںסּَ` )/ۜ ``` -------------------------------- ### Print One-Line Art Directly Python Source: https://context7.com/sepandhaghighi/art/llms.txt Prints ASCII art directly to console using aprint() function with automatic Unicode handling. Supports multiple repetitions and spacing options. Environment-aware for different terminal configurations. Uses 'random' or 'rand' keywords for random art selection. ```python from art import aprint # Print basic art aprint("butterfly") # Ƹ̵̡Ӝ̵̨̄Ʒ # Print multiple times with spacing aprint("heart", number=5, space=2) # ♥ ♥ ♥ ♥ ♥ # Print random art aprint("random") # (◕‿◕) aprint("rand") # Alternative keyword for random # ¯\_(ツ)_/¯ ``` -------------------------------- ### tsave: Save ASCII Art to File in Python Source: https://github.com/sepandhaghighi/art/blob/master/README.md The tsave function generates ASCII art from text and saves it to a specified file, returning a dictionary with status and message. It supports options like overwrite, decoration, separator, space, and print status; inputs include text, filename, font; outputs are file and dict; limitations involve file permissions and input type errors. ```python >>> Response=tsave("art",filename="test.txt") # save ASCII text in test.txt file with save message (print_status==True), return dict Saved! Filename: test.txt >>> Response["Message"] 'OK' ``` ```python >>> Response=tsave("art",filename="test.txt",print_status=False) # save ASCII text in test.txt file without save message (print_status==False) >>> Response["Message"] 'OK' >>> Response["Status"] True ``` ```python >>> tsave(22,font=DEFAULT_FONT,filename="art",chr_ignore=True,print_status=True) {'Status': False, 'Message': "'int' object has no attribute 'split'"} ``` ```python >>> Response=tsave("art",filename="test.txt",overwrite=True) # overwrite parameter is added in Version 4.0 Saved! Filename: test.txt ``` ```python >>> Response=tsave("art",filename="test.txt",decoration="barcode1") # decoration parameter is added in Version 4.6 Saved! Filename: test.txt ``` ```python >>> Response=tsave("art",filename="test.txt",sep="\r\n") # sep parameter is added in Version 5.3 Saved! Filename: test.txt ``` ```python >>> Response=tsave("art",filename="test.txt",space=5) # space parameter is added in Version 6.0 Saved! Filename: test.txt ``` -------------------------------- ### Generate Random Art (Python) Source: https://github.com/sepandhaghighi/art/blob/master/README.md Shortcut function added in Version 2.2 as art("random") alternative. Generates and returns random 1-line art strings without printing them. Each call produces different artistic output. ```python >>> randart() 'ዞᏜ℘℘Ꮍ ℬℹℛʈዞᗬᏜᎽ ' >>> randart() '✌(◕‿-)✌ ' ``` -------------------------------- ### Configure Default Settings Python Source: https://context7.com/sepandhaghighi/art/llms.txt Modifies global default parameters for art generation functions using set_default(). Affects text2art, tprint, and tsave functions. Supports font, decoration, filename, and formatting options. Useful for standardizing output across multiple function calls. ```python from art import set_default, tprint, tsave # View current defaults tprint("Default") # ____ __ _ _ # | _ \ ___ / _| __ _ _ _ | | | |_ # | | | | / _ \ | |_ / _` || | | || | | __| # | |_| | | __/ | _|| (_| || |_| || | | |_ # |____/ \___| |_| \__,_| \__,_||_| \__| # Change default font set_default(font="italic") tprint("Italic") # ___ _ _ _ # |_ _|| |_ __ _| |(_) ___ # | | | __| / _` | || |/ __| # | | | |_ | (_| | || || (__ # |___| \__| \__,_|_||_| \___| # Change multiple defaults set_default( font="block", chr_ignore=True, decoration="star1", filename="default_output", print_status=True, overwrite=False, sep="\n", space=0 ) # Now all subsequent calls use new defaults tprint("Custom") tsave("Test") # Will use "default_output" as filename ``` -------------------------------- ### Wizard mode for font selection in Python Source: https://github.com/sepandhaghighi/art/blob/master/README.md Wizard mode selects fonts based on the length of the input text, supporting 95 ASCII characters. Keywords include 'wizard', 'wiz', and 'magic'. Introduced in Version 2.9. ```python >>> tprint("1","wizard") ``` ```python >>> tprint("1"*5,"wizard") ``` ```python >>> tprint("1"*15,"wizard") ``` -------------------------------- ### Convert Text to ASCII Art (Python) Source: https://github.com/sepandhaghighi/art/blob/master/README.md Core function that converts text to ASCII art with extensive customization options. Supports multiple fonts (including Non-ASCII fonts from Version 3.3), random font selection, custom spacing, multi-line text, and decorative elements. Defaults to chr_ignore=True for character filtering and uses newline separators from Version 5.3. ```python >>> Art=text2art("art") # Return ASCII text (default font) and default chr_ignore=True >>> print(Art) _ __ _ _ __ | |_ / _` || '__|| __| | (_| || | | |_ \__,_||_| \__| >>> Art=text2art("art",font='block',chr_ignore=True) # Return ASCII text with block font >>> print(Art) .----------------. .----------------. .----------------. | .--------------. || .--------------. || .--------------. | | | __ | || | _______ | || | _________ | | | | / \ | || | |_ __ \ | || | | _ _ | | | | | / /\ \ | || | | |__) | | || | |_/ | | \_| | | | | / ____ \ | || | | __ / | || | | | | | | | _/ / \ \_ | || | _| | \ \_ | || | _| |_ | | | ||____| |____|| || | |____| |___| | || | |_____| | | | | | || | | || | | | | '--------------' || '--------------' || '--------------' | '----------------' '----------------' '----------------' >>> Art=text2art("test","random") # random font mode >>> print(Art) | | ~|~/~/(~~|~ | \/__) | >>> Art=text2art("test","rand") # random font mode >>> print(Art) ___ ____ ____ ___ | |___ [__ | | |___ ___] | >>> print(text2art("test", space=10)) _ _ | |_ ___ ___ | |_ | __| / _ \ / __| | __| | |_ | __/ \__ \ | |_ \__| \___| |___/ \__| >>> print(text2art('''Lorem ipsum dolor''', font="small")) # Multi-line print _ | | ___ _ _ ___ _ __ | |__ / _ \| '_|/ -_)| ' \ |____|\___/|_| \___||_|_|_| _ (_) _ __ ___ _ _ _ __ | || '_ \(_-<| || || ' \ |_|| .__//__/ \_,_||_|_|_| |_| _ _ __| | ___ | | ___ _ _ / _` |/ _ \| |/ _ \| '_| \__,_|\___/|_|\___/|_| >>> print(text2art("test","white_bubble")) # Non-ASCII font example ⓣⓔⓢⓣ >>> text2art("art",font="fancy5",decoration="barcode1") # decoration parameter is added in Version 4.6 '▌│█║▌║▌║ ᏗᏒᏖ ║▌║▌║█│▌' >>> text2art("seسسس",font=DEFAULT_FONT,chr_ignore=False) # raise artError in exception Traceback (most recent call last): ... art.art.artError: س is invalid. ``` -------------------------------- ### Save generated ASCII art to file with Python art library Source: https://context7.com/sepandhaghighi/art/llms.txt Uses the `tsave` function to write ASCII art to a file and returns a status dictionary. Supports custom fonts, decorations, overwriting, custom line separators, and character spacing. Provides optional status printing and error handling. ```Python from art import tsave # Basic save with default settings response = tsave("Hello World", filename="output.txt") print(response) # Save with custom font response = tsave("Python", font="block", filename="python_art.txt") print(response) # Save without print status response = tsave("Quiet", filename="quiet.txt", print_status=False) print(response) # Save with overwrite enabled response = tsave("New", filename="output.txt", overwrite=True) print(response) # Save with decoration response = tsave("Decorated", filename="decor.txt", decoration="heart1") print(responsen # Save with custom line separator (Windows style) response = tsave("Windows", filename="win.txt", sep="\\r\\n") print(response) # Save with character spacing response = tsave("Spaced", filename="spaced.txt", space=3) print(response) # Error handling response = tsave(123, filename="error.txt") # Invalid input print(response) ``` -------------------------------- ### lprint: Print Character Grid in Python Source: https://github.com/sepandhaghighi/art/blob/master/README.md The lprint function prints a grid of specified length and height filled with a given character, raising artError on invalid inputs. Defaults are length=15, height=1, char='#'; new in Version 6.4. Inputs: length, height, char; outputs: printed grid; no major dependencies beyond ART library. ```python >>> lprint(length=15, height=2, char="*") *************** *************** ``` -------------------------------- ### Print 1-line Art (Python) Source: https://github.com/sepandhaghighi/art/blob/master/README.md Function that prints 1-line art in normal mode and raises artError on exceptions. Supports custom number of repetitions and spacing. Handles random art generation modes for unpredictable output. ```python >>> aprint("butterfly") # print art Ƹ̵̡Ӝ̵̨̄Ʒ >>> aprint("happy") # print art ۜ\(סּںסּَ` )/ۜ >>> aprint("coffee", number=3, space=5) c[_] c[_] c[_] >>> aprint("random") # random 1-line art mode '(っ◕‿◕)っ ' >>> aprint("rand") # random 1-line art mode 't(-_-t) ' >>> aprint("woman",number="22") # raise artError Traceback (most recent call last): ... art.art.artError: The 'number' type must be int. ``` -------------------------------- ### Print ASCII art directly to console using Python art library Source: https://context7.com/sepandhaghighi/art/llms.txt Leverages the `tprint` function to output ASCII art to stdout without returning a value. Allows custom fonts, decorations, random and wizard modes, and character spacing. Handles Unicode errors automatically. ```Python from art import tprint # Print with default font tprint("Hello World") # Print with custom font and decoration tprint("ART", font="fancy42", decoration="star1") # Random font mode tprint("Random", font="random") # Wizard mode - automatically selects font based on text length tprint("Hi", font="wizard") tprint("This is a longer text", font="wizard") # Character spacing tprint("SPACE", space=3) ``` -------------------------------- ### Convert text to ASCII art with Python art library Source: https://context7.com/sepandhaghighi/art/llms.txt Uses the `text2art` function from the `art` package to generate ASCII art strings. Supports custom fonts, decorations, character spacing, and multi‑line input. Returns the generated art as a string for further processing. ```Python from art import text2art, tprint, tsave # Basic usage - convert text to ASCII art with default font art_text = text2art("Hello") print(art_text) # Using a specific font art_text = text2art("ART", font="block") print(art_text) # Adding decorations art_text = text2art("Python", font="fancy5", decoration="barcode1") print(art_text) # Adding space between characters art_text = text2art("test", space=5) print(art_text) # Multi-line text support multi_line = text2art('''Hello World''', font="small") print(multi_line) ``` -------------------------------- ### tprint: Print ASCII Art Text in Python Source: https://github.com/sepandhaghighi/art/blob/master/README.md The tprint function generates and prints ASCII art from input text using specified fonts, with options for decorations, spacing, and character ignoring. It returns None on success and raises artError for invalid characters unless chr_ignore is True. Dependencies include the ART library; inputs are text, font, decoration, space, sep; outputs are printed art; limitations include font availability and non-ASCII support. ```python >>> tprint("art") # print ASCII text (default font) _ __ _ _ __ | |_ / _` || '__|| __| | (_| || | | |_ \__,_||_| \__| ``` ```python >>> tprint("art",font="block",chr_ignore=True) # print ASCII text (block font) .----------------. .----------------. .----------------. | .--------------. || .--------------. || .--------------. | | | __ | || | _______ | || | _________ | | | | / \ | || | |_ __ \ | || | | _ _ | | | | | / /\ \ | || | | |__) | | || | |_/ | | \_| | | | | / ____ \ | || | | __ / | || | | | | | | | _/ / \ \_ | || | _| | \ \_ | || | _| |_ | | | ||____| |____|| || | |____| |___| | || | |_____| | | | | | || | | || | | | | '--------------' || '--------------' || '--------------' | '----------------' '----------------' '----------------' ``` ```python >>> tprint('testسس') # chr_ignore flag ==True (Default) _ _ | |_ ___ ___ | |_ | __| / _ \/ __|| __| | |_ | __\/__ \| |_ \__| \___||___/ \__| ``` ```python >>> tprint("test","random") # random font mode | | ~|~/~/(~~|~ | \__/) | ``` ```python >>> tprint("test","rand") # random font mode ___ ____ ____ ___ | |___ [__ | | |___ ___] | ``` ```python >>> tprint("test", space=10) _ _ | |_ ___ ___ | |_ | __| / _ \ / __| | __| | |_ | __/ \__ \ | |_ \__| \___| |___/ \__| ``` ```python >>> tprint('testسس',chr_ignore=False) # raise artError in exception Traceback (most recent call last): ... art.art.artError: س is invalid. ``` ```python >>> tprint('''Lorem ipsum dolor''', font="cybermedium") # Multi-line print _ ____ ____ ____ _ _ | | | |__/ |___ |\/| |___ |__| | \ |___ | | _ ___ ____ _ _ _ _ | |__] [__ | | |\/| | | ___] |__| | | ___ ____ _ ____ ____ | \ | | | | | |__/ |__/ |__| |___ |__| | \ ``` ```python >>> tprint("art",font="fancy5",decoration="barcode1") # decoration parameter is added in Version 4.6 ▌│█║▌║▌║ ᏗᏒᏖ ║▌║▌║█│▌ ``` ```python >>> tprint("art",font="fancy5",decoration="random") # decoration random mode is added in Version 5.0 •]•·✦º✦·»ᏗᏒᏖ«·✦º✦·•[• ``` -------------------------------- ### line: Generate Character Grid String in Python Source: https://github.com/sepandhaghighi/art/blob/master/README.md The line function returns a string representation of a grid of specified length and height filled with a given character, raising artError on invalid inputs. Defaults are length=15, height=1, char='#'; new in Version 6.4. Inputs: length, height, char; outputs: string with newlines; limitations include string size constraints. ```python >>> line(length=15, height=2, char="*") '***************\n***************' ``` -------------------------------- ### Generate Line Patterns Python Source: https://context7.com/sepandhaghighi/art/llms.txt Creates horizontal lines, blocks, and custom patterns using line() and lprint() functions. Supports customizable length, height, and character selection. Useful for creating visual separators and dividers. Can generate both single lines and block patterns. ```python from art import line, lprint # Generate horizontal line separator = line(length=50, height=1, char='=') print(separator) # ================================================== # Generate block pattern block = line(length=20, height=3, char='#') print(block) # #################### # #################### # #################### # Print directly lprint(length=30, height=2, char='*') # ****************************** # ****************************** # Create custom patterns box_top = line(length=40, height=1, char='─') box_side = line(length=1, height=5, char='│') # Use as dividers print("HEADER") lprint(length=50, char='-') print("Content here") lprint(length=50, char='-') ``` -------------------------------- ### Random Non-ASCII font selection in Python Source: https://github.com/sepandhaghighi/art/blob/master/README.md This mode randomly selects from non-ASCII fonts for text display. Keywords are 'random-na', 'rand-na', and 'rnd-na'. Introduced in Version 3.4. ```python >>> tprint("test","random-na") ``` -------------------------------- ### Generate Random Art Python Source: https://context7.com/sepandhaghighi/art/llms.txt Returns random one-line ASCII art from library collection using randart() function. Each call generates different art piece for variety. Useful for creating dynamic visual elements in applications. Can be used in loops for generating multiple random art pieces. ```python from art import randart # Get random art art1 = randart() print(art1) # ʕ•ᴥ•ʔ art2 = randart() print(art2) # (づ。◕‿‿◕。)づ # Use in loops for variety for i in range(5): print(f"Random art {i+1}: {randart()}") ``` -------------------------------- ### Randomly select xlarge fonts in Python Source: https://github.com/sepandhaghighi/art/blob/master/README.md This mode randomly selects from xlarge fonts for displaying text. It supports keywords 'rnd-xlarge', 'random-xlarge', and 'rand-xlarge'. Introduced in Version 2.8. ```python >>> tprint("test","rnd-xlarge") ``` -------------------------------- ### Mix Non-ASCII fonts in Python Source: https://github.com/sepandhaghighi/art/blob/master/README.md Randomly mixes non-ASCII fonts for text display. The keyword is 'mix'. Introduced in Version 3.7. Note: Non-ASCII fonts are only available in specific modes. ```python >>> tprint("test","mix") ```