资源简介
c++ code for drawing arrows in any CDC
代码片段和文件信息
#include “Arrow.h“
#include
// ArrowTo()
//
void ArrowTo(HDC hDC int x int y ARROWSTRUCT *pA) {
POINT ptTo = {x y};
ArrowTo(hDC &ptTo pA);
}
// ArrowTo()
//
void ArrowTo(HDC hDC const POINT *lpTo ARROWSTRUCT *pA) {
POINT pFrom;
POINT pbase;
POINT aptPoly[3];
float vecLine[2];
float vecLeft[2];
float fLength;
float th;
float ta;
// get from point
MoveToEx(hDC 0 0 &pFrom);
// set to point
aptPoly[0].x = lpTo->x;
aptPoly[0].y = lpTo->y;
// build the line vector
vecLine[0] = (float) aptPoly[0].x - pFrom.x;
vecLine[1] = (float) aptPoly[0].y - pFrom.y;
// build the arrow base vector - normal to the line
vecLeft[0] = -vecLine[1];
vecLeft[1] = vecLine[0];
// setup length parameters
fLength = (float) sqrt(vecLine[0] * vecLine[0] + vecLine[1] * vecLine[1]);
th = pA->nWidth / (2.0f * fLength);
ta = pA->nWidth / (2.0f * (tanf(pA->fTheta) / 2.0f) * fLength);
// find the base of the arrow
pbase.x = (int) (aptPoly[0].x + -ta * vecLine[0]);
pbase.y = (int) (aptPoly[0].y + -ta * vecLine[1]);
// build the points on the sides of the arrow
aptPoly[1].x = (int) (pbase.x + th * vecLeft[0]);
aptPoly[1].y = (int) (pbase.y + th * vecLeft[1]);
aptPoly[2].x = (int) (pbase.x + -th * vecLeft[0]);
aptPoly[2].y = (int) (pbase.y + -th * vecLeft[1]);
MoveToEx(hDC pFrom.x pFrom.y NULL);
// draw we‘re fillin‘...
if(pA->bFill) {
LineTo(hDC aptPoly[0].x aptPoly[0].y);
Polygon(hDC aptPoly 3);
}
// ... or even jes chillin‘...
else {
LineTo(hDC pbase.x pbase.y);
LineTo(hDC aptPoly[1].x aptPoly[1].y);
LineTo(hDC aptPoly[0].x aptPoly[0].y);
LineTo(hDC aptPoly[2].x aptPoly[2].y);
LineTo(hDC pbase.x pbase.y);
MoveToEx(hDC aptPoly[0].x aptPoly[0].y NULL);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1831 2002-12-01 14:29 Arrow.cpp
文件 743 2002-12-01 14:28 Arrow.h
文件 3726 2002-12-01 12:59 ArrowTest.cpp
文件 4664 2002-12-01 14:26 ArrowTest.dsp
文件 541 2002-12-01 12:59 ArrowTest.dsw
文件 1400 2002-12-01 12:59 ArrowTest.h
文件 8739 2002-12-01 12:59 ArrowTest.rc
文件 1721 2002-12-01 14:29 ChildView.cpp
文件 1267 2002-12-01 12:59 ChildView.h
文件 3286 2002-12-01 12:59 MainFrm.cpp
文件 1744 2002-12-01 12:59 MainFrm.h
目录 0 2002-12-01 12:59 res\
文件 1078 2002-12-01 12:59 res\ArrowTest.ico
文件 401 2002-12-01 12:59 res\ArrowTest.rc2
文件 718 2002-12-01 12:59 res\Toolbar.bmp
文件 497 2002-12-01 12:59 Resource.h
文件 211 2002-12-01 12:59 StdAfx.cpp
文件 1054 2002-12-01 12:59 StdAfx.h
- 上一篇:Kinect2.0+PCL实现点云显示
- 下一篇:地球仪纹理型纹理贴图 C++代码
相关资源
- 地球仪纹理型纹理贴图 C++代码
- C_C++中的正则表达式库(三)——PC
- adaboost算法源码c++
- c++基础封装线程、锁、定时器、原子
- MD5 碰撞生成器 C++源码
- ini文件读取源代码
- c++实现找出数组最大值函数
- c++写的库存管理程序
- c++类型长度查看方式
- c++使用vector统计字符串中单词出现的
- c++11多线程编程
- c++11互斥库mutex的使用
- c++11原子库
- 谭浩强c++课本第一章习题答案源码
- 模糊控制C++测试代码
- c++builder QQ登录界面源码
- 走迷宫程序C++
- c++读写BMP JPG 和png 的图像文件linux
- 设计模式之委托模式的demo
- c++函数指针使用demo
- c++11 bind库使用
- 面向对象的编程技术课程设计VC++_MF
- 基于VC++的PC机实现与429通信板的数据
- blender2.8.3c++源码工程打包10G.zip
- Qt5Twain.rar
- 分治策略算法设计寻找最邻近点对c
- C/C++实现FAT文件系统的读写
- C++制作加密解密系统
- C++实现回归算法(逻辑回归 线性回归
- Htran 0.22源码 c++
评论
共有 条评论