예제 #1
0
 public void DrawLine(int x1, int y1, int x2, int y2, char c, int rowOffSet = 0)
 {
     if (x1 == x2)
     {
         //Vertical line
         for (int i = y1; i <= y2; i++)
         {
             _consoleBuffer.WriteCharAtLocation(x1, i + rowOffSet, c);
         }
     }
     else if (y1 == y2)
     {
         // Horizontal Line
         for (int i = x1; i <= x2; i++)
         {
             _consoleBuffer.WriteCharAtLocation(i, y1 + rowOffSet, c);
         }
     }
     else
     {
         throw new InvalidCoordinatesException("Only straight lines are allowed");
     }
 }