@@ -3,7 +3,7 @@ import blobs from "..";
33import { interpolateBetweenLoop } from "../internal/animate/interpolate" ;
44import { divideShape , prepShapes } from "../internal/animate/prepare" ;
55import { Coord , Point , Shape } from "../internal/types" ;
6- import { length , insertAt , insertCount , rad } from "../internal/util" ;
6+ import { length , insertAt , insertCount , rad , mod } from "../internal/util" ;
77import { clear , drawInfo , drawShape } from "../internal/render/canvas" ;
88
99const animationSpeed = 2 ;
@@ -40,15 +40,15 @@ const testSplitAt = (percentage: number) => {
4040 const stop = 2 * count - 1 ;
4141 for ( let i = 0 ; i < count ; i ++ ) {
4242 const double = i * 2 ;
43- const next = ( double + 1 ) % stop ;
43+ const next = mod ( double + 1 , stop ) ;
4444 points . splice ( double , 2 , ...insertAt ( percentage , points [ double ] , points [ next ] ) ) ;
4545 }
4646 points . splice ( 0 , 1 ) ;
4747
4848 let sum = 0 ;
4949 for ( let i = 0 ; i < points . length ; i ++ ) {
5050 const curr = points [ i ] ;
51- const next = points [ ( i + 1 ) % points . length ] ;
51+ const next = points [ mod ( i + 1 , points . length ) ] ;
5252 sum += length ( curr , next ) ;
5353 }
5454 drawInfo ( ctx , 1 , "split at lengths sum" , sum ) ;
@@ -154,7 +154,7 @@ const genBlob = (
154154 testPrepShapesB ( percentage ) ;
155155
156156 percentage += animationSpeed / 1000 ;
157- percentage %= 1 ;
157+ percentage = mod ( percentage , 1 ) ;
158158 if ( animationSpeed > 0 ) requestAnimationFrame ( renderFrame ) ;
159159 } ;
160160 renderFrame ( ) ;
0 commit comments