public Border(IntXYPair position, IntXYPair size) { positionX = position.x; positionY = position.y; sizeX = Math.Max(size.x, 2); sizeY = Math.Max(size.y, 2); }
public static void PrintImage(Image image, IntXYPair position) { // isolate the Y for incrementing as each line is printed if (IsInScope(position, image.Bitmap[0].Length, image.Bitmap.Count)) { int topLimit = Math.Max(0, 0 - position.y); int row = Math.Max(position.y, 0); for (int y = topLimit; y < image.Bitmap.Count; y += 2) { char[] nextLine1 = image.Bitmap[y].ToCharArray(); char[] nextLine2; if (y + 1 >= image.Bitmap.Count) { nextLine2 = new string('Z', image.Bitmap[y].Count()).ToCharArray(); } else { nextLine2 = image.Bitmap[y + 1].ToCharArray(); } for (int x = 0; x < Math.Min(nextLine1.Length, Console.BufferWidth - position.y); x++) { string nextPixel = nextLine1[x] + ""; int nextColorIndex; nextColorIndex = GetPixelCode(nextPixel); SetForeground(nextColorIndex, image.Colors); nextPixel = nextLine2[x] + ""; nextColorIndex = GetPixelCode(nextPixel); SetBackground(nextColorIndex, image.Colors); // A special character recognized by console that covers excactly the top half of the space // it's also very square. PrintComponent("▀", x + position.x, row); } row++; } System.Console.BackgroundColor = ConsoleColor.Black; System.Console.ForegroundColor = ConsoleColor.White; } CleanUp(); }
static bool IsInScope(IntXYPair position, int sizeX, int sizeY) { return(IsInScope(position.GetX(), position.GetY(), sizeX, sizeY)); }
static bool IsInScope(int positionX, int positionY, IntXYPair size) { return(IsInScope(positionX, positionY, size.GetX(), size.GetY())); }
static bool IsInScope(IntXYPair position, IntXYPair size) { return(IsInScope(position.GetX(), position.GetY(), size.GetX(), size.GetY())); }
static void PrintComponent(string component, IntXYPair position) { PrintComponent(component, position.x, position.y); }