用 GDI+ 画 Chord
来源:互联网 发布:求三唑仑淘宝上输什么 编辑:程序博客网 时间:2024/05/23 02:19
GDI+并没有提供GDI中的Chord函数(其它的还有RoundRect函数,可参考BobPowell 的这篇文章),只好自己动手了:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
BOOL
GDIplusChord(
HDC
hDC,
INT
x1,
INT
y1,
INT
x2,
INT
y2,
INT
x3,
INT
y3,
INT
x4,
INT
y4 )
{
Graphics graphics(hDC);
CRect rectBound(x1, y1, x2, y2);
rectBound.NormalizeRect();
Rect ellipseRect(rectBound.left, rectBound.top, rectBound.Width(), rectBound.Height());
////////////////////////////////////////////////////////////////////////////////
// For testing only.
BYTE
byAlpha = 200;
SolidBrush fillBrush(Color(byAlpha, 0, 0, 255));
Pen redPen(Color(byAlpha, 255, 0, 0), 3);
////////////////////////////////////////////////////////////////////////////////
Status ret = InvalidParameter;
if
( x3 == x4 && y3 == y4 )
{
// If the starting point and ending point of the curve are the same, a complete ellipse should be drawn.
ret = graphics.FillEllipse(&fillBrush, ellipseRect);
ret = graphics.DrawEllipse(&redPen, ellipseRect);
return
Gdiplus::Ok == ret;
}
CPoint ptCenter(rectBound.CenterPoint());
#define PI 3.1415926
REAL startAngle =
atan2
(y3-ptCenter.y, x3-ptCenter.x ) * 180.0f / PI;
REAL sweepAngle = (
atan2
(y4-ptCenter.y, x4-ptCenter.x ) * 180.0f / PI) - startAngle - 360.0f;
if
( sweepAngle < -360.0f )
sweepAngle += 360.0f;
GraphicsPath path;
path.StartFigure();
path.AddArc(ellipseRect, startAngle, sweepAngle);
path.CloseFigure();
ret = graphics.FillPath(&fillBrush, &path);
ret = graphics.DrawPath(&redPen, &path);
return
Gdiplus::Ok == ret;
}
转自:http://www.cnblogs.com/yonken/archive/2010/05/06/Implement_Chord_Function_Using_GDIplus.html
- 用 GDI+ 画 Chord
- 用GDI+画长方体
- 用C# GDI+画太极图
- Chord协议
- Chord原理
- Chord算法
- Chord算法
- Chord算法
- Chord算法
- Chord算法
- Chord算法
- Chord算法
- 本人用GDI+写的一个盒装图片(用GDI+画变形图)
- GDI/GDI+ 在图像上画直线
- 20080904 chord项目日志
- Chord阅读报告
- Chord算法(原理)
- P2P中的Chord算法
- Jquery 获取焦点,和失去焦点
- C++中的time类(摘抄)
- ExtJs之combobox详解
- oracle事务隔离级别
- jsp基础教程清华版源代码
- 用 GDI+ 画 Chord
- 五险一金。。。终于懂了
- Jquery 和JS获得文体
- USB Core 四
- 1.常用javascript 方法
- 进程
- 2012年度十大优秀免费云空间推荐
- sql 2005 日期时间 数据类型
- centos 配置nginx php-fpm mysql 环境步骤