⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arrow.cpp

📁 画一些简单的图元
💻 CPP
字号:
// Arrow.cpp: implementation of the CArrow class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
//#include "tpa.h"
#include "Arrow.h"
#include "math.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CArrow::CArrow()
{

}

CArrow::~CArrow()
{

}

BOOL CArrow::DrawArrow(CDC *pDC, PointPairs ptPairs)
{
	CPoint ptStart;
	CPoint ptEnd;
	ptStart = ptPairs.m_ptStart;
	ptEnd = ptPairs.m_ptEnd;
	DrawArrow(pDC,ptStart,ptEnd);
	
	return TRUE;
	
}

void  CArrow::DrawArrow(CDC *pDC,CPoint ptStart, CPoint ptEnd)
{
	double slopy, cosy , siny;
	double AL = 10.0 ;   //Arrow Length
	slopy = atan2((ptStart.y-ptEnd.y), (ptStart.x-ptEnd.x));
	cosy = cos(slopy);
	siny = sin(slopy);

	//draw a line between the 2 endpoint 
	pDC->MoveTo(ptStart);
	pDC->LineTo(ptEnd);

    //here is the tough part - actually drawing the arrows   
	//a total of 6 lines drawn to make the arrow shape   
    pDC->MoveTo(ptEnd);
	pDC->LineTo(ptEnd.x+ int( AL*cosy-(AL/2.0*siny)),
		        ptEnd.y+ int( AL*siny+(AL/2.0*cosy)) );
	pDC->LineTo(ptEnd.x+ int( AL*cosy+(AL/2.0*siny)),
		        ptEnd.y- int(-AL*siny+(AL/2.0*cosy)) );
	pDC->LineTo(ptEnd);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -