• C# JackLib系列之GdiHelper圆角矩形的快速生成


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Drawing;
    using System.Drawing.Drawing2D;

    namespace JackLib.GdiHelper {

        /// <summary>
        /// GdiHelper
        /// </summary>
        public class GdiHelper {
            /// <summary>
            /// 获取圆角矩形
            /// </summary>
            /// <param name="rect">原始矩形</param>
            /// <param name="radius">圆角大小(像素)</param>
            /// <returns></returns>
            public static GraphicsPath GetRoundRectangle(Rectangle rect, int radius) {
                GraphicsPath path = new GraphicsPath();
                Point lefttop = new Point(rect.X, rect.Y);
                Point righttop = new Point(rect.X + rect.Width, rect.Y);
                Point rightbottom = new Point(rect.X + rect.Width, rect.Y + rect.Height);
                Point leftbottom = new Point(rect.X, rect.Y + rect.Height);
                path.AddArc(lefttop.X, lefttop.Y, radius * 2, radius * 2, 180, 90);
                path.AddLine(lefttop.X + radius, lefttop.Y, righttop.X - radius, righttop.Y);
                path.AddArc(righttop.X - radius * 2, righttop.Y, radius * 2, radius * 2, 270, 90);
                path.AddLine(righttop.X, righttop.Y + radius, rightbottom.X, rightbottom.Y - radius);
                path.AddArc(rightbottom.X - radius * 2, rightbottom.Y - radius * 2, radius * 2, radius * 2, 0, 90);
                path.AddLine(rightbottom.X - radius, rightbottom.Y, leftbottom.X + 5, leftbottom.Y);
                path.AddArc(leftbottom.X, leftbottom.Y - radius * 2, radius * 2, radius * 2, 90, 90);
                path.AddLine(lefttop.X, leftbottom.Y - radius, lefttop.X, lefttop.Y + radius);
                path.CloseFigure();
                return path;
            }
        }
    }


  • 相关阅读:
    海尔大数据精准营销平台(内部资料)
    马化腾做的PPT:产品设计与用户体验
    网站上线后,第一次完成线上线下整个环节
    灵感不断
    redis命令
    Redis持久化实践及灾难恢复模拟
    [转]创业公司常见的25个法律问题
    用python语言编写网络爬虫
    Python3常用网络编程模块介绍
    Python3数据库模块(sqlite3,SQLite3)
  • 原文地址:https://www.cnblogs.com/shaozhuyong/p/5130528.html
Copyright © 2020-2023  润新知