资源简介
基于qt5.8写的一个贝塞尔曲线
qt5.8工程源码
直接打开编译,不是网上转的,是自己写的,里面有注释
贝塞尔曲线的t系数是0.5
C++写贝塞尔曲线,可以在任意平台编译,可移植的贝塞尔曲线
贝塞尔曲线例子
Bezier demo
bezier curve writen by qt5.8
qt5.8 project of bezier, you can open the pro file and compile the project directly
it is fully test and reliable.
this bezier curve's t factor is 0.5f
C++ coede of bezier, cross platfor

代码片段和文件信息
#include “beziercruve.h“
BezierCruve::BezierCruve(Qobject *parent) : Qobject(parent)
maxDotQty(0)
dotQty(0)
dotInterval(1)
{
cruveDots.clear();
dotQty = 0;
dotInterval = 1;
}
void BezierCruve::bezier_draw_cruve(MY_POINT *pInPoints)
{
if (dotQty <= 0) return;//point qty invalide;
if((pInPoints[dotQty].x < pInPoints[0].x+dotInterval) && (pInPoints[dotQty].x > pInPoints[0].x-dotInterval)
&& (pInPoints[dotQty].y < pInPoints[0].y+dotInterval) && (pInPoints[dotQty].y > pInPoints[0].y-dotInterval))//如果第一点的xy坐标和第n点的不重合,不是一个点
{
//pDC->SetPixel(pInPoints[0].x pInPoints[0].y RGB(255000));//0x0000ff,这里的每一个点都是贝塞尔曲线,pInPoints[0],每次递归之后,拍p[0]会接近最后一点p[dotQty]
cruveDots.append(pInPoints[0]);
return;
}
MY_POINT *p1;
p1 = new MY_POINT[dotQty+1];
int i j;
p1[0] = pInPoints[0];
for(i=1; i<=dotQty; i++)//第1点到第n点,可以遍历n-1次
{
for(j=0; j<=dotQty-i;j++)//从第0点到n-i,意识是每画一点之后,j可以遍历少一点
{
//pDC->MoveTo(pInPoints[j].x pInPoints[j].y);
//pDC->LineTo(pInPoints[j+1].x pInPoints[j+1].y);
pInPoints[j].x = (pInPoints[j].x + pInPoints[j+1].x)/2.0f;//取得x之间的中点
pInPoints[j].y = (pInPoints[j].y + pInPoints[j+1].y)/2.0f;//取得每相邻的y点之间的中点
//pDC->SetPixel(pInPoints[i].x pInPoints[i].y RGB(25500));
//pDC->Rectangle(pInPoints[j].x - 2 pInPoints[j].y -2 pInPoints[j].x + 2 pInPoints[j].y + 2);
//Sleep(2000);
}//执行完毕,pInPoints[j]变成两个线之间的中点
p1[i] = pInPoints[0];
}//每次i和j一起,历遍到没点连线的最后一个中点
bezier_draw_cruve(pInPoints);
bezier_draw_cruve(p1);
delete p1;
//emit cruveDots;//发送信号和数据不可以在递归里面发生,否则多次发送
}
void BezierCruve::bezier_set_point_interval(qint32 pix)
{
dotInterval = pix;
}
void BezierCruve::bezier_set_dot_qty(qint32 dot)
{
dotQty = dot;
}
void BezierCruve::bezier_set_max_dot_qty(qint32 maxDot)
{
maxDotQty = maxDot;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-09-06 09:00 BezierCruve\
文件 2361 2017-09-05 21:04 BezierCruve\beziercruve.cpp
文件 662 2017-09-03 17:07 BezierCruve\beziercruve.h
文件 1132 2017-09-03 17:05 BezierCruve\BezierCruve.pro
文件 23835 2017-09-05 22:17 BezierCruve\BezierCruve.pro.user
文件 171 2017-09-05 20:57 BezierCruve\commondata.h
文件 885 2017-09-05 21:33 BezierCruve\main.cpp
文件 3437 2017-09-05 22:16 BezierCruve\mainwindow.cpp
文件 931 2017-09-05 22:09 BezierCruve\mainwindow.h
文件 1177 2017-09-05 21:42 BezierCruve\mainwindow.ui
文件 2293 2017-09-05 22:08 BezierCruve\renderarea.cpp
文件 2173 2017-09-03 21:53 BezierCruve\renderarea.cpp.fD7112
文件 1175 2017-09-05 22:11 BezierCruve\renderarea.h
相关资源
- DSDEMO-C演示(数据结构C语言版 严蔚敏
- QT5开发及源代码
- QT Hisi demo
- Qt5串口通信-windows
- 物联网GPS跟踪器demo程序
- Qt TCP聊天室demo
- 期货交易的C++简易demo
- MFC绘制Bezier曲线B样条曲线曲线拟合
- C#神思二代身份证读卡程序 demo
- C++ log4cplus Demo
- RSA算法纯C语言代码实现,带测试dem
- QT5.9_c++开发指南——随书[源码]
- 明华读卡器操作Demo
- Spline曲线(穿过控制点CC++版本)
- VC6.0_MFC画图demo小程序源码
- DemoHttpMFC.zip
- KCFC++demo代码
- MongoDB C/C++开发使用案例Demo
- c++QT5图形学-中点画圆完整工程文件
- C++_WebService_Demon
- FlyBird游戏模仿OC版
- MFC_跑酷游戏小Demo
- Coons曲面与hermite、bezier、B样条曲线标
- 图形学各种曲线--Bezier曲线,B-样条曲
- 基于qt5.6与echarts配合打造最强图表库
- 基于QT5.6编写Echart动态交互仪表盘-修
- 基于Cocos2dx + box2d 实现的愤怒的小鸟
- Duilib在MFC、WTL中的使用方法(Demo)
- C++实现多语言程序Demo
- Bezier曲线曲面算法实现代码
评论
共有 条评论