-
Notifications
You must be signed in to change notification settings - Fork 1
/
gif.js
58 lines (53 loc) · 1.51 KB
/
gif.js
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
/**
* gif.js
*
* functions related to the gif management (not display)
*/
/**
* Function to search when to stop if the gif has a part where many images
* can be displayed in one click
* @param {Number} resGif position in the array of the Gif we want to verify
* @param {Number} currentFrame Current image of the gif displayed
* @returns : the next index where the gif should stop before a click
*/
function findNextUnskippedFrame(resGif, currentFrame){
let i = currentFrame + 1;
const len = gifClickZone[resGif].id[0];
while(i != currentFrame){
if(i >=len){
i = 0;
}
if(gifClickZone[resGif].id[2][i] != 0){
return i
}
i++;
}
return -1;
}
/*
* Refreshes the size of every gif on the scene
*/
function resizeGif(){
for(let i = 0; i < gifOnScene.length; i++){
let top = windowsValues[5] + gifClickZone[i].y1 * windowsValues[3] * windowsValues[6];
let left = windowsValues[4] + gifClickZone[i].x1 * windowsValues[2] * windowsValues[6];
let width = windowsValues[2] * windowsValues[6] * (gifClickZone[i].x2-gifClickZone[i].x1);
let height = windowsValues[3] * windowsValues[6] * (gifClickZone[i].y2-gifClickZone[i].y1);
gifOnScene[i].resize(width, height, left, top);
}
}
/*
* Check if all the gifs are set to the right frame.
*/
function areGifWellSet(){
let bool = true;
let i = 0 ;
const len = gifClickZone.length;
while(i < len && bool){
if(gifClickZone[i].id[2][gifOnScene[i].get_current_frame()] != 2){
bool = false;
}
i++;
}
return bool;
}