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正则表达式在线 其实是对(理论 ...
随机推荐
- Hack 【二分答案】
题意:给出n门课程,每一门课程考的分数,每一门课程的学分,求最多删去k组数据之后能够得到的最大加权平均数 先开一个数组x[],其中x[i]=1代表没有删除这门课程,x[i]=0表示删除了这门课程 然后 ...
- 格式化输出星期几 C#
string Today = DateTime.Now.ToString("yyyy-MM-dd dddd",new System.Globalization.CultureInf ...
- GenericRepository
public interface IGenericRepository<TEntity> where TEntity : class { IQueryable<TEntity> ...
- 嵌入式 hi3518x平台h264+g711a封装mp4代码demo
先看代码吧,有代码有真相,具体代码的demo(下载demo的朋友请勿在网上上传我的demo,谢谢)下载连接为: http://download.csdn.net/detail/skdkjxy/8071 ...
- C#实现不安装Oracle客户端访问远程服务器数据!!
概述: C#通过使用ADO的方式在未安装Oracle数据库的前提下,客户端程序远程访问服务器,会出现:“System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或 ...
- 开源Math.NET基础数学类库使用(11)C#计算相关系数
阅读目录 前言 1.Math.NET计算相关系数的类 2.Correlation的实现 3.使用案例 4.资源 本博客所有文章分类的总目录:[总目录]本博客博文总目录-实 ...
- LR之录制SQL脚本
1.选择协议 ①MS SQL serve ②ODBC 一般情况下选ODBC 2.录制步骤
- python2.7系列安装失败的办法
在windows系统上安装python时出现"there is a problem with your Windows installer package. A program run as ...
- Spring依赖注入 --- 简单使用说明
Spring依赖注入 --- 简单使用说明 本文将对spring依赖注入的使用做简单的说明,enjoy your time! 1.使用Spring提供的依赖注入 对spring依赖注入的实现方法感兴趣 ...
- JSON 教程学习进度备忘
书签:跳过:另外跳过的内容有待跟进 __________________ 学习资源:W3School. _________________ 跳过的内容: 1. ______________ 知识点:1 ...