代码从网上搜集

#region 圆角矩形/// /// 最大圆角半径/// protected const int MaxRoundRadius = 3;/// /// 最小矩形边长,用于自动处理圆角大小/// protected const int MinBorderLength = 20;/// /// 绘制一个圆角矩形./// /// 当前屏幕的图形对象/// 矩形线条的颜色/// 矩形左上角X坐标/// 矩形左上角Y坐标/// 矩形右下角X坐标/// 矩形右下角Y坐标/// 圆角的半径长度public static void DrawRoundRect(System.Drawing.Graphics currentGraphicObject, Color lineColor, int nLeft, int nTop, int nRight, int nBottom, int round){if (round > MaxRoundRadius){round = MaxRoundRadius;}else if (round < 0){round = 0;}if (Math.Abs(nRight - nLeft) < MinBorderLength && Math.Abs(nBottom - nTop) < MinBorderLength){round = 1;}Point Polygon1 = new Point(nLeft + round, nTop);Point Polygon2 = new Point(nRight - round + 1, nTop);Point Polygon3 = new Point(nLeft, nTop + round);Point Polygon4 = new Point(nRight + 1, nTop + round);Point Polygon5 = new Point(nLeft, nBottom - round);Point Polygon6 = new Point(nRight + 1, nBottom - round);Point Polygon7 = new Point(nLeft + round, nBottom + 1);Point Polygon8 = new Point(nRight - round, nBottom + 1);//四条主线(上下左右)currentGraphicObject.DrawLine(new System.Drawing.Pen(lineColor), Polygon1.X, Polygon1.Y, Polygon2.X, Polygon2.Y);currentGraphicObject.DrawLine(new System.Drawing.Pen(lineColor), Polygon7.X, Polygon7.Y, Polygon8.X, Polygon8.Y);currentGraphicObject.DrawLine(new System.Drawing.Pen(lineColor), Polygon3.X, Polygon3.Y, Polygon5.X, Polygon5.Y);currentGraphicObject.DrawLine(new System.Drawing.Pen(lineColor), Polygon4.X, Polygon4.Y, Polygon6.X, Polygon6.Y);//四个边角currentGraphicObject.DrawLine(new System.Drawing.Pen(lineColor), Polygon1.X, Polygon1.Y, Polygon3.X, Polygon3.Y);currentGraphicObject.DrawLine(new System.Drawing.Pen(lineColor), Polygon2.X, Polygon2.Y, Polygon4.X, Polygon4.Y);currentGraphicObject.DrawLine(new System.Drawing.Pen(lineColor), Polygon5.X, Polygon5.Y, Polygon7.X, Polygon7.Y);currentGraphicObject.DrawLine(new System.Drawing.Pen(lineColor), Polygon6.X, Polygon6.Y, Polygon8.X, Polygon8.Y);}/// /// 绘制一个圆角矩形./// /// 当前屏幕的图形对象/// 矩形线条的颜色/// 要绘制的矩形对象/// 圆角的半径长度public static void DrawRoundRect(System.Drawing.Graphics currentGraphicObject, Color lineColor, Rectangle rect, int round){DrawRoundRect(currentGraphicObject, lineColor, rect.Left, rect.Top, rect.Right, rect.Bottom, round);}/// /// 绘制一个圆角矩形./// /// 当前屏幕的图形对象/// 矩形线条的颜色/// 要绘制的矩形对象public static void DrawRoundRect(System.Drawing.Graphics currentGraphicObject, Color lineColor, Rectangle rect){DrawRoundRect(currentGraphicObject, lineColor, rect.Left, rect.Top, rect.Right, rect.Bottom, 2);}/// /// 填充一个圆角矩形./// /// 当前屏幕的图形对象/// 矩形线条的颜色/// 矩形左上角X坐标/// 矩形左上角Y坐标/// 矩形右下角X坐标/// 矩形右下角Y坐标/// 圆角的半径长度public static void FillRoundRect(System.Drawing.Graphics currentGraphicObject, Color fillColor, int nLeft, int nTop, int nRight, int nBottom, int round){if (round > MaxRoundRadius){round = MaxRoundRadius;}else if (round < 0){round = 0;}if (Math.Abs(nRight - nLeft) < MinBorderLength && Math.Abs(nBottom - nTop) < MinBorderLength){round = 1;}Point Polygon1 = new Point(nLeft + round, nTop);Point Polygon2 = new Point(nRight - round + 1, nTop);Point Polygon3 = new Point(nLeft, nTop + round);Point Polygon4 = new Point(nRight + 1, nTop + round);Point Polygon5 = new Point(nLeft, nBottom - round);Point Polygon6 = new Point(nRight + 1, nBottom - round);Point Polygon7 = new Point(nLeft + round, nBottom + 1);Point Polygon8 = new Point(nRight - round, nBottom + 1);currentGraphicObject.FillPolygon(new System.Drawing.SolidBrush(fillColor), new Point[]{   Polygon1,Polygon3,Polygon5,Polygon7,Polygon8,Polygon6,Polygon4,Polygon2});}/// /// 填充一个圆角矩形./// /// 当前屏幕的图形对象/// 矩形线条的颜色/// 要填充的矩形/// 填充区域针对矩形的缩进距离/// 圆角的半径长度public static void FillRoundRect(System.Drawing.Graphics currentGraphicObject, Color lineColor, Rectangle rect, int indentSize, int round){FillRoundRect(currentGraphicObject, lineColor, rect.Left + indentSize, rect.Top + indentSize, rect.Right - indentSize + 1, rect.Bottom - indentSize + 1, round);}/// /// 填充一个圆角矩形./// /// 当前屏幕的图形对象/// 矩形线条的颜色/// 要填充的矩形public static void FillRoundRect(System.Drawing.Graphics currentGraphicObject, Color lineColor, Rectangle rect){FillRoundRect(currentGraphicObject, lineColor, rect, 0, 2);}public static void FillRoundTitle(System.Drawing.Graphics currentGraphicObject, Color fillColor, int nLeft, int nTop, int nRight, int nBottom, int round,int Height){if (round > MaxRoundRadius){round = MaxRoundRadius;}else if (round < 0){round = 0;}if (Math.Abs(nRight - nLeft) < MinBorderLength && Math.Abs(nBottom - nTop) < MinBorderLength){round = 1;}Point Polygon1 = new Point(nLeft + round, nTop);Point Polygon2 = new Point(nRight - round + 1, nTop);Point Polygon3 = new Point(nLeft, nTop + round);Point Polygon4 = new Point(nRight + 1, nTop + round);Point Polygon5 = new Point(nLeft, nTop + Height);Point Polygon6 = new Point(nRight + 1, nTop + Height);currentGraphicObject.FillPolygon(new System.Drawing.SolidBrush(fillColor), new Point[]{   Polygon1,Polygon3,Polygon5,Polygon6,Polygon4,Polygon2});}public static void FillRoundTitle(System.Drawing.Graphics currentGraphicObject, Color lineColor, Rectangle rect, int indentSize, int round, int Height){FillRoundTitle(currentGraphicObject, lineColor, rect.Left + indentSize, rect.Top + indentSize, rect.Right - indentSize + 1, rect.Bottom - indentSize + 1, round, Height);}#endregion

