MFC中实现的画箭头算法(ArrowinMFC)

来源:计算机等级考试    发布时间:2012-08-29    计算机等级考试视频    评论

  在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;

上一页123下一页

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答