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;
}
}
}
C# JackLib系列之GdiHelper圆角矩形的快速生成的更多相关文章
- 解读Unity中的CG编写Shader系列四(unity中的圆角矩形shader)
转自 http://www.itnose.net/detail/6097625.html 上篇文章中我们掌握了表面剔除和剪裁模式 这篇文章将利用这些知识实现一个简单的,但是又很常用的例子:把一张图片做 ...
- 解读Unity中的CG编写Shader系列4——unity中的圆角矩形shader
上篇文章中我们掌握了表面剔除和剪裁模式 这篇文章将利用这些知识实现一个简单的,可是又非经常常使用的样例:把一张图片做成圆角矩形 例3:圆角矩形Shader 好吧我承认在做这个样例的时候走了不少弯路,因 ...
- [转]解读Unity中的CG编写Shader系列4——unity中的圆角矩形shader
上篇文章中我们掌握了表面剔除和剪裁模式这篇文章将利用这些知识实现一个简单的,但是又很常用的例子:把一张图片做成圆角矩形 例3:圆角矩形Shader好吧我承认在做这个例子的时候走了不少弯路,由于本人对矩 ...
- [BOT] 一种android中实现“圆角矩形”的方法
内容简介 文章介绍ImageView(方法也可以应用到其它View)圆角矩形(包括圆形)的一种实现方式,四个角可以分别指定为圆角.思路是利用"Xfermode + Path"来进行 ...
- 用贝赛尔曲线把图片, 按钮, label 绘成圆 或圆角矩形
//创建圆形遮罩,把用户头像变成圆形 /* *CGPointMake(35, 35) 是绘图的中心点, 如果想把控件居中绘圆, 一般用控件的中心点, radius 是圆半径 startAn ...
- RoundedImageView,实现圆形、圆角矩形的注意事项
RoundedImageView是gitHub上面的一个开源组件(https://github.com/vinc3m1/RoundedImageView),实现一些圆形或者圆角矩形是很方便的, < ...
- swift UIImage加载远程图片和圆角矩形
UIImage这个对象是swift中的图像类,可以使用UIImageView加载显示到View上. 以下是UIImage的构造函数: init(named name: String!) -> U ...
- iOS设置圆角矩形和阴影效果
1.设置圆角矩形 //设置dropview属性 _dropView.backgroundColor=[[UIColor whiteColor] colorWithAlphaComponent:0.8] ...
- 如何在html中做圆角矩形和 只有右边的"分隔线"
这个网站满好的,可以常看看 css-matic中有几个很好的写css可视化的工具 其实做css 版式布局等都可以有工具的 推荐40个优秀的免费CSS工具 debugger正则表达式在线 其实是对(理论 ...
随机推荐
- Mysql使用大全
#登录数据库 mysql -hlocalhost -uroot -p; #修改密码 mysqladmin -uroot -pold password new; #显示数据库 show database ...
- html常用笔记
<?php //CSS可以对文本格式进行精确的控制 //HTML标记更有利于搜索引擎 //一.标签 <br> <p>//换行后插入一个空行,单字节不换行,双字节自动换行 ...
- 【转】Eclipse编辑shell的插件(shellEd)
原文网址:http://blog.sina.com.cn/s/blog_a42d507e01019mlp.html Eclipse官方网站:http://download.eclipse.org/ 1 ...
- Android Window 9问9答
1.简述一下window是什么?在android体系里 扮演什么角色? 答:window就是一个抽象类,他的实现类是phoneWindow.我们一般通过windowManager 来访问window. ...
- RequireJS 2.0 正式发布(转)
RequireJS发布了一个大版本,直接从version1.0.8升级到了2.0.随后的几小时James Burke又迅速的将版本调整为2.0.1,当然其配套的打包压缩工具r.js也同时升级到了2.0 ...
- Groovy读取properties及txt
昨晚帮老同事解决了一个SoapUI的代码问题,好长时间没用SoapUI,好多东西都忘了,今天先总结下Groovy读取properties 首先吐槽下SoapUI的apidocs,我几乎从中看不出什么东 ...
- python27+django创建app
python manage.py startapp polls创建一个叫polls的app 编辑文件 polls/models.py : 1 from django.db import models ...
- Quartz使用总结
废话的前言 以前凭借年轻,凡事都靠脑记.现在工作几年后发现,很多以前看过.用过的东西,再次拿起的时候总觉得记不牢靠."好记性不如烂笔头"应该是某位上了年纪的大叔的切肤之痛(仅次于上 ...
- Matlab命令——目录操作(windows&Linux)
Matlab命令——目录操作(windows&Linux) 1. filesep用于返回当前平台的目录分隔符,Windows是反斜杠(\),Linux是斜杠(/).有时此命令结合ispc命令使 ...
- 多线程的Python 教程--“贪吃蛇”
本指南的里代码可以在这里下载: threadworms.py ,或者从 GitHub.代码需要 Python 3 或 Python 2 ,同时也需要安装 Pygame . 点击查看大版本图片 ...