-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmagic_fish.h
59 lines (45 loc) · 1.4 KB
/
magic_fish.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef MAGIC_FISH_H
#define MAGIC_FISH_H
#include <QWidget>
#include <QTimer>
class MagicFish : public QWidget
{
public:
explicit MagicFish(QWidget *parent = 0);
void setFishR(int value);
void setSpeed(int value);
void setCurrentAngle(float angle);
void setFinAnimation(bool start);
QPointF getHeadPos() const;
int getFishR() const;
float getAngle();
void setWave(float value);
public slots:
void updateValue();
protected:
void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e);
private:
QPointF calcPoint(const QPointF &pos, float length, float angle);
void paintMyPoint(QPainter &painter, const QPointF pos);
void paintMyFishFins(QPainter &painter, const QPointF &pos, bool is_left, float father_angle);
void paintMyBody(QPainter &painter, const QPointF &pos, float seg_r, float MP, float father_angle);
void paintMyBody2(QPainter &painter, const QPointF &pos, float seg_r, float MP, float father_angle);
void paintMyTail(QPainter &painter, const QPointF &pos, float length, float max_w, float angle);
private:
float body_height;
float fish_r; // fish head r
float fin_length;
int head_alpha;
int body_alpha;
int fin_alpha;
float main_angle;
int current_value;
int speed;
float wave;
QTimer *timer;
bool start_fin;
bool paint_point;
QPointF head_pos;
};
#endif // MAGIC_FISH_H