@@ -259,54 +259,94 @@ const loopBetween = (percentage: number, a: Point[], b: Point[]): Point[] => {
259259 }
260260} ;
261261
262- const animation = blobs2Animate . canvasPath ( ) ;
262+ const genAnimation = ( speed : number ) : blobs2Animate . CanvasAnimation => {
263+ const animation = blobs2Animate . canvasPath ( ) ;
264+
265+ const loopAnimation = ( ) => {
266+ animation . transition (
267+ {
268+ duration : speed ,
269+ delay : speed ,
270+ timingFunction : "easeInOut" ,
271+ blobOptions : {
272+ extraPoints : 3 ,
273+ randomness : 4 ,
274+ seed : Math . random ( ) ,
275+ size : 200 ,
276+ } ,
277+ } ,
278+ {
279+ duration : speed ,
280+ timingFunction : "easeInOut" ,
281+ blobOptions : {
282+ extraPoints : 3 ,
283+ randomness : 4 ,
284+ seed : Math . random ( ) ,
285+ size : 200 ,
286+ } ,
287+ } ,
288+ {
289+ duration : speed ,
290+ delay : speed ,
291+ timingFunction : "easeInOut" ,
292+ blobOptions : {
293+ extraPoints : 3 ,
294+ randomness : 4 ,
295+ seed : Math . random ( ) ,
296+ size : 200 ,
297+ } ,
298+ } ,
299+ {
300+ duration : speed ,
301+ callback : loopAnimation ,
302+ timingFunction : "easeInOut" ,
303+ blobOptions : {
304+ extraPoints : 39 ,
305+ randomness : 2 ,
306+ seed : Math . random ( ) ,
307+ size : 200 ,
308+ } ,
309+ } ,
310+ ) ;
311+ } ;
263312
264- const loopAnimation = ( ) => {
265313 animation . transition ( {
266- duration : 2000 + 1000 * Math . random ( ) ,
314+ duration : 0 ,
267315 callback : loopAnimation ,
268- timingFunction : "easeInOut" ,
269316 blobOptions : {
270- extraPoints : 3 ,
271- randomness : 4 ,
272- seed : Math . random ( ) ,
317+ extraPoints : 1 ,
318+ randomness : 0 ,
319+ seed : 0 ,
273320 size : 200 ,
274321 } ,
275322 } ) ;
276- } ;
277323
278- animation . transition ( {
279- duration : 0 ,
280- callback : loopAnimation ,
281- blobOptions : {
282- extraPoints : 1 ,
283- randomness : 0 ,
284- seed : 0 ,
285- size : 200 ,
286- } ,
287- } ) ;
288-
289- interact . onclick = ( ) => {
290- animation . transition ( {
291- duration : 400 ,
292- callback : loopAnimation ,
293- timingFunction : "elasticIn0" ,
294- blobOptions : {
295- extraPoints : 3 ,
296- randomness : 8 ,
297- seed : Math . random ( ) ,
298- size : 180 ,
299- } ,
300- canvasOptions : {
301- offsetX : 10 ,
302- offsetY : 10 ,
303- }
304- } ) ;
324+ interact . onclick = ( ) => {
325+ animation . transition ( {
326+ duration : 400 ,
327+ callback : loopAnimation ,
328+ timingFunction : "elasticIn0" ,
329+ blobOptions : {
330+ extraPoints : 3 ,
331+ randomness : 8 ,
332+ seed : Math . random ( ) ,
333+ size : 180 ,
334+ } ,
335+ canvasOptions : {
336+ offsetX : 10 ,
337+ offsetY : 10 ,
338+ } ,
339+ } ) ;
340+ } ;
341+
342+ return animation ;
305343} ;
306344
307345( ( ) => {
308346 let percentage = animationStart ;
309347
348+ const animation = genAnimation ( 1000 ) ;
349+
310350 const renderFrame = ( ) => {
311351 clear ( ctx ) ;
312352
@@ -327,7 +367,6 @@ interact.onclick = () => {
327367 percentage += animationSpeed / 1000 ;
328368 percentage = mod ( percentage , 1 ) ;
329369 if ( animationSpeed > 0 ) requestAnimationFrame ( renderFrame ) ;
330-
331370 } ;
332371 renderFrame ( ) ;
333372} ) ( ) ;
0 commit comments