当前位置: 首页 > news >正文

揭阳网站制作托管做一款app需要多少钱

揭阳网站制作托管,做一款app需要多少钱,建设部网站令第77号,网站设计seo1.窗口自己的 paint事件 使用QPainter 2.使用gif.h 生成 gif 3.处理原始图像RGBA数据 4.动画代码实现就是曲线函数,三角函数,x,y坐标位置变化,然后更新显示 5.注意窗口 x,y轴 横是 x ,竖是 y,向…
1.窗口自己的 paint事件 使用QPainter
2.使用gif.h 生成 gif
3.处理原始图像RGBA数据
4.动画代码实现就是曲线函数,三角函数,x,y坐标位置变化,然后更新显示
5.注意窗口 x,y轴 横是 x ,竖是 y,向下为正,向右为正!
6.坐标和函数方程带入计算,图形轨迹没问题,不会溢出。

//黄色小球运动就是 x,y轴使用三角函数,来回运行,
//三角函数无论多大的数都会转化到 -1~1之间for (int i = 0; i < 1000; i++) {auto f = new Food(nextRandom(800),nextRandom(600),10,10,":/pic/bean.png");foods.push_back(f);f->mf.initialParams.push(nextRandom(30));f->mf.initialParams.push(nextRandom(10));f->mf.initialParams.push(nextRandom(30));f->mf.initialParams.push(nextRandom(10));f->mf.initialParams.push(nextRandom(60));f->mf.f = [f, d]() {static double t = 0;double A = f->mf.initialParams[0];double w = f->mf.initialParams[1];double q = f->mf.initialParams[2];double a = f->mf.initialParams[3];auto freq = f->mf.initialParams[4];f->ry() = f->rOriginY() +A*qCos(2*M_PI*w*freq*t+q)+a;f->rx() = f->rOriginX()+nextRandom(30)*qSin(2*M_PI*nextRandom(12)*freq*t+nextRandom(30))+nextRandom(10);t += d;};}

 

//定时器 每隔一段时间 计算 小球的位置,然后 发送更新请求 窗口,窗口刷新显示connect(&heroTimer, &QTimer::timeout, [this, getRgbData, getImgData2]() {//        static double angle = 20;//        int a = 100;//        int x = a*qPow(qCos(qDegreesToRadians(angle)),3) + 300;//        int y = a*qPow(qSin(qDegreesToRadians(angle)),3) + 300;//        hero->setPos(x,y);//        angle += 5;for(auto &food:foods){food->mf.f();//            qDebug() << food->rx() << "," << food->ry();}update();if (frames > fIdx) {g.GifWriteFrame(&writer,//                            grab().toImage().convertToFormat(QImage::Format_ARGB32).bits(),//getRgbData(//  grab().toImage()), //必须要自己转化下to data原始数据,img的bits()接口数据有问题getImgData2(grab().toImage()), //Ok//grab().toImage().bits(),//blue ? what's wrong?width(),height(),2);fIdx++;} else {g.GifEnd(&writer);if (imgData) {delete[] imgData;imgData = nullptr;qDebug() << "gif grab window over";}}});heroTimer.start();

