| author | Edwin Razafimahatratra <edwin@robotalismsoft.com> |
| Tue, 11 Dec 2012 21:13:42 +0100 | |
| changeset 45 | f7bfdc49982b |
| parent 43 | 21a791340354 |
| child 78 | 8c3f0b94d056 |
| permissions | -rw-r--r-- |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
1 |
function IncMosaic() |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
2 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
3 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
4 |
// Members |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
5 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
6 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
7 |
// Canvas |
| 36 | 8 |
this.canvasId; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
9 |
this.canvas; |
| 36 | 10 |
this.ctx; |
11 |
this.imageData; |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
12 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
13 |
/// Images |
|
39
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
14 |
this.imageUrls = []; |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
15 |
this.listeUrls = []; // The images list to blend |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
16 |
this.pairImages = []; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
17 |
this.imagesLoaded = 0; |
| 36 | 18 |
this.imageWidth; |
19 |
this.imageHeight; |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
20 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
21 |
// Effect |
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
22 |
this.waitStartEffectTime = 3000; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
23 |
this.waitStartEffectGo; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
24 |
this.effectSpeed; |
| 36 | 25 |
this.squareCountX; |
26 |
this.squareCountY; |
|
27 |
this.srcSquareWidth; |
|
28 |
this.srcSquareHeight; |
|
29 |
this.squareWidth; |
|
30 |
this.squareHeight; |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
31 |
this.effects = []; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
32 |
this.squareEffects = []; |
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
33 |
this.loop; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
34 |
this.endEffecFunc; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
35 |
|
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
36 |
// Time |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
37 |
this.startTime; |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
38 |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
39 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
40 |
// Functions |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
41 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
42 |
|
|
39
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
43 |
this.addImageUrl = function(url) |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
44 |
{ |
|
39
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
45 |
this.imageUrls.push(url); |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
46 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
47 |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
48 |
this.start = function(canvasId, effectSpeed, squareCountX, squareCountY, loop, waitStartEffectGo, endEffecFunc) |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
49 |
{ |
| 36 | 50 |
// Canvas ID |
51 |
this.canvasId = canvasId; |
|
52 |
||
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
53 |
// Speed |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
54 |
this.effectSpeed = 1 / effectSpeed; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
55 |
|
| 36 | 56 |
// Set square count |
57 |
this.squareCountX = squareCountX; |
|
58 |
this.squareCountY = (squareCountY === undefined) ? squareCountX: squareCountY; |
|
59 |
||
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
60 |
// End effect behavior |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
61 |
this.loop = loop; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
62 |
this.endEffecFunc = endEffecFunc; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
63 |
|
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
64 |
// Does the effect wait for go |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
65 |
this.waitStartEffectGo = waitStartEffectGo; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
66 |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
67 |
// Init the canvas objects |
| 36 | 68 |
this.init(); |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
69 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
70 |
// Register effects |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
71 |
this.registerEffects(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
72 |
|
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
73 |
// Set a new effect transition between 2 images |
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
74 |
this.setNewEffect(); |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
75 |
|
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
76 |
// Main loop |
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
77 |
this.loopCallback(); |
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
78 |
}; |
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
79 |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
80 |
this.setNewEffect = function() |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
81 |
{ |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
82 |
// Set a random pair images |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
83 |
this.setRandomPairImages(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
84 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
85 |
// Set random effect on the squares |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
86 |
this.setRandomSquareEffect(); |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
87 |
|
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
88 |
// Time |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
89 |
this.startTime = new Date().getTime(); |
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
90 |
}; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
91 |
|
|
45
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
92 |
this.UnpauseEffect = function(go) |
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
93 |
{ |
|
45
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
94 |
this.waitStartEffectGo = !go; |
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
95 |
}; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
96 |
|
| 36 | 97 |
this.init = function() |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
98 |
{ |
|
45
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
99 |
if (this.canvas === undefined || this.canvas === null) { |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
100 |
// Init canvas objects |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
101 |
this.canvas = document.getElementById(this.canvasId ); |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
102 |
this.ctx = this.canvas.getContext('2d'); |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
103 |
this.ctx.fillStyle = "#000000"; |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
104 |
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
105 |
} |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
106 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
107 |
|
| 36 | 108 |
this.registerPreNewCanvasSize = function(newCanvasWidth, newCanvasHeight) |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
109 |
{ |
| 36 | 110 |
}; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
111 |
|
| 36 | 112 |
this.registerPostNewCanvasSize = function(newCanvasWidth, newCanvasHeight) |
113 |
{ |
|
114 |
// Recalculate the size of the mosaic squares |
|
115 |
incMosaic.squareWidth = Math.floor(newCanvasWidth / incMosaic.squareCountX); |
|
116 |
incMosaic.squareHeight = Math.floor(newCanvasHeight / incMosaic.squareCountY); |
|
117 |
}; |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
118 |
|
|
39
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
119 |
this.fillListUrl = function() |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
120 |
{ |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
121 |
var urls = []; |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
122 |
for (var i = 1; i < this.imageUrls.length; ++i) { |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
123 |
urls.push(this.imageUrls[i]); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
124 |
} |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
125 |
|
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
126 |
// Set random url |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
127 |
|
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
128 |
// The first images is always the first in this array |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
129 |
this.listeUrls.push(this.imageUrls[0]); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
130 |
|
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
131 |
while (urls.length > 0) { |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
132 |
var randInd = this.randomInt(0, urls.length); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
133 |
this.listeUrls.push(urls[randInd]); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
134 |
urls.remove(randInd); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
135 |
} |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
136 |
}; |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
137 |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
138 |
this.setRandomPairImages = function() |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
139 |
{ |
|
39
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
140 |
if (this.listeUrls.length == 0) { |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
141 |
this.fillListUrl(); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
142 |
} |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
143 |
|
|
39
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
144 |
if (this.pairImages.length == 0) { |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
145 |
this.imagesLoaded = 0; |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
146 |
this.pairImages.push(this.getImageFromUrl(this.listeUrls[0])); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
147 |
this.pairImages.push(this.getImageFromUrl(this.listeUrls[1])); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
148 |
this.listeUrls.remove(0); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
149 |
} else { |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
150 |
this.imagesLoaded = 1; |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
151 |
this.pairImages[0] = this.pairImages[1]; // Swap |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
152 |
this.pairImages[1] = this.getImageFromUrl(this.listeUrls[0]) |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
153 |
} |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
154 |
this.listeUrls.remove(0); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
155 |
|
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
156 |
// Todo preload the next image |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
157 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
158 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
159 |
this.setRandomSquareEffect = function() |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
160 |
{ |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
161 |
this.squareEffects.length = 0; |
| 36 | 162 |
for (var i = 0; i < this.squareCountX; ++i) { |
163 |
for (var j = 0; j < this.squareCountY; ++j) { |
|
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
164 |
var fullEffect = this.effects[this.randomInt(0, this.effects.length)].copy(); |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
165 |
fullEffect.x = i; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
166 |
fullEffect.y = j; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
167 |
this.squareEffects.push(fullEffect); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
168 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
169 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
170 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
171 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
172 |
this.loopCallback = function() |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
173 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
174 |
var self = incMosaic; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
175 |
|
| 36 | 176 |
if (self.imagesLoaded == 2) { |
177 |
// Redraw |
|
178 |
self.redraw(); |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
179 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
180 |
|
| 36 | 181 |
// Loop |
182 |
requestAnimationFrame(self.loopCallback); |
|
183 |
}; |
|
184 |
||
185 |
this.redraw = function() |
|
186 |
{ |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
187 |
// Get time |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
188 |
var time = new Date().getTime(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
189 |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
190 |
var timeToWait = (this.startTime + this.waitStartEffectTime)*this.effectSpeed; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
191 |
if (time < timeToWait || this.waitStartEffectGo) { |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
192 |
// Draw the first image |
| 36 | 193 |
this.ctx.drawImage(this.pairImages[0], 0, 0, this.srcSquareWidth*this.squareCountX, this.srcSquareHeight*this.squareCountY, 0, 0, this.squareWidth*this.squareCountX, this.squareHeight*this.squareCountY); |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
194 |
return; |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
195 |
} |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
196 |
|
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
197 |
// Update effects |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
198 |
var effectsContinue = false; |
| 36 | 199 |
for (var i = 0; i < this.squareEffects.length; ++i) { |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
200 |
// Update |
| 36 | 201 |
var fullEffect = this.squareEffects[i]; |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
202 |
effectsContinue = fullEffect.update(time) || effectsContinue; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
203 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
204 |
for (var j = 0; j < 2; ++j) { |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
205 |
var effectInfo = fullEffect.effectInfos[j]; |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
206 |
if (effectInfo !== null) { |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
207 |
// Draw square |
| 36 | 208 |
this.drawSquare(fullEffect, this.pairImages[j], effectInfo); |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
209 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
210 |
} |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
211 |
} |
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
212 |
|
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
213 |
if (!effectsContinue) { |
|
45
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
214 |
if (this.endEffecFunc != undefined && this.endEffecFunc != null) { |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
215 |
// Call the end callback |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
216 |
var func = this.endEffecFunc; |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
217 |
if (!this.loop) { |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
218 |
this.endEffecFunc = null; |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
219 |
} |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
220 |
func(); |
|
f7bfdc49982b
ecrant choix unique
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
43
diff
changeset
|
221 |
} |
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
222 |
if (this.loop) { |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
223 |
// The effect loop |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
224 |
this.setNewEffect(); |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
225 |
} |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
226 |
} |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
227 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
228 |
|
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
229 |
this.drawSquare = function(fullEffect, image, effectInfo) |
|
29
c9c75ab3de3e
avance sur l'effet mosaic
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
23
diff
changeset
|
230 |
{ |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
231 |
this.ctx.save(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
232 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
233 |
// Global alpha |
| 36 | 234 |
this.ctx.globalAlpha = effectInfo.alpha; |
235 |
||
236 |
// Compute src and dest square position |
|
237 |
var srcPosX = fullEffect.x * this.srcSquareWidth; |
|
238 |
var srcPosY = fullEffect.y * this.srcSquareHeight; |
|
239 |
var destPosX = fullEffect.x * this.squareWidth; |
|
240 |
var destPosY = fullEffect.y * this.squareHeight; |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
241 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
242 |
// Draw colored rectangle |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
243 |
this.ctx.fillStyle = "rgba(" + effectInfo.color.r + "," + effectInfo.color.v + "," + effectInfo.color.b + "," + effectInfo.color.a + ")"; |
| 36 | 244 |
this.ctx.fillRect(destPosX, destPosY, this.squareWidth, this.squareHeight); |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
245 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
246 |
// Draw image |
| 36 | 247 |
this.ctx.drawImage(image, srcPosX, srcPosY, this.srcSquareWidth, this.srcSquareHeight, destPosX, destPosY, this.squareWidth, this.squareHeight); |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
248 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
249 |
this.ctx.restore(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
250 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
251 |
|
| 36 | 252 |
this.registerEffects = function() |
253 |
{ |
|
254 |
var count = 7; |
|
255 |
var color = 64; |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
256 |
var speed = this.effectSpeed; |
| 36 | 257 |
|
258 |
// Create semi random effects |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
259 |
var range1 = 3000 * speed; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
260 |
var range2 = 5000 * speed; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
261 |
this.registerEffectsTime(count, color, range1, range2); |
| 36 | 262 |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
263 |
// Create semi random effects |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
264 |
range1 = 7000 * speed; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
265 |
range2 = 15000 * speed; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
266 |
this.registerEffectsTime(count, color, range1, range2); |
| 36 | 267 |
|
268 |
// Create semi random effects |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
269 |
range1 = 17000 * speed; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
270 |
range2 = 23000 * speed; |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
271 |
this.registerEffectsTime(count, color, range1, range2); |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
272 |
}; |
| 36 | 273 |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
274 |
this.registerEffectsTime = function(count, color, range1, range2) |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
275 |
{ |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
276 |
for (var i = 0; i < count; ++i) { |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
277 |
var time1 = this.randomInt(range1, range2); |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
278 |
var time2 = this.randomInt(range1, range2); |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
279 |
var c1 = this.randomInt(0, color); |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
280 |
|
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
281 |
var effectParam1 = new IncEffectParams(new IncColor(c1, c1, c1, 0), new IncAnim(1, time1), 1, new IncAnim(-1, time1)); |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
282 |
var effect1 = new IncSquareEffect_Alpha(effectParam1, createjs.Ease.quadOut, createjs.Ease.quadOut); |
| 36 | 283 |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
284 |
var effectParam2 = new IncEffectParams(new IncColor(c1, c1, c1, 1), new IncAnim(0, time2), 0, new IncAnim(1, time2)); |
|
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
285 |
var effect2 = new IncSquareEffect_Alpha(effectParam2, createjs.Ease.quadIn, createjs.Ease.quadIn, time1 / 2.5); |
| 36 | 286 |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
287 |
var fullEffect1 = new IncFullEffect(effect1, effect2, time1, time2); |
| 36 | 288 |
this.effects.push(fullEffect1); |
289 |
} |
|
|
42
01415303372e
écran choix
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
39
diff
changeset
|
290 |
}; |
| 36 | 291 |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
292 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
293 |
// Tools |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
294 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
295 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
296 |
this.randomInt = function(min, max) |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
297 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
298 |
return Math.floor(this.randomFloat(min, max)); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
299 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
300 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
301 |
this.randomFloat = function(min, max) |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
302 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
303 |
return Math.random() * (max - min) + min; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
304 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
305 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
306 |
this.getImageFromUrl = function(url) |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
307 |
{ |
| 36 | 308 |
var self = incMosaic; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
309 |
var image = new Image(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
310 |
image.onload = function() { |
| 36 | 311 |
// When the first image is loaded we can get the image dimention and init the autoresize of the canvas |
312 |
if (self.imagesLoaded === 0) { |
|
313 |
// Set some image size related vars |
|
314 |
self.imageWidth = image.width; |
|
315 |
self.imageHeight = image.height; |
|
316 |
self.srcSquareWidth = image.width / self.squareCountX; |
|
317 |
self.srcSquareHeight = image.height / self.squareCountY; |
|
318 |
||
319 |
// Call the resize object |
|
320 |
if (incResize !== undefined) { |
|
321 |
incResize.resizeElements(); |
|
322 |
} |
|
323 |
} |
|
324 |
self.imagesLoaded += 1; |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
325 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
326 |
image.src = url; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
327 |
return image; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
328 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
329 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
330 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
331 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
332 |
// Effects |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
333 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
334 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
335 |
function IncColor(r, v, b, a) |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
336 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
337 |
this.r = r; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
338 |
this.v = v; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
339 |
this.b = b; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
340 |
this.a = a; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
341 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
342 |
this.copy = function() |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
343 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
344 |
return new IncColor(this.r, this.v, this.b, this.a); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
345 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
346 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
347 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
348 |
function IncAnim(value, time) |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
349 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
350 |
this.value = value; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
351 |
this.time = time; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
352 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
353 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
354 |
function IncEffectInfo() |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
355 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
356 |
this.color; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
357 |
this.alpha; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
358 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
359 |
|
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
360 |
function IncEffectParams(color, colorAnim, alpha, alphaAnim) |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
361 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
362 |
// Color |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
363 |
this.color = color; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
364 |
this.colorAnim = colorAnim; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
365 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
366 |
// Alpha |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
367 |
this.alpha = alpha; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
368 |
this.alphaAnim = alphaAnim; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
369 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
370 |
this.computeColorAnimValue = function(elapsedTime, easeFunc) |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
371 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
372 |
return this.computeAnimValue(this.colorAnim, elapsedTime, easeFunc); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
373 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
374 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
375 |
this.computeAlphaAnimValue = function(elapsedTime, easeFunc) |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
376 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
377 |
return this.computeAnimValue(this.alphaAnim, elapsedTime, easeFunc); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
378 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
379 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
380 |
this.computeAnimValue = function(anim, elapsedTime, easeFunc) |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
381 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
382 |
// Compute color alpha anim |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
383 |
if (elapsedTime < anim.time) { |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
384 |
return easeFunc(elapsedTime/anim.time) * anim.value; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
385 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
386 |
return anim.value; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
387 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
388 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
389 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
390 |
function IncSquareEffect_Alpha(effectParms, tweenColorFunc, tweenAlphaFunc, waitTime) |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
391 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
392 |
// Effect parameters |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
393 |
this.effectParms = effectParms; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
394 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
395 |
// Tween functions |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
396 |
this.tweenColorFunc = tweenColorFunc; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
397 |
this.tweenAlphaFunc = tweenAlphaFunc; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
398 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
399 |
// Time |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
400 |
this.waitTime = (waitTime!==undefined) ? waitTime : 0; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
401 |
|
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
402 |
this.update = function(elapsedTime) |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
403 |
{ |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
404 |
var info = new IncEffectInfo(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
405 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
406 |
// Compute new color |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
407 |
var newColorValue = this.effectParms.computeColorAnimValue(elapsedTime, this.tweenColorFunc); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
408 |
info.color = this.effectParms.color.copy(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
409 |
info.color.a += newColorValue; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
410 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
411 |
// Compute alpha anim |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
412 |
var newAlphaValue = this.effectParms.computeAlphaAnimValue(elapsedTime, this.tweenAlphaFunc); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
413 |
info.alpha = this.effectParms.alpha; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
414 |
info.alpha += newAlphaValue; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
415 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
416 |
return info; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
417 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
418 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
419 |
|
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
420 |
function IncFullEffect(effect1, effect2, totalTime1, totalTime2) |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
421 |
{ |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
422 |
// Position |
|
29
c9c75ab3de3e
avance sur l'effet mosaic
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
23
diff
changeset
|
423 |
this.x = 0; |
|
c9c75ab3de3e
avance sur l'effet mosaic
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
23
diff
changeset
|
424 |
this.y = 0; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
425 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
426 |
// Effect |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
427 |
this.effects = [effect1, effect2]; |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
428 |
this.effectInfos = [null, null]; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
429 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
430 |
// Time |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
431 |
this.startTime = [0, 0]; |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
432 |
this.totalTime = [totalTime1, totalTime2]; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
433 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
434 |
this.copy = function() |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
435 |
{ |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
436 |
return new IncFullEffect(this.effects[0], this.effects[1], this.totalTime[0], this.totalTime[1]); |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
437 |
}; |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
438 |
|
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
439 |
this.update = function(time) |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
440 |
{ |
| 36 | 441 |
if (this.startTime[0] === 0) { |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
442 |
this.startTime[0] = time; |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
443 |
this.startTime[1] = time; |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
444 |
return true; |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
445 |
} |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
446 |
|
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
447 |
for (var i = 0; i < 2; ++i) { |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
448 |
// If we are in the good time range we update the effect |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
449 |
var waitTime = this.startTime[i] + this.effects[i].waitTime; |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
450 |
var updateEffect = time < this.totalTime[i] + waitTime; |
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
451 |
if (time > waitTime && updateEffect) { |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
452 |
this.effectInfos[i] = this.effects[i].update(time - waitTime); |
|
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
453 |
} |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
454 |
|
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
455 |
if (i == 1 && !updateEffect) { |
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
456 |
// The effect is done |
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
457 |
return false; |
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
458 |
} |
|
30
6d5b46559bd9
effet mosaic done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
29
diff
changeset
|
459 |
} |
|
38
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
460 |
|
|
cdbb56b876c9
mosaic effect loops
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
36
diff
changeset
|
461 |
return true; |
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
462 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
463 |
} |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
464 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
465 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
466 |
// Tools |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
467 |
// -------------------------------------------------------------------------------------------------------------------- |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
468 |
|
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
469 |
window.requestAnimationFrame = (function() { |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
470 |
return window.requestAnimationFrame || // Chromium |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
471 |
window.webkitRequestAnimationFrame || // Webkit |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
472 |
window.mozRequestAnimationFrame || // Mozilla Geko |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
473 |
window.oRequestAnimationFrame || // Opera Presto |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
474 |
window.msRequestAnimationFrame || // IE Trident? |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
475 |
function(callback, element){ // Fallback function |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
476 |
window.setTimeout(callback, 20); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
477 |
}; |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
478 |
})(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
479 |
|
|
39
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
480 |
Array.prototype.remove = function(from, to) { |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
481 |
var rest = this.slice((to || from) + 1 || this.length); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
482 |
this.length = from < 0 ? this.length + from : from; |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
483 |
return this.push.apply(this, rest); |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
484 |
}; |
|
6605de5fe0bd
mosaic effect done
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
38
diff
changeset
|
485 |
|
|
23
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
486 |
var incMosaic = new IncMosaic(); |
|
45b05706b516
mosaic effect js first test
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff
changeset
|
487 |