Esempio n. 1
0
 public Border(IntXYPair position, IntXYPair size)
 {
     positionX = position.x;
     positionY = position.y;
     sizeX     = Math.Max(size.x, 2);
     sizeY     = Math.Max(size.y, 2);
 }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 static bool IsInScope(IntXYPair position, int sizeX, int sizeY)
 {
     return(IsInScope(position.GetX(), position.GetY(), sizeX, sizeY));
 }
Esempio n. 4
0
 static bool IsInScope(int positionX, int positionY, IntXYPair size)
 {
     return(IsInScope(positionX, positionY, size.GetX(), size.GetY()));
 }
Esempio n. 5
0
 static bool IsInScope(IntXYPair position, IntXYPair size)
 {
     return(IsInScope(position.GetX(), position.GetY(), size.GetX(), size.GetY()));
 }
Esempio n. 6
0
 static void PrintComponent(string component, IntXYPair position)
 {
     PrintComponent(component, position.x, position.y);
 }