Blame mono/Diagram/Shapes.cs

777717
/*
777717
    ......... 2015 Ivan Mahonin
777717
777717
    This program is free software: you can redistribute it and/or modify
777717
    it under the terms of the GNU General Public License as published by
777717
    the Free Software Foundation, either version 3 of the License, or
777717
    (at your option) any later version.
777717
777717
    This program is distributed in the hope that it will be useful,
777717
    but WITHOUT ANY WARRANTY; without even the implied warranty of
777717
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
777717
    GNU General Public License for more details.
777717
777717
    You should have received a copy of the GNU General Public License
777717
    along with this program.  If not, see <http: licenses="" www.gnu.org="">.</http:>
777717
*/
777717
777717
using System;
8cb222
using System.Drawing;
8cb222
8cb222
namespace Diagram {
8cb222
    public class Shapes {
8cb222
        public static void drawRoundRect(Graphics g, RectangleF rect, float radius, Pen pen, Brush brush) {
8cb222
            radius = Math.Min(radius, 0.5f*rect.Width);
8cb222
            radius = Math.Min(radius, 0.5f*rect.Height);
8cb222
            float d = 2f*radius;
8cb222
8cb222
            g.FillPie(brush, rect.Left,    rect.Top,      d, d, -180f, 90f);
8cb222
            g.FillPie(brush, rect.Right-d, rect.Top,      d, d,  -90f, 90f);
8cb222
            g.FillPie(brush, rect.Right-d, rect.Bottom-d, d, d,    0f, 90f);
8cb222
            g.FillPie(brush, rect.Left,    rect.Bottom-d, d, d,   90f, 90f);
8cb222
            g.FillRectangle(brush, rect.Left+radius, rect.Top, rect.Width-d, rect.Height);
8cb222
            g.FillRectangle(brush, rect.Left, rect.Top+radius, rect.Width, rect.Height-d);
8cb222
8cb222
            g.DrawArc(pen, rect.Left,    rect.Top,      d, d, -180f, 90f);
8cb222
            g.DrawArc(pen, rect.Right-d, rect.Top,      d, d,  -90f, 90f);
8cb222
            g.DrawArc(pen, rect.Right-d, rect.Bottom-d, d, d,    0f, 90f);
8cb222
            g.DrawArc(pen, rect.Left,    rect.Bottom-d, d, d,   90f, 90f);
8cb222
            g.DrawLine(pen, rect.Left+radius, rect.Top, rect.Right-radius, rect.Top);
8cb222
            g.DrawLine(pen, rect.Left+radius, rect.Bottom, rect.Right-radius, rect.Bottom);
8cb222
            g.DrawLine(pen, rect.Left, rect.Top+radius, rect.Left, rect.Bottom-radius);
8cb222
            g.DrawLine(pen, rect.Right, rect.Top+radius, rect.Right, rect.Bottom-radius);
8cb222
        }
8cb222
    }
8cb222
}
8cb222