(baseBg,baseFg,flashBg,flashFg)
| 272 | } |
| 273 | |
| 274 | function flash(baseBg,baseFg,flashBg,flashFg){ |
| 275 | let flashValue={v:0}; |
| 276 | function transitionFlash(to,t=0.025){ |
| 277 | return new Promise((resolve,reject)=>{ |
| 278 | TweenLite.to(flashValue,t,{ |
| 279 | v:to, |
| 280 | ease:Quint.easeOut, |
| 281 | onUpdate:()=>{ |
| 282 | generateTextures(baseFg,baseBg); |
| 283 | generateTextures(flashFg,flashBg,flashValue.v); |
| 284 | renderer.updateTextures(); |
| 285 | }, |
| 286 | onComplete:()=>{ |
| 287 | resolve(); |
| 288 | } |
| 289 | }); |
| 290 | }); |
| 291 | } |
| 292 | |
| 293 | let lastFlash=transitionFlash(1); |
| 294 | times(random(2,7),(i)=>{ |
| 295 | lastFlash=lastFlash.then(()=>{ |
| 296 | return transitionFlash(random(0.1,1)) |
| 297 | }) |
| 298 | }) |
| 299 | lastFlash=lastFlash.then(()=>{ |
| 300 | return transitionFlash(1,0.1); |
| 301 | }).then(()=>{ |
| 302 | transitionFlash(0,0.25); |
| 303 | }); |
| 304 | |
| 305 | } |
| 306 | function generateTextures(fg,bg,alpha=1){ |
| 307 | textureFgCtx.globalAlpha=alpha; |
| 308 | textureFgCtx.drawImage(fg,0,0,textureFgSize.width,textureFgSize.height); |
no test coverage detected