Skip to content

Instantly share code, notes, and snippets.

@pahaz
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pahaz/99c4a7a319814f9e81b4 to your computer and use it in GitHub Desktop.
Save pahaz/99c4a7a319814f9e81b4 to your computer and use it in GitHub Desktop.
Simple Ascii Art Image
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class AsciiArtImage
{
static int[][] makeZebraImg(int width, int height)
{
int[][] img = new int[height][];
// write code here!
// img[0] = new int[width];
return img;
}
static void Main(string[] args)
{
int[][] myImg = new int[8][];
myImg[0] = new int[] { 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 05 };
myImg[1] = new int[] { 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 05 };
myImg[2] = new int[] { 00, 04, 01, 01, 01, 01, 01, 01, 01, 00, 00, 00, 00, 00, 00, 00, 05 };
myImg[3] = new int[] { 00, 04, 03, 03, 03, 03, 03, 03, 03, 00, 00, 00, 00, 00, 00, 00, 05 };
myImg[4] = new int[] { 00, 04, 02, 02, 02, 02, 02, 02, 02, 00, 00, 00, 00, 00, 00, 00, 05 };
myImg[5] = new int[] { 00, 04, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 05 };
myImg[6] = new int[] { 00, 04, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 05 };
myImg[7] = new int[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 09 };
draw(myImg);
Console.WriteLine(" == HomeWork: zebra: 10x10 ==");
int[][] zebraImg1 = makeZebraImg(10, 10);
// draw(zebraImg1);
Console.WriteLine(" == HomeWork: zebra: 50x15 ==");
int[][] zebraImg2 = makeZebraImg(50, 15);
// draw(zebraImg2);
Console.ReadKey();
}
static void draw(int[][] img)
{
for (int i = 0; i < img.Length; i++)
{
for (int j = 0; j < img[i].Length; j++)
{
Console.Write(intToChar(img[i][j]));
}
Console.WriteLine();
}
}
static char intToChar(int i)
{
char c = (char)0;
if (i == 00)
{
c = ' ';
}
else if (i == 01)
{
c = '░';
}
else if (i == 02)
{
c = '▒';
}
else if (i == 03)
{
c = '▓';
}
else if (i == 04)
{
c = '█';
}
else if (i == 05)
{
c = '│';
}
else if (i == 06)
{
c = '┌';
}
else if (i == 07)
{
c = '┐';
}
else if (i == 08)
{
c = '└';
}
else if (i == 09)
{
c = '┘';
}
else if (i == 10)
{
c = '─';
}
else if (i == 11)
{
c = '┴';
}
else if (i == 12)
{
c = '┬';
}
else if (i == 13)
{
c = '├';
}
else if (i == 14)
{
c = '┼';
}
else if (i == 15)
{
c = '┤';
}
/*
0 1 2 3 4 5 6 7 8 9 A B C D E F
B0 ░ ▒ ▓ │ ┤ ╡ ╢ ╖ ╕ ╣ ║ ╗ ╝ ╜ ╛ ┐
C0 └ ┴ ┬ ├ ─ ┼ ╞ ╟ ╚ ╔ ╩ ╦ ╠ ═ ╬ ╧
D0 ╨ ╤ ╥ ╙ ╘ ╒ ╓ ╫ ╪ ┘ ┌ █ ▄ ▌ ▐ ▀
*/
return c;
}
}
@pahaz
Copy link
Author

pahaz commented Nov 19, 2014

    static void drawPalette()
    {
        Console.WriteLine(" == PALETTE == ");
        for (int i = 0; i < 16; i++)
        {
            if (i < 10) { Console.Write("      "); }
            else { Console.Write("     "); }
            Console.Write(i);
            Console.Write(":");
            Console.Write(intToChar(i));
            Console.WriteLine(":");
            Console.WriteLine();
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment