-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathanimation.cpp
More file actions
264 lines (257 loc) · 6.83 KB
/
animation.cpp
File metadata and controls
264 lines (257 loc) · 6.83 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
//-----本文件是SC类成员函数的实现部分-----
#include "widget.h"
void SC::UesSCFun(SCFun scfun)
{
this->scfun=scfun;
this->isfunction=true;
}
void SC::changepixmap()
{
if(iter==pixmap.end())
{
if(cycle)
{iter=pixmap.begin();}//若需循环,就重播
else//若不循环,发信号退出一切
{
over=true;
if(signfun!=NULL_String)
{
QByteArray ba = signfun.toLatin1();
const char *function = ba.data();
QMetaObject::invokeMethod(lfevent,function);
}
return;
}
}
//若未播完,正常换图
item->PixmapItemPoniter->setPixmap(*iter);
++iter;
}
void SC::start(int choose)
{
this->choose=choose;
timer=new QTimer(this);
switch(choose)
{
case 0:
{
temp=0;
temp1=2*(TargetModulus-CurrentModulus)/times;
timer->start(2);
break;
}
case 1:
{
temp=0;
temp1=2*(TargetModulus-CurrentModulus)/times;
timer->start(2);
break;
}
case 2:
{
temp=0;
temp1=2*(TargetModulus-CurrentModulus)/times;
temp2=2*(TargetModulus2-CurrentModulus2)/times;
timer->start(2);
break;
}
case 3:
{
temp=0;
temp1=3*(TargetModulus-CurrentModulus)/times;
timer->start(3);
break;
}
case 4:
{
temp=0;
temp1=2*(TargetModulus-CurrentModulus)/times;
timer->start(2);
break;
}
case 5:
{
temp=0;
temp1=2*(TargetModulus-CurrentModulus)/times;
temp2=2*(TargetModulus2-CurrentModulus2)/times;
temp3=2*(TargetModulus3-CurrentModulus3)/times;
timer->start(2);
break;
}
case 6:
{
iter=pixmap.begin();//将装满连帧图元的迭代器调到头元素
temp1=times/pixmap.size();//计算出播放每一帧需要的时间
timer->start(int(temp1));//根据此时间开始播放
break;
}
case 7:
{
temp=0;
temp1=2*(TargetModulus-CurrentModulus)/times;
temp2=2*(TargetModulus2-CurrentModulus2)/times;
timer->start(2);
break;
}
case 8:
{
temp=0;
temp1=2*(TargetModulus-CurrentModulus)/times;
temp2=2*(TargetModulus2-CurrentModulus2)/times;
timer->start(2);
break;
}
case 20:
{
temp=0;
temp1=2*(TargetModulus-CurrentModulus)/times;
temp2=2*(TargetModulus2-CurrentModulus2)/times;
timer->start(2);
break;
}
}
connect(timer,SIGNAL(timeout()),this,SLOT(SlowChange()));
}
void SC::isend()
{
if(times!=-1)
{
if((long)temp==times || (long)temp==times+1 || (long)temp==times-1) //temp实际上是记录目前时间的
{over=true;}
}
}
void SC::SlowChange()
{
if(!over)
{
switch(choose)
{
case Rotation:
{
temp+=2;
if(!isfunction)
{item->ItemPointer->setRotation(CurrentModulus+=temp1);}
else
{item->ItemPointer->setRotation(scfun(temp).CurrentModulus);}
isend();
break;
}
case Scale:
{
temp+=2;
if(!isfunction)
{item->ItemPointer->setScale(CurrentModulus+=temp1);}
else
{item->ItemPointer->setScale(scfun(temp).CurrentModulus);}
isend();
break;
}
case Move:
{
temp+=2;
if(!isfunction)
{item->ItemPointer->moveBy(temp1,temp2);}
else
{
SCCurrentModulus scc=scfun(temp);
item->ItemPointer->setPos(scc.CurrentModulus,scc.CurrentModulus2);
}
#ifdef AutoIsColliding
s->itemMoveEvent();
#endif
isend();
break;
}
case BlurRadius:
{
temp+=3;
if(!isfunction)
{s->BlurRadiusItem(item,CurrentModulus+=temp1);}
else
{s->BlurRadiusItem(item,scfun(temp).CurrentModulus);}
isend();
break;
}
case Opacity:
{
temp+=2;
if(!isfunction)
{item->ItemPointer->setOpacity(CurrentModulus+=temp1);}
else
{item->ItemPointer->setOpacity(scfun(temp).CurrentModulus);}
isend();
break;
}
case Color:
{
temp+=2;
if(!isfunction)
{s->SetRGBColorItem(item,CurrentModulus+=temp1,CurrentModulus2+=temp2,CurrentModulus3+=temp3);}
else
{
SCCurrentModulus scc=scfun(temp);
s->SetRGBColorItem(item,scc.CurrentModulus,scc.CurrentModulus2,scc.CurrentModulus3);
}
isend();
break;
}
case Picture:
{
changepixmap();
break;
}
case Shear:
{
temp+=2;
if(!isfunction)
{s->ShearItem(item,CurrentModulus+=temp1,CurrentModulus2+=temp2);}
else
{
SCCurrentModulus scc=scfun(temp);
s->ShearItem(item,scc.CurrentModulus,scc.CurrentModulus2);
}
isend();
break;
}
case FreeScale:
{
temp+=2;
if(!isfunction)
{s->FreeScaleItem(item,CurrentModulus+=temp1,CurrentModulus2+=temp2);}
else
{
SCCurrentModulus scc=scfun(temp);
s->FreeScaleItem(item,scc.CurrentModulus,scc.CurrentModulus2);
}
isend();
break;
}
case 20:
{
temp+=2;
if(!isfunction)
{gv->SetCenter(CurrentModulus+=temp1,CurrentModulus2+=temp2);}
else
{
SCCurrentModulus scc=scfun(temp);
gv->SetCenter(scc.CurrentModulus,scc.CurrentModulus2);
}
isend();
break;
}
}
}
if(over)
{
if(signfun!=NULL_String)
{
QByteArray ba = signfun.toLatin1();
const char *function = ba.data();
QMetaObject::invokeMethod(lfevent,function);
}
if(choose!=20)
{item->scPointer[choose]=nullptr;}
delete timer;
delete this; //释放动画资源的位置在这里,在EndAnimation后会在2ms后执行到这里自动释放
}
}