@@ -6,6 +6,7 @@ import {clear, drawInfo, drawClosed} from "../../render/canvas";
66import { genBlob } from "../../gen" ;
77import { rand } from "../../rand" ;
88import * as blobs2 from "../../../public/blobs" ;
9+ import * as blobs2Animate from "../../../public/animate" ;
910
1011let animationSpeed = 2 ;
1112let animationStart = 0.3 ;
@@ -24,6 +25,9 @@ const toggle = document.getElementById("toggle");
2425if ( toggle === null ) throw new Error ( "no toggle" ) ;
2526toggle . onclick = ( ) => ( debug = ! debug ) ;
2627
28+ const interact = document . getElementById ( "interact" ) as any ;
29+ if ( toggle === null ) throw new Error ( "no interact" ) ;
30+
2731const point = ( x : number , y : number , ia : number , il : number , oa : number , ol : number ) : Point => {
2832 return {
2933 x : x * size ,
@@ -255,6 +259,58 @@ const loopBetween = (percentage: number, a: Point[], b: Point[]): Point[] => {
255259 }
256260} ;
257261
262+ const animation = blobs2Animate . canvasPath ( ) ;
263+
264+ const loopAnimation = ( ) => {
265+ console . log ( "LOOP" ) ;
266+
267+ animation . transition (
268+ {
269+ duration : 2000 ,
270+ blobOptions : {
271+ extraPoints : 3 ,
272+ randomness : 3 ,
273+ seed : "blob1" ,
274+ size : 200 ,
275+ } ,
276+ } ,
277+ {
278+ duration : 2000 ,
279+ callback : loopAnimation ,
280+ blobOptions : {
281+ extraPoints : 3 ,
282+ randomness : 3 ,
283+ seed : "blob2" ,
284+ size : 200 ,
285+ } ,
286+ } ,
287+ ) ;
288+ } ;
289+
290+ animation . transition ( {
291+ duration : 100 ,
292+ callback : loopAnimation ,
293+ blobOptions : {
294+ extraPoints : 3 ,
295+ randomness : 3 ,
296+ seed : "start" ,
297+ size : 200 ,
298+ } ,
299+ } ) ;
300+
301+ interact . onclick = ( ) => {
302+ animation . transition ( {
303+ duration : 1000 ,
304+ callback : loopAnimation ,
305+ blobOptions : {
306+ extraPoints : 3 ,
307+ randomness : 7 ,
308+ seed : "onClick" ,
309+ size : 200 ,
310+ } ,
311+ } ) ;
312+ } ;
313+
258314( ( ) => {
259315 let percentage = animationStart ;
260316
@@ -276,6 +332,8 @@ const loopBetween = (percentage: number, a: Point[], b: Point[]): Point[] => {
276332 percentage += animationSpeed / 1000 ;
277333 percentage = mod ( percentage , 1 ) ;
278334 if ( animationSpeed > 0 ) requestAnimationFrame ( renderFrame ) ;
335+
336+ ctx . fill ( animation . renderFrame ( ) ) ;
279337 } ;
280338 renderFrame ( ) ;
281339} ) ( ) ;
0 commit comments