设为首页 加入收藏

TOP

MFC中实现的画箭头算法(ArrowinMFC)
2014-11-05 12:45:07 】 浏览:243
Tags:MFC 实现 箭头 算法 ArrowinMFC

  在codeproject中寻找到一个这样的算法,在这里介绍一下


  可以改变三角形大小,顶点角度,是否填充和填充颜色等


  但是画出的箭头还是不够美观....呵呵,还好吧


  其中填充是代表箭头内是否填充颜色


  先来看声明和实现


  //使用一个结构体来存储相关的信息


  //Defines the attributes of an arrow.


  typedef struct tARROWSTRUCT {


  int nWidth; // width (in pixels) of the full base of the arrowhead


  float fTheta; // angle (in radians) at the arrow tip between the two


  // sides of the arrowhead


  bool bFill; // flag indicating whether or not the arrowhead should be


  // filled


  } ARROWSTRUCT;


  ///////////////////////


  //函数声明


  // Draws an arrow, using the current pen and brush, from the current position


  // to the passed point using the attributes defined in the ARROWSTRUCT.


  void ArrowTo(HDC hDC, int x, int y, ARROWSTRUCT *pArrow);


  void ArrowTo(HDC hDC, const POINT *lpTo, ARROWSTRUCT *pArrow);


  ///////////////////////


  //画箭头函数实现


  void CMyDialog::ArrowTo(HDC hDC, int x, int y, ARROWSTRUCT *pA) {


  POINT ptTo = {x, y};


  ArrowTo(hDC, &ptTo, pA);


  }


  void CMyDialog::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;


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇tsockopt()函数 下一篇在MFC程序中启用XP新控件外观

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目