zoukankan
html css js c++ java
绘制圆角矩形和八角形
Code
1
class
Figure
2
{
3
/**/
///
<summary>
4
///
画一个圆角矩形
5
///
</summary>
6
///
<param name="x">
矩形左上角X
</param>
7
///
<param name="y">
矩形右上角Y
</param>
8
///
<param name="width">
矩形宽
</param>
9
///
<param name="height">
矩形高
</param>
10
///
<param name="arc">
弧度的矩形宽度,arc
<0时,则等于矩形宽或者高最短者的1/2</param>
11
///
<returns></returns>
12
public
GraphicsPath RoundRectangle(
int
x,
int
y,
int
width,
int
height,
int
arc)
13
{
14
if
(arc
<
0
)
15
{
16
if
(width
<
height)
17
arc
=
width
/
2
;
18
else
19
arc
=
height
/
2
;
20
}
21
22
GraphicsPath gPath
=
new
GraphicsPath();
23
gPath.AddArc(x, y, arc, arc,
180
,
90
);
24
gPath.AddArc(width
-
arc, y, arc, arc,
270
,
90
);
25
gPath.AddArc(width
-
arc, height
-
arc, arc, arc,
0
,
90
);
26
gPath.AddArc(x, height
-
arc, arc, arc,
90
,
90
);
27
gPath.CloseAllFigures();
28
return
gPath;
29
}
30
31
/**/
///
<summary>
32
///
画一个圆角矩形
33
///
</summary>
34
///
<param name="rect">
矩形
</param>
35
///
<param name="arc">
弧度的矩形宽度,arc
< 0时,则等于矩形宽或者高最短者的1/2</param>
36
///
<returns></returns>
37
public
GraphicsPath RoundRectangle(Rectangle rect,
int
arc)
38
{
39
return
RoundRectangle(rect.X, rect.Y, rect.Width, rect.Height, arc);
40
}
41
42
/**/
///
<summary>
43
///
根据矩形在矩形内绘制八角形
44
///
</summary>
45
///
<param name="x">
矩形左上角X
</param>
46
///
<param name="y">
矩形右上角Y
</param>
47
///
<param name="width">
矩形宽
</param>
48
///
<param name="height">
矩形高
</param>
49
///
<returns></returns>
50
public
GraphicsPath Octagon(
int
x,
int
y,
int
width,
int
height)
51
{
52
GraphicsPath gPath
=
new
GraphicsPath();
53
gPath.AddLine(x, height
/
4
, width
/
4
, y);
54
gPath.AddLine(width
-
width
/
4
, y, width, height
/
4
);
55
gPath.AddLine(width, height
-
height
/
4
, width
-
width
/
4
, height);
56
gPath.AddLine(width
/
4
, height, x, height
-
height
/
4
);
57
58
gPath.CloseAllFigures();
59
60
return
gPath;
61
}
62
63
/**/
///
<summary>
64
///
根据矩形在矩形内绘制八角形
65
///
</summary>
66
///
<param name="rect">
矩形
</param>
67
///
<returns></returns>
68
public
GraphicsPath Octagon(Rectangle rect)
69
{
70
return
Octagon(rect.X, rect.Y, rect.Width, rect.Height);
71
}
72
}
查看全文
相关阅读:
Mysql常见索引介绍
Mysql字段修饰符(约束)
使用select和show命令查看mysql数据库系统信息
Mysql5.7数据库介绍
对Mysql数据表本身进行操作
各种修改Mysql字符集
Mysql的安全配置向导命令mysql_secure_installation
firewalld介绍
CentOS7使用yum安装mysql5.7
利用ASP.NET一般处理程序动态生成Web图像(转)
原文地址:https://www.cnblogs.com/warrior/p/1501826.html
最新文章
ECharts上手例子
win7 64位下redis的安装
SpringBoot执行定时任务
Windows7下安装redmine-3.4.6
Spring Boot 2 入门
activiti 5.13流程图连线名称不显示bug修复
Tomcat和weblogic虚拟路径的配置
Activit工作流学习例子
WebLogic调用WebService提示Failed to localize、Failed to create WsdlDefinitionFeature
[转]Comparing sFlow and NetFlow in a vSwitch
热门文章
[转]Rapidly detecting large flows, sFlow vs. NetFlow/IPFIX
Openvswitch手册(2): OpenFlow Controller
Openvswitch手册(1): 架构,SSL, Manager, Bridge
[转] An Introduction to Mutual SSL Authentication
[转]深入理解 GRE tunnel
OpenFlow学习笔记
如何让 Git 使用 HTTP 代理服务器
[转]SDN与OpenFlow技术简介
[转]OpenContrail 体系架构文档
Mysql视图介绍
Copyright © 2011-2022 走看看