Represents a rectangle within a Cartesian coordinate space.
コード例 #1
0
ファイル: Utilities.cs プロジェクト: hexafluoride/no
        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);
        }
コード例 #2
0
ファイル: Rectangle.cs プロジェクト: hexafluoride/no
 private bool IntersectCheck(Rectangle first, Rectangle second)
 {
     return
         first.Top < second.Bottom && first.Top > second.Top &&
         first.Left < second.Right && first.Left > second.Left;
 }
コード例 #3
0
ファイル: Rectangle.cs プロジェクト: hexafluoride/no
 public bool Intersects(Rectangle rect)
 {
     return IntersectCheck(this, rect) || IntersectCheck(rect, this);
 }
コード例 #4
0
ファイル: TextBuffer.cs プロジェクト: hexafluoride/no
        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();
        }