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
}
查看全文
相关阅读:
指定盘符获取u盘PID、VID、序列号等信息
禁用u盘再启用
golang 使用编译选项-H=windowsgui后,仍然输出log到console
c#实现"扫描检测硬件改动"
哈希表
Python 环境搭建
Python 简介
Python 基础教程
7.1.2 定义改进的Sales_date类
第七章 类
原文地址:https://www.cnblogs.com/warrior/p/1501826.html
最新文章
SQL2005四个排名函数(row_number、rank、dense_rank和ntile)的比较
Redis 集群方案
Android SDK Manager国内更新代理
AndroidDevTools简介
winform listview美化
winform 无边框应用程序
c# datagridview笔记
sqlite3开源加密方案-wxsqlite3
sqlite3 select语句将blob数据用16进制字符串展示
CentOS 6 时间错误导致无法开机
热门文章
winapi获取网络文件大小
winform richtextbox显示图片
c++以16进制输出字符串
获取当天时间戳
windows10多出几个显示器解决方法
c#查看本机网络端口和对应的程序名
golang开启随机端口并获取端口
golang调用CertUtil获取文件md5
树莓派3b安装Windows10 Arm
IOCTL_DISK_GET_DRIVE_GEOMETRY
Copyright © 2011-2022 走看看