6

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?

pppery
  • 3,731
  • 22
  • 33
  • 46
GurdeepS
  • 65,107
  • 109
  • 251
  • 387
  • you mean like converting an image to ascii art with a c# program? – Ashley Grenon Aug 08 '10 at 21:30
  • You'll have to define what you mean by ASCII art. If you are okay with only rendering 1-bit images, or you are allowed to color each character in 24 bits, it may be much more simple to come up with the answer. If you have to use a smaller color palette to represent a 24-bit color image, or you have to use one color to represent a gray scale, it may be more complicated, and you may have to resort to the answers other people have already given. Which are you looking for? – Merlyn Morgan-Graham Aug 08 '10 at 22:44
  • I think that's a pretty stupid interview question... It doesn't really prove anything about your skills. So don't feel too bad if you didn't get the job ;) – Thomas Levesque Aug 08 '10 at 22:52

4 Answers4

12

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!"));
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
3

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

Marko
  • 71,361
  • 28
  • 124
  • 158
3

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.

marsh-wiggle
  • 2,508
  • 3
  • 35
  • 52
YT_GraphiX
  • 31
  • 2
1

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.

JustBoo
  • 1,723
  • 9
  • 9