//QT接口自带的 原始数据接口返回数据始终输出偏蓝色的图片,
//自己转化后的 图像 data 数组就没问题
//没有特殊计算 就是 一个数组 复制 到另一个数组
//奇怪的很!!!//必须要自己转化下to data原始数据,img的bits()接口数据有问题//原始QImage bits() 数据输出颜色不对!!!int dataSize = width() * height() * 4;imgData = new uint8_t[dataSize];auto getRgbData = [this, dataSize](auto img) -> auto{//zero data arraymemset(imgData, 0, dataSize);// 2. 遍历像素for (int y = 0; y < img.height(); y++) {for (int x = 0; x < img.width(); x++) {// 3. 获取像素的 QRgb 值QRgb pixel = img.pixel(x, y);// RGBA A is last!!!// 4. 提取 R, G, B 分量int r = qRed(pixel);int g = qGreen(pixel);int b = qBlue(pixel);int idx = y * img.width() + x;idx = idx * 4; //RGBA 4 bytesimgData[idx] = r;imgData[idx + 1] = g;imgData[idx + 2] = b;imgData[3 + idx] = qAlpha(pixel); ////                qDebug() << idx;// 5. 打印或处理 RGB//                qDebug() << "Pixel at (" << x << "," << y << "): R=" << r << " G=" << g//                         << " B=" << b;}}return imgData;};//OK two!!auto getImgData2 = [this, dataSize](auto image) -> auto{//zero data arraymemset(imgData, 0, dataSize);const uchar *bits = image.bits(); // 获取原始数据指针int width = image.width();int height = image.height();int bytesPerLine = image.bytesPerLine(); // 每行字节数for (int y = 0; y < height; y++) {const QRgb *line = reinterpret_cast<const QRgb *>(bits + y * bytesPerLine);for (int x = 0; x < width; x++) {QRgb pixel = line[x];int r = qRed(pixel);int g = qGreen(pixel);int b = qBlue(pixel);// 处理 RGB 数据...int idx = y * image.width() + x;idx = idx * 4; //RGBA 4 bytesimgData[idx] = r;imgData[idx + 1] = g;imgData[idx + 2] = b;imgData[3 + idx] = qAlpha(pixel); //}}return imgData;};
//先计算位置和速度等等非RGBA值(think),再刷新显示!!!
void Widget::paintEvent(QPaintEvent *e){QPainter p(this);p.setRenderHint(QPainter::Antialiasing);for(auto &f:foods){f->draw(p);}for(auto &e:enemies){e->draw(p);}hero->draw(p);
}
//设置移动方向,速度void Widget::keyPressEvent(QKeyEvent *e)
{int sd = 20;int k = e->key();switch (k) {case Qt::Key_W:hero->setDirection(Direction::UP,sd);break;case Qt::Key_S:hero->setDirection(Direction::DOWN,sd);break;case Qt::Key_A:hero->setDirection(Direction::LEFT,sd);break;case Qt::Key_D:hero->setDirection(Direction::RIGHT,sd);break;default:break;}update();
}
//实体类
//.h
#ifndef PACMAN_H
#define PACMAN_H#include <QObject>
#include<QPainter>
#include<QStack>
//#include<iostream>
#include<functional>
//#include<QFunctionPointer>
#include<QHash>
using namespace std;enum class Direction:int{UP,DOWN,LEFT,RIGHT
};template<class T>
struct MotionFunction
{
public:int x;int y;function<T> f;QStack<double> initialParams;
};class Pacman:public QObject
{Q_OBJECT
public:Pacman(int x,int y,int w,int h,QString pic);virtual void draw(QPainter& p);virtual void setPos(int x,int y);virtual int &rx();virtual int &ry();virtual int &rOriginX();virtual int &rOriginY();virtual void setFace(const Direction &d,QPixmap pic);virtual void setDirection(const Direction &d,int distance);virtual QHash<Direction,QPixmap> &face();public:MotionFunction<void()> mf;protected:QPixmap pic;
//    QString pic;int originX;int originY;int x;int y;int width;int height;Direction direction;QHash<Direction,QPixmap> faces;};uint qHash(const Direction &d,uint seed);class Enemy:public Pacman{Q_OBJECT
public:Enemy(int x,int y,int w,int h,QString pic);
};class Food:public Pacman{Q_OBJECT
public:Food(int x,int y,int w,int h,QString pic);};#endif // PACMAN_H
//.cpp
#include "pacman.h"Pacman::Pacman(int x,int y,int w,int h,QString pic):x(x),y(y),width(w),height(h),pic(pic),direction(Direction::RIGHT),originX(x),originY(y)
{}void Pacman::draw(QPainter& p){p.drawPixmap(x,y,width,height,pic);
}void Pacman::setPos(int x,int y){this->x = x;this->y = y;
}int &Pacman::rx(){return x;
}int &Pacman::ry(){return y;
}int &Pacman::rOriginX(){return originX;
}int &Pacman::rOriginY(){return originY;
}void Pacman::setFace(const Direction &d,QPixmap pic){faces[d] = pic;
}void Pacman::setDirection(const Direction &d,int distance){this->pic = faces[d];switch (d) {case Direction::UP:y -= distance;break;case Direction::DOWN:y+=distance;break;case Direction::LEFT:x -= distance;break;case Direction::RIGHT:x += distance;break;default:break;}
}QHash<Direction,QPixmap> &Pacman::face(){return faces;
}uint qHash(const Direction &d,uint seed){return static_cast<int>(d) + seed;
}Enemy::Enemy(int x,int y,int w,int h,QString pic):Pacman(x,y,w,h,pic)
{}Food::Food(int x,int y,int w,int h,QString pic):Pacman(x,y,w,h,pic)
{}
子类可以继承父类的函数和属性,代码复用非常方便不支持反射的编程语言,只能通过其他工具(程序)生成实体类,
RPC,序列化,等等都是使用工具生成代码,可以方便代码编写,提高编写代码的速度。

 

 

http://www.dtcms.com/a/433633.html

相关文章:

  • 福田网站制作报价企业网站建设合同书
  • 高端手机网站定制湛江网页设计培训
  • 苏州建设网站的公司有哪些企业可以做招聘的网站有哪些方面
  • 商城网站开发报成都网站建设 城
  • espcms易思企业网站管理系统建立网站商店
  • 网站备案换主体vs做的网站如何使用
  • 洛阳市网站建设网站内页跳转wap
  • 2018做技术分享网站有前景吗网络产品推广方案范文
  • seo网站编辑是做什么的求职网站的建设方案
  • 罗湖网站建设优化wordpress 博客多人
  • 网站icp 备案查询网站建设哪里培训
  • 网站和新媒体建设方案一键下载安装微信
  • 网站模板设计师要求jsp网站开发需要什么技术
  • 建站中企动力网站优化提升排名
  • 网站建设怎么在png上写文字广州微网站建设哪家好
  • 为什么要建设档案网站做零食网站的选题理由
  • 苏州网站建设软件云服务器安装win系统做网站
  • 公司网站如何seo网站开发时浮动框的代码
  • 武威做网站的网站开发公司属于什么行业
  • 免费建自己的网站html5 网站模板
  • 龙岩网站推广营销wordpress上传到服务器
  • 有教做素食的网站吗wordpress如何使用
  • 个人网站名称 备案合肥网站建设
  • 如何搭建 seo网站旺道seo推广效果怎么样
  • 有什么好看的网站资源网页游戏平台系统
  • 邢台网站制作公司更改wordpress前缀
  • wordpress简单易懂的网站河南住房建设部网站
  • 做宠物网站班级网站怎么做
  • 广州口碑好的网站建设设计pc软件开发工具
  • 杭州网站建设响应式高端大气公司名称