试用蓝奏云盘分享代码笔记及demo效果

蓝奏盘的下载速度很快,而且可以在浏览器下载,这点很不错。
这里就把以前用QPainter绘制螺线的Qt代码,Qt的是PC端的,Android上以前也画过螺旋线,编译成的apk放在蓝奏盘上。
我用蓝奏浏览器分享了[qtcurve], 下载链接:
https://wwp.lanzoup.com/i8CT111p3dqf
提取码 : 4iir, 你可以不限速下载哦!
代码

#include <QApplication>
#include <QLabel>
#include <QWidget>
#include <QPainter>

#define _USE_MATH_DEFINES
#include <math.h>

int w=640;
int h=480;

struct vec2d
{
	double x;
	double y;
};

vec2d rsi2xy(double r, double si)
{
	vec2d p;
	double s=si *M_PI/180.0;
	p.x = r*cos(s);
	p.y = r*sin(s);
	return p;
}

double agmd(double si)
{
	return 80.0+0.1*si;
}
 
class GrphWidget : public QWidget
{
    //Q_OBJECT
 
public:
    GrphWidget(QWidget *parent = 0):
    QWidget(parent)
    {
    }
    ~GrphWidget()
    {}
 
    void paintEvent(QPaintEvent* event)
    {
    	int w =this->width();
    	int h = this->height();
    	
        QPainter p(this);
        p.setRenderHint(QPainter::Antialiasing);
    	 
	    // draw axis
	    p.setPen(QPen(Qt::black, 3));
        p.drawLine( 0,h/2,w, h/2   );
        p.drawLine( w/2,0,w/2, h  );
	 
	    
	    // draw helix r= r0+a*si
	    p.setPen(QPen(Qt::blue, 5));
	    double cx=w/2;
	    double cy=h/2;
	    double si = 0.0;
	    double dsi=2.0;
	    double simax=360.0*10+1.0;
	    double r=agmd(si);
	    vec2d  p0=rsi2xy(r,si);
	    si+=dsi;
	    while(si<simax)
	    {
	    	  double r=agmd(si);
	          vec2d  p1=rsi2xy(r,si);
	          p.drawLine(p0.x+cx,cy-p0.y,p1.x+cx,cy-p1.y);
	          p0=p1;
	          si+=dsi;
	    };
    	
        p.end();
    }
 
private:

};

 
int main(int argc, char* argv[]) {
    QApplication app(argc, argv);    
   
    GrphWidget* wgt=new GrphWidget;
    wgt->show();
    return app.exec();
}