How to make you console app look cool

From time to time everyone needs to write simple console application. It’s a great, simple type of project to test something or write a simple tool. However, most of the times it looks… kind of dull.

What if it could have an updating percentage value?

Let’s start with something we know. Let’s create a console app, that would show a percentage of the task being done.

And it produces output like this:

There’s one little trick to it. Notice I used \r character, that moves caret back to the beginning of the line, where next write overrides last one. It’s a simple animation!

Let’s create a spinner

With a bit of searching through Internet and a little of code:

We will have something like this:

We need to go bigger!

I searched a bit and came across this post on StackOverflow: https://stackoverflow.com/questions/2685435/cooler-ascii-spinners

Here it is an implementation of an “executive desk toy”.

And we have multiline ASCII animation:

Cool, isn’t it? With your imagination and thousands of Unicode characters possibilities are limitless.

Let’s have some color

Colorful.Console is a fantastic nuget package, that you can use to introduce some color into your console application. With just a few lines of code:

We can see something like this:

Colorful.Console overrides original console, so it does have all existing methods, but it extends original object with new possibilities. This is important, because you can start using this console in your old code, but introduce color only where you want it.

So let’s do some animation with color. This is super easy and a lot of fun.

This code produces simple, but effective animation. How would it look in your next console tool? Awesome!

This nuget package offers even more, like colorful text. You can use ASCII fonts to write text. You can download fonts here – there are plenty.

With a little code:

And downloaded larry3d.flf font file you can see an effect:

Full tutorial is available here: http://colorfulconsole.com/

All code posted here is available on my github repository: https://github.com/mikuam/Blog/tree/master/ServiceBusExamples/MichalBialecki.com.ConsoleAppMagic

Enjoy and make exciting and amusing code 🙂

2 thoughts on “How to make you console app look cool

Leave a Reply

Your email address will not be published. Required fields are marked *