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
}
查看全文
相关阅读:
青瓷qici
青瓷qici
青瓷qici
青瓷引擎_珍膳小游戏_巧妇有好米来做煮
2013年12月30日 星期一 谷歌、百度地图拽取
不懂网络知识,测试工程师真的能走得很远么
测试和开发之间的博弈--没有硝烟的战争
docker命令每次需要sudo操作解决方案
Ubuntu 18.04安装Docker CE + NVIDIA-Docker
windos10下安装ubuntu18双系统
原文地址:https://www.cnblogs.com/warrior/p/1501826.html
最新文章
Java8新特性时间日期库DateTime API及示例
mysql if else count 计数
webmagic学习之路-3:采集安居客经纪人详情页
webmagic学习之路-2:采集安居客经纪人列表
webmagic学习之路-1:采集安居客列表页测试
mysql 如何清除sql缓存
Mysql EXPLAIN列的解释
mysql查看执行sql语句的记录日志
shell 中可以for 循环的时间加减日期格式
杀死 ps grep 出来的所有进程
热门文章
javascript 写状态模式
javascript 写农场迭代
javascript 写策略模式,商场收银打折优惠策略
javascript 老王开车去东北
javascript 写职责链
利用青瓷布局自定义加载的场景,而不是自己改写qici-loading
如何在Webstorm中添加js库 (青瓷H5游戏引擎)
青瓷qici
青瓷qici
青瓷qici
Copyright © 2011-2022 走看看