Represents a rectangle within a Cartesian coordinate space.
Exemple #1
0
        public static void ClearArea(Rectangle rect)
        {
            int x_t = Console.CursorLeft;
            int y_t = Console.CursorTop;

            for(int x = rect.Left; x < rect.Right; x++)
            {
                for(int y = rect.Top; y < rect.Bottom; y++)
                {
                    Console.SetCursorPosition(x, y);

                    Console.Write(" ");
                }
            }

            Console.SetCursorPosition(x_t, y_t);
        }
Exemple #2
0
 private bool IntersectCheck(Rectangle first, Rectangle second)
 {
     return
         first.Top < second.Bottom && first.Top > second.Top &&
         first.Left < second.Right && first.Left > second.Left;
 }
Exemple #3
0
 public bool Intersects(Rectangle rect)
 {
     return IntersectCheck(this, rect) || IntersectCheck(rect, this);
 }
Exemple #4
0
        public void PrintToConsole(Point position, bool clear = false)
        {
            ColorInfo color = ColorInfo.FromConsole();

            Rectangle drawarea = new Rectangle(position, Size);

            if (clear)
                Console.Clear();

            for (int y = drawarea.Top; y < drawarea.Bottom; y++)
            {
                Console.SetCursorPosition(position.X, y);

                for(int x = drawarea.Left; x < drawarea.Right; x++)
                {
                    int local_x = x - drawarea.Left;
                    int local_y = y - drawarea.Top;

                    Colors[local_y, local_x].SetConsoleColor();
                    Console.Write(Text[local_y, local_x]);
                }
                Console.WriteLine();
            }

            color.SetConsoleColor();
        }