Beispiel #1
0
        /// <summary>
        /// Draws an ellipse to the sprite.
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="color">The color to draw.</param>
        /// <param name="plotWidth">The pen width.</param>
        /// <param name="fill">True to fill the ellipse.</param>
        public void DrawEllipse(int x1, int y1, int x2, int y2, int color, int plotWidth = 1, bool fill = false)
        {
            if (x2 < x1)
            {
                MerthsoftExtensions.Swap(ref x1, ref x2);
            }
            if (y2 < y1)
            {
                MerthsoftExtensions.Swap(ref y1, ref y2);
            }

            int hr = (x2 - x1) / 2;
            int kr = (y2 - y1) / 2;
            int h  = x1 + hr;
            int k  = y1 + kr;

            DrawEllipseUsingRadius(h, k, hr, kr, color, plotWidth, fill);
        }
Beispiel #2
0
 /// <summary>
 /// Draws a rectangle to the sprite.
 /// </summary>
 /// <param name="x1"></param>
 /// <param name="y1"></param>
 /// <param name="x2"></param>
 /// <param name="y2"></param>
 /// <param name="color">The color to draw.</param>
 /// <param name="plotWidth">The pen width.</param>
 /// <param name="fill">True to fill the rectangle.</param>
 public void DrawRectangle(int x1, int y1, int x2, int y2, int color, int plotWidth = 1, bool fill = false)
 {
     if (!fill)
     {
         DrawLine(x1, y1, x1, y2, color, plotWidth);
         DrawLine(x1, y2, x2, y2, color, plotWidth);
         DrawLine(x2, y2, x2, y1, color, plotWidth);
         DrawLine(x1, y1, x2, y1, color, plotWidth);
     }
     else
     {
         if (x1 > x2)
         {
             MerthsoftExtensions.Swap(ref x1, ref x2);
         }
         for (int x = x1; x <= x2; x++)
         {
             DrawLine(x, y1, x, y2, color, plotWidth);
         }
     }
 }