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
}
查看全文
相关阅读:
简单家庭记账本app开发进度四
简单家庭记账本app开发进度三
简单家庭记账本app开发进度二
构建之法阅读笔记一
寒假学习进度七
简单家庭记账本app开发进度一
【Java每日一题】20170328
【Java每日一题】20170327
【Java每日一题】20170324
【Java每日一题】20170323
原文地址:https://www.cnblogs.com/warrior/p/1501826.html
最新文章
API网关服务Zuul-Spring Cloud学习第五天(非原创)
Feign详细使用-Spring Cloud学习第四天(非原创)
断路器Hystrix与Turbine集群监控-Spring Cloud学习第三天(非原创)
搭建服务与负载均衡的客户端-Spring Cloud学习第二天(非原创)
搭建高可用服务注册中心-Spring Cloud学习第一天(非原创)
Spring Cloud与Duddo比较(非原创)
CentOS 编译安装 PyCrypto
python3的pip3安装
Docke-ce 安装
centos 7 安装pip和pip3
热门文章
easy_install和pip的安装及使用
Centos中Python升级为3.X时yum出现except OSError, e: ^ SyntaxError: invalid syntax问题 No module named 'pip._internal.main
Centos7 Python2 升级到Python3
Ansible Tower 3.5.1 平台部署和破解
Ansible-Tower使用文档
sublime 下载 和 破解
返回一个整数数组中最大子数组的和
javascript学习笔记
简单家庭记账本app开发进度六
简单家庭记账本app开发进度五
Copyright © 2011-2022 走看看