转载于:https://www.cnblogs.com/zhangjianli/archive/2012/06/01/2530921.html

GDI 绘制圆角矩形相关推荐

  1. GDI+绘制圆角矩形

    1.最近,用到GDI+绘图,但是发现没有绘制圆角矩形的函数,故自己写了一个.下面贴出原理和代码,以作备份. 2.要绘制圆角矩形,基础是普通的直角矩形,需要做的就是将直角画成弧形. 3.绘制圆角矩形可以 ...

  2. 绘制圆角矩形(方法 )

    /* sharecodes.org 友情提醒:尊重知识,转载请注明原创作者.出处! */ /// <summary> /// C# GDI+ 绘制圆角矩形 /// </summary ...

  3. android绘制圆角矩形

    android中可以绘制圆角矩形. 1.利用画布cavas绘制 如果提供了一个方法可以在画布上绘制圆角矩形: 函数名称:public void drawRoundRect (RectF rect, f ...

  4. JavaScript 使用canvas绘制圆角矩形边框

    目录 分析 完整代码如下 前言 在react项目中需要用到绘制矩形填充, 因为直角矩形不够美观, 需要绘制圆角填充矩形 分析 Canvas并没有提供绘制圆角矩形的方法,但是通过观察,我们可以发现,其实 ...

  5. 微信小程序使用canvas绘制圆角矩形在Android:变形、锯齿

    这两天用小程序实现分享生成海报,那我的手机测的一直没问题,结果后来用同事的小米测发现:画的图形缺个角,锯齿形的,根据小程序社区回复:使用ctx.arc + ctx.lineTo就能避免Android错 ...

  6. canvas绘图,绘制圆角矩形。圆角线条。圆形头像

    //绘制圆角矩形 //x.x坐标,y,y轴坐标.width宽 height高  radius圆角(一定不能大于height的一半,否则不显示)   fillColor填充颜色.borderColor线 ...

  7. php 绘制圆角矩形,快速绘制圆角矩形的三种方法 - 行业动态 - 济南新视觉实训基地-平面UI设计PS培训,室内设计,web前端,影视3D动画后期制作培训...

    圆角矩形可谓是UI设计中,我们最常见到的元素之一了,通过圆角矩形工具去绘制的圆角过于普通,且略显呆板,缺少吸引力.今天新视觉实训就给大家分享三种绘制圆角矩形的方法,让我们在千篇一律的圆角矩形中找寻一些 ...

  8. 咸鱼菌CAD实战—绘制圆角矩形

    咸鱼菌CAD实战-绘制圆角矩形 设计中一般使用圆角使产品看起来更舒服一些,今天我们来绘制一个圆角矩形. 方法如下: 绘制矩形 使用快捷键F,进入倒圆角工具.或者在工具栏中选择倒圆角工具 按R键进入半径 ...

  9. 在Android中绘制圆角矩形图片

    圆角矩形图片在苹果的产品中很流行,相比于普通的矩形,很多人都喜欢圆角矩形的图片,下面在Android中实现将普通的矩形图片绘制成圆角矩形.        先来看一下普通矩形图片的显示,代码很简单,从r ...

最新文章

  1. RDKit | 化合物库的相似性分析
  2. 对软连接进行cp,rm
  3. Java并发编程:AbstractQueuedSynchronizer的内部结构
  4. java servlet上传centos服务器
  5. rails4 ajax 例子,Ajax和Rails 4:创建实例变量并更新视图而不刷新
  6. WSARecv() 函数使用解析
  7. windows键按了没反应_windows快捷键使用 - 小怜
  8. 如果我是一线技术主管…… 1
  9. Android AlarmManager实现不间断轮询服务
  10. 矿池如何给矿机下发任务
  11. 蓝桥杯 算法提高 全排列 next_pertumutation
  12. 盘点前端开发常用的几款编辑器
  13. 研发 | Unity资源商店里的免费资源,你一定要知道!
  14. linux 下载文件
  15. CNN应用之性别、年龄识别
  16. struct+Matlab向上向下取整+单位圆向量+matlab求导
  17. 1989-2015各国平均关税水平
  18. [日语]基于日语常用汉字表的音读到汉字的映射表
  19. 熊市赚取被动收入:质押NFT带来高达30%收益回报!
  20. 机器人学笔记之——操作臂逆运动学:代数解法和几何解法

热门文章

  1. Hutool Java 工具类库导出 Excel,超级简单!
  2. spring boot实战(第四篇)分散配置
  3. Redux 核心概念
  4. JSP页面中四种“返回按钮”的使用
  5. 在当前PJ项目pj_nath模块加入mysql的一些问题
  6. Android --- Android Device Monitor 在 3.0 版本之后废弃了怎么办
  7. 100页精华PPT,帮你彻底看懂5G!
  8. 查看防火墙状态_干货 | 华为防火墙配置,这篇文章强烈推荐收藏学习
  9. 2246xt u盘开卡详细教程_U盘制作PE及系统安装详细教程!
  10. node.js require 自动执行脚本 并生成html,利用node.js实现自动生成前端项目组件的方法详解...