Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
ejanimation.h 1.06 KB
Copy Edit Web IDE Raw Blame History
unix_chen authored 2018-03-26 07:59 . init
#ifndef EJANIMATION_H
#define EJANIMATION_H
#include <QPoint>
#include <QPixmap>
#include <QVector>
#include <QImage>
#include <QPainter>
#include <functional>
struct AnimationEvent
{
};
struct AnimationFrame
{
QPoint off;
QPixmap pixmap;
AnimationFrame(const QPixmap &pix, const QPoint &point = QPoint()):pixmap(pix), off(point){}
};
typedef std::function<int(AnimationEvent *)> AnimationCallBack;
class EJAnimation
{
public:
void addFrame(AnimationFrame *frame){m_frames.push_back(frame);}
void setFrames(QVector<AnimationFrame*> &frames){m_frames = frames;}
void setFps(int fps){m_fps = fps;}
void setCallback(AnimationCallBack callback){m_callback = callback;}
int getFrameCount(){return m_frames.size();}
int getFPS(){return m_fps;}
AnimationFrame *getFrame(int index){return m_frames[index % m_frames.size()];}
private:
QVector<AnimationFrame*> m_frames;
AnimationCallBack m_callback;
int m_callbackIndex;
int m_fps;
};
#endif // EJANIMATION_H

Comment ( 0 )

Sign in for post a comment