/// <summary>
        /// Строит прямоугольник с заданными параметрами
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        public override void Draw(StudCanvas canvas, ushort x1, ushort y1, ushort x2, ushort y2)
        {
            DevTools.Normalize(ref x1, ref x2);
            DevTools.Normalize(ref y1, ref y2);

            if (IsSolid)
            {
                DevTools.CheckRightX(ref x2, canvas);
                DevTools.CheckLowY(ref y2, canvas);
                for (int i = x1; i <= x2; i++)
                {
                    for (int j = y1; j <= y2; j++)
                    {
                        canvas.Field[i, j] = BackChar;
                    }
                }
            }
            else
            {
                int height = canvas.GetHeight();
                for (int i = x1; i <= x2; i++)
                {
                    if (y1 >= height) continue;
                    canvas.Field[i, y1] = BackChar;

                    if (y2 >= height) break;
                    canvas.Field[i, y2] = BackChar;
                }

                int width = canvas.GetWidth();
                for (int i = y1; i <= y2; i++)
                {
                    if (x1 >= width) continue;
                    canvas.Field[x1, i] = BackChar;

                    if (x2 >= width) break;
                    canvas.Field[x2, i] = BackChar;
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Реализация должна отрисовать фигуры в заданном прямоугольнике, на заданной канве
 /// </summary>
 /// <param name="canvas"></param>
 /// <param name="x1"></param>
 /// <param name="y1"></param>
 /// <param name="x2"></param>
 /// <param name="y2"></param>
 public abstract void Draw(StudCanvas canvas, ushort x1, ushort y1, ushort x2, ushort y2);