()
| 165 | vcanvas.width = w; vcanvas.height = h; // set to same size as main canvas |
| 166 | |
| 167 | function loop() { |
| 168 | ctx.clearRect(0, 0, w, h); |
| 169 | |
| 170 | for (var y = 0; y < h; y++) { |
| 171 | |
| 172 | // segment positions for Y-waves |
| 173 | var lx1 = x1 + o1.current(y * 0.2) * maxYShift * yAmpInputValue/300, |
| 174 | lx2 = x2 + o2.current(y * 0.26) * maxYShift * yAmpInputValue/300, |
| 175 | lx3 = x3 + o3.current(y * 0.22) * maxYShift * yAmpInputValue/300, |
| 176 | |
| 177 | // segment widths |
| 178 | w0 = lx1, |
| 179 | w1 = lx2 - lx1, |
| 180 | w2 = lx3 - lx2, |
| 181 | w3 = x4 - lx3; |
| 182 | |
| 183 | // draw image lines |
| 184 | ctx.drawImage(originalImg, x0, y, sw0, 1, 0 , y, w0 , 1); |
| 185 | ctx.drawImage(originalImg, x1, y, sw1, 1, lx1 - 0.5, y, w1 + 0.5, 1); |
| 186 | ctx.drawImage(originalImg, x2, y, sw2, 1, lx2 - 0.5, y, w2 + 0.5, 1); |
| 187 | ctx.drawImage(originalImg, x3, y, sw3, 1, lx3 - 0.5, y, w3 + 0.5, 1); |
| 188 | |
| 189 | } |
| 190 | |
| 191 | // pass 1 done, copy to off-screen canvas: |
| 192 | vctx.clearRect(0, 0, w, h); // clear off-screen canvas (only if alpha) |
| 193 | vctx.drawImage(animation, 0, 0); |
| 194 | ctx.clearRect(0, 0, w, h); // clear main (onlyif alpha) |
| 195 | |
| 196 | for (var x = 0; x < w; x++) { |
| 197 | // segment positions for X-waves |
| 198 | var ly1 = y1 + o4.current(x * 0.32) * maxXShift * xAmpInputValue/300, |
| 199 | ly2 = y2 + o5.current(x * 0.3) * maxXShift * xAmpInputValue/300, |
| 200 | ly3 = y3 + o6.current(x * 0.4) * maxXShift * xAmpInputValue/300; |
| 201 | |
| 202 | ctx.drawImage(vcanvas, x, y0, 1, sh0, x, 0 , 1, ly1); |
| 203 | ctx.drawImage(vcanvas, x, y1, 1, sh1, x, ly1 - 0.5, 1, ly2 - ly1 + 0.5); |
| 204 | ctx.drawImage(vcanvas, x, y2, 1, sh2, x, ly2 - 0.5, 1, ly3 - ly2 + 0.5); |
| 205 | ctx.drawImage(vcanvas, x, y3, 1, sh3, x, ly3 - 0.5, 1, y4 - ly3 + 0.5); |
| 206 | } |
| 207 | |
| 208 | //requestAnimationFrame(loop); |
| 209 | } |
| 210 | |
| 211 | animationInterval = setInterval(loop,1000/fps); |
| 212 |
nothing calls this directly
no outgoing calls
no test coverage detected