Skip to content

Instantly share code, notes, and snippets.

@nin-jat
Last active November 16, 2022 20:14
Show Gist options
  • Select an option

  • Save nin-jat/7a18755b07aff61c4f37c1c27de449c6 to your computer and use it in GitHub Desktop.

Select an option

Save nin-jat/7a18755b07aff61c4f37c1c27de449c6 to your computer and use it in GitHub Desktop.
This shows a cat in your console.
/// <summary>
/// This program draws a cute cat on your console.
/// View more at the gist over here.
/// https://gist.github.com/Those45Ninjas/7a18755b07aff61c4f37c1c27de449c6
///
/// This cute cat was sourced from textart4u.
/// http://textart4u.blogspot.com/2013/02/cute-cat-face-ascii-text-art.html
///
/// Code written by Those45Ninjas
/// </summary>
using System;
class Cat
{
static void Main()
{
// Save the position of the cursor for later.
var oldLeft = Console.CursorLeft;
var oldTop = Console.CursorTop;
// Draw the cat picture.
CatPicture.Draw(ConsoleColor.DarkGray);
// Reset the cursor position so you can continue with your terminal.
Console.SetCursorPosition(oldLeft, oldTop);
}
}
/// <summary>
/// The cat picture class used to draw cats down the bottom right of the terminal.
/// </summary>
static class CatPicture
{
static readonly string[] picture = new string[]
{
" ▓▓█",
" ▒██▒▒█",
" █▓▓▓░▒▓▓",
" ▒█▓▒█░▒▒▒█",
" ▒█▒▒▒█▒▒▒▒▓▒",
"▓▓▒░ ▓█▒▒▒▓██▓▒░▒█",
"█▓▓██▓░ ▓█▒▒▒▒████▒▒▒█",
"▓█▓▒▒▓██▓░ ▒█▒▒▒▒▒██▓█▓░░▓▒",
"▓▒▓▒▒▒▒▒▓█▓░ ░▒▒▓▓██▒▒▒▒▒▒█████▒▒▒▓",
"▓░█▒▒▒▒▒▒▒▓▓█▓█▓▓▓▓▒▒▒▒▒▒▒▒██▓██▒░▒█",
"▓░▓█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓████▒▒▒█",
"▓░▓██▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▓██░░░█",
"▓░▓███▒▒▒▒▒▒▒▒▒▒▒▓█▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▒▓▓",
"▒▒▒██▓▒▓█▓▒▒▒▒▒▒▒▓▒▒▒▒▒▒▓▓▓▒▒▒▒▒▒▒▓▒█",
" ▓▒█▓▒▒▒▒▓▒▒▒▒▒▒▒▒▒▒▒▓█▓▓▓▓█▓▒▒▒▒▒▒▒▓▒",
" ▓▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓ ▓█▓▒▒▒▒▒▓█",
" ▒▒▓▒▒▒▓▓▓▒▒▒▒▒▒▒▒▒▓▓ ░▓▓ █▓▒▒▒▒▒█",
" █▒▒▓▓▓▒▒▓▓▒▒▒▒▒▒▓▓ █████▓ █▓▒▒▒▒▓▒",
" ▓▓█▒ ▒▓▒▒▒▒▒█ ░██████ ░█▒▒▒▒▓▓",
" ▓█▒ ▒███ ▒▓▒▒▒▒█ ██████ ▓▒▒▒▒▒▓",
" ██ █████ █▒▒▒▒█ ███▓ ▓▓▒▒▒▒▓",
" █▓ █████ ▒▓▒▒▒█ █▓▓▓▒▒▓",
" █▓ ░███ ░▓▒▒▒▓█ ░█▓▒▒▒▓▒▓",
" ██ ▒▓▒▒▒▒▓▓ ░▒▓█▓ ░▓▓",
" ▓█░ █▓██▓▒▒▓█▓▓▓▓██▓▓▒▓▒░░▒▓▒▓",
" ▒██░ ▓▒███▓▒▒▒▒▓▓▓▓▒▒▒▒▒▒▓▓▓▓▒▓",
" █▓█▓▓▒▒▓█▓▒░██▒▒▓▓█▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓█▒",
" ▓ ░▓▓▓▓▓▒▓▓▓▓▒▓▓▓▒▓▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓",
" ▒▒▒▓▒▒▒▒▒▒▓█░ ░░░ ▓▓▒▒▒▒▒▒▒▒▒▒▒▓██▓▒",
" █▓▒▒▒▒▒▒▒▒▓▓ ░░░ ▓▓▒▒▒▒▒▒▒▒▒▓▓▓▒▒▓▒",
" ██▓▓▒▒▒▒▒▒█▒░░░░█▒▒▒▒▒▒▒▒▓█▓▓▒▒▒▒▒",
" ░ ▒██▓▓▒▒▒▒▒█▓▒▒▓▒▒▒▒▒▒▓███▓▒▒▒▒▒▓▓",
" ░▒▓▓▓▓▒▒▓▓▓▓▓▓████▓▓█▒▒▒▒▒▓▓█░"
};
/// <summary>
/// Draw the cat.
/// </summary>
/// <param name="colour">The to draw the cat in.</param>
public static void Draw(ConsoleColor colour)
{
// Set the colour.
Console.ForegroundColor = colour;
int v = 0;
for (int i = picture.Length - 1; i >= 0; i--, v++)
{
// Move the cursor to the right minus the width of the picture.
Console.CursorLeft = Console.WindowWidth - 39;
// Move the cursor to the bottom minus the vertical offset.
Console.CursorTop = Console.WindowHeight - v;
// Draw a line of the picture.
Console.Write(picture[i]);
// Move to the next line unless it's the last one (for is in reverse (forr))
if (i != 0)
Console.WriteLine();
}
// Reset the colour because we are good programmers.
Console.ResetColor();
}
}
@nin-jat
Copy link
Author

nin-jat commented Mar 19, 2019

Preview

It looks like this.

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