GurdeepS
GurdeepS

Reputation: 67233

Producing ascii art via C#

I once did a programming test for a job, which involved producing ASCii art in C#. I didn't really do well at this, as I had little idea or experience of doing this in C# (or in any programming knowledge).

Are there any resources or classes in .NET that would be worth knowing/practising on?

Upvotes: 7

Views: 41354

Answers (4)

YT_GraphiX
YT_GraphiX

Reputation: 31

After some research I found out that the best way to do it is this:

1. go to Text to ASCII Art Generator (TAAG).

2. type your text.

3. Change the settings to make the text look right to you.

enter image description here

3. click "Select & Copy"

enter image description here

4. In the C# code type this:

string text = @"// Your copied ASCII code";
Console.WriteLine(text);

Make sure you add the @ sign before the quotes so that the formatting stays the same, otherwise the editor will give you lots of errors.

Upvotes: 3

Drew Noakes
Drew Noakes

Reputation: 311195

ASCII art is pretty general, but if you want to produce an ASCII banner or heading then I've ported the popular FIGlet font generation to .NET:

https://github.com/drewnoakes/figgle

It's very easy to use, and available on NuGet for almost every version of .NET (netstandard1.3 and above, so .NET Framework as well as .NET Core, Xamarin, etc...).

            _ _          __    __           _     _   _ 
  /\  /\___| | | ___    / / /\ \ \___  _ __| | __| | / \
 / /_/ / _ \ | |/ _ \   \ \/  \/ / _ \| '__| |/ _` |/  /
/ __  /  __/ | | (_) |   \  /\  / (_) | |  | | (_| /\_/ 
\/ /_/ \___|_|_|\___( )   \/  \/ \___/|_|  |_|\__,_\/   
                    |/       

Produced via:

Console.WriteLine( 
    FiggleFonts.Ogre.Render("Hello, World!"));

Upvotes: 12

JustBoo
JustBoo

Reputation: 1741

To understand the full ASCII "spectrum" one should know about the ASCII Chart, also known as the ASCII Table.

http://www.asciitable.com/

Knowing that, one could take code found in the codeproject link and make something "unique" with it. :-)

If you think about it, it's just a "look-up" table and you can pull a value out of it and do anything you want.

Upvotes: 1

Marko
Marko

Reputation: 72232

Have a read at this post http://www.c-sharpcorner.com/UploadFile/dheenu27/ImageToASCIIconverter03022007164455PM/ImageToASCIIconverter.aspx

It allows you to upload an image which will be converted into ASCII art :) Pretty cool stuff.

CodeProject has a sample too http://www.codeproject.com/KB/web-image/ascii_art_with_c_.aspx

Upvotes: 3

Related Questions