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
}
查看全文
相关阅读:
飘逸的python
hdu 4512 吉哥系列故事——完美队形I(最长公共上升自序加强版)
Codeforces 482B. Interesting Array 线段树
《开源框架那些事儿21》:巧借力与借巧力
openNebula libvirt-virsh attach disk device for kvm
configure mount nfs
opennebula kvm attach disk
openNebula 运维系列虚拟机virtual machines operations
yum subversion puppet puppet-server
文件系统,快存储,对象存储
原文地址:https://www.cnblogs.com/warrior/p/1501826.html
最新文章
[Node.js] Node Util Promisify
[Angular] Implement a custom form component by using control value accessor
[React] Create component variations in React with styled-components and "extend"
[React] Animate your user interface in React with styled-components and "keyframes"
[Angular] Update FormArray with patchValue
再探java基础——throw与throws
Android apk逆向实战
PHP 自学之路-----XML编程(Xpath技术,simpleXml技术)基础入门
2013 我的暑期生活
JAX-RS
热门文章
ORA-00845 Oracle 启不来修改 MEMORY_TARGET
poj 3150 Cellular Automaton
CSS样式优先级
JAVA排序(二) Comparator接口
Hadoop之——分布式集群安装过程简化版
osx中Grapher的使用
eCos系统无法正确链接到在C++源文件里自己定义的cyg_user_start函数的问题和解决的方法
《Java程序猿面试笔试宝典》之volatile有什么作用
配置文件总结(机房重构知识点总结)
CodeForces 388A Fox and Box Accumulation (模拟)
Copyright © 2011-2022 走看看