You can add visual design to your C# text-based console application even though you can't use graphic files. Alphanumeric characters can be used to create design elements, ASCII design, in your console application.
Used strategically, ASCII art can make an interface more interesting. Balance your ASCII art carefully so it doesn't overwhelm the player, or distract from important text you want someone to pay attention to.
Creating ASCII Design Elements
Some options for creating an original design for your application include:
- Image and Text Generators: creating images or multi-line words and designs with creation tools
- Convertors: downloading or using an online convertor to translate a graphic you've created into alphanumeric characters
- Building: creating designs one alphanumeric letter or symbol at a time
If you don't want to make your own design, you can search for an existing one. Be sure to check that the creators allow you to use their designs first, though. Some are licensed with restrictions on how you can use them.
Image Generators
Generating images with online tools allows you to create complex designs without too much effort. Not all of the designs transfer gracefully from online to console application, though, and you might need to adjust them after including them in your code.
ASCIIFlow
ASCIIFlow.com has an intuitive interface and a large space to work in.
You can make images and/or text. When finished, export your work or save it to Google drive.
Blocky Text Art
Similar to ASCIIFlow.com is Nerd Show's Blocky Text Art. This tool also allows you to create images and/or text.
If you see question marks or gaps when testing your application you'll need to adjust the characters in your C# file.
Text Generators
There are a lot of online text generators, each with a nice selection of fonts that you can choose from. These are straightforward to use, and generally look the same in your console application as online. Type in the text and it will create the multi-line design for you.
Two easy to use generators:
Convertors
Image convertors can create an ASCII art version of a photograph or graphic.
The resulting designs tend to be a lot bigger than the other options, so this might not be a good solution for an application with a small window size.
Building ASCII Design Elements
If you want to create your own ASCII art without using a generator or convertor, you can use a text editor to build up your design. It can take longer to create a design in this fashion, but you will have more control over the result. I recommend reading the comprehensive ASCII-code.com FAQ. It has history, tips on how to create ASCII art in a text editor, examples, and links to helpful resources.
Using ASCII Design in C# Console Applications
Once you have your design, there is an easy way to include it in your code. Using a separate WriteLine for each line of a multi-line design works, but isn't necessary. Instead create a string variable and use the @ (at) symbol. Then use one WriteLine to write out the design. This technique is also helpful if you have long strings of text.
To use it, simply add an @ symbol before the first quotation mark.
string title = @""; Console.WriteLine(title);
Example Code
Create a new C# project and copy/paste the following code to try out a multi-line title. It might be difficult to see here, but it should write out the words "Fancy Title" when your console application runs.
using System; namespace ASCIIDesign { class Program { static void Main() { Console.Title = "ASCII Art"; string title = @" ____ ______ __ ___ /\ _`\ /\__ _\__/\ \__/\_ \ \ \ \L\_\ __ ___ ___ __ __ \/_/\ \/\_\ \ ,_\//\ \ __ \ \ _\/'__`\ /' _ `\ /'___\/\ \/\ \ \ \ \/\ \ \ \/ \ \ \ /'__`\ \ \ \/\ \L\.\_/\ \/\ \/\ \__/\ \ \_\ \ \ \ \ \ \ \ \_ \_\ \_/\ __/ \ \_\ \__/.\_\ \_\ \_\ \____\\/`____ \ \ \_\ \_\ \__\/\____\ \____\ \/_/\/__/\/_/\/_/\/_/\/____/ `/___/> \ \/_/\/_/\/__/\/____/\/____/ /\___/ \/__/ "; Console.WriteLine(title); Console.Read(); } } }
Show More Example Code
Five multi-line titles in one code example to test several alternatives at once.
using System; namespace ASCIIDesign { class Program { static void Main() { Console.Title = "ASCII Art"; string title = @" _ __ __ ____ _ / | / /__ ____ _/ /_ / __ \___ _____(_)___ _____ / |/ / _ \/ __ `/ __/ / / / / _ \/ ___/ / __ `/ __ \ / /| / __/ /_/ / /_ / /_/ / __(__ ) / /_/ / / / / /_/ |_/\___/\__,_/\__/ /_____/\___/____/_/\__, /_/ /_/ /____/ _ _ ___ __ ____ ___ ___ ___ __ __ _ _ ( \( )( _) ( )(_ _) ( \( _)/ __)( )/ _)( \( ) ) ( ) _) /__\ )( ) ) )) _)\__ \ )(( (/\ ) ( (_)\_)(___)(_)(_)(__) (___/(___)(___/(__)\__/(_)\_) \ | | __ \ _) \ | _ \ _` | __| | | _ \ __| | _` | __ \ |\ | __/ ( | | | | __/\__ \ | ( | | | _| \_|\___|\__,_|\__| ____/ \___|____/_|\__, |_| _| |___/ , ___ /|/\ _ _, _|_ (| \ _ , o _, | | |/ / | | | ||/ / \_| / | /|/| | |_/|_/\/|_/|_/ (\__/ |_/ \/ |/\/|/ | |_/ (| _ _ _ ____ _ | \ | | ___ __ _| |_ | _ \ ___ ___(_) __ _ _ __ | \| |/ _ \/ _` | __| | | | |/ _ \/ __| |/ _` | '_ \ | |\ | __/ (_| | |_ | |_| | __/\__ \ | (_| | | | | |_| \_|\___|\__,_|\__| |____/ \___||___/_|\__, |_| |_| |___/ "; Console.WriteLine(title); Console.Read(); } } }
Clearing Screens
To clear a screen that is full of ASCII designs, or text, use the Clear method of the Console class.
Console.Clear();
For example, you can create a title screen to your application. At the bottom, have something along the lines of:
Console.WriteLine("Press enter to continue..."); Console.ReadKey(); Console.Clear();
When the player clicks the enter key the screen will clear. The text that is written to the screen next will be at the top of a blank screen.
Related Posts
- Changing properties: Console Application Window Properties.
- Console text and background color: Console Application Color: Text and Background.