Skip to content

Instantly share code, notes, and snippets.

@ThoNohT
Created November 8, 2019 13:47
Show Gist options
  • Save ThoNohT/47625c4b3bb719950d4e2dfefb859423 to your computer and use it in GitHub Desktop.
Save ThoNohT/47625c4b3bb719950d4e2dfefb859423 to your computer and use it in GitHub Desktop.
using System;
using System.Text;
namespace Tree
{
class Program
{
static void Main(string[] args)
{
var h = 32;
var w = 50d;
var center = w / 2;
var sb = new StringBuilder();
for (var i = 0; i < h * w; i++)
{
var posY = i / w;
var posX = (int)Math.Round((posY - (int)posY) * w);
// Trunk.
if (posX - center < 2 && posX - center > -2 && posY > h / 1.5 && posY < h - 1)
sb.Append("X");
// Right border.
else if (posX == w - 1)
sb.Append("=\r\n");
// Left border.
else if (posX == 0 || posY == 0 || posY == h - 1)
sb.Append("=");
// Leaves / balls.
else if (Math.Abs(posX - center) < posY / (float)h * center && posY <= h / 1.5)
if (i % (int)(w * 1.39) == 0)
sb.Append("O");
else
sb.Append("*");
// Empty space.
else
sb.Append(" ");
}
Console.Write(sb.ToString());
// I especially love this line.
var a = 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment