@@ -6,10 +6,10 @@ import {clear, drawInfo, drawShape} from "../../render/canvas";
66import { genBlob } from "../../blobs" ;
77import { rand } from "../../rand" ;
88
9- const animationSpeed = 2 ;
10- const animationStart = 0.3 ;
11- const debug = true ;
12- const size = 1000 ;
9+ let animationSpeed = 2 ;
10+ let animationStart = 0.3 ;
11+ let debug = true ;
12+ let size = 1000 ;
1313
1414const canvas = document . createElement ( "canvas" ) ;
1515document . body . appendChild ( canvas ) ;
@@ -19,6 +19,10 @@ const temp = canvas.getContext("2d");
1919if ( temp === null ) throw new Error ( "context is null" ) ;
2020const ctx = temp ;
2121
22+ const toggle = document . getElementById ( "toggle" ) ;
23+ if ( toggle === null ) throw new Error ( "no toggle" ) ;
24+ toggle . onclick = ( ) => debug = ! debug ;
25+
2226const point = ( x : number , y : number , ia : number , il : number , oa : number , ol : number ) : Point => {
2327 return {
2428 x : x * size ,
@@ -103,18 +107,37 @@ const testInterpolateBetween = (percentage: number) => {
103107} ;
104108
105109const testPrepShapesA = ( percentage : number ) => {
106- const a = blob ( "a" , 6 , 0.2 , { x : 0.5 , y : 0.2 } ) ;
107- const b = blob ( "b" , 10 , 0.2 , { x : 0.5 , y : 0.2 } ) ;
110+ const a = blob ( "a" , 6 , 0.15 , { x : 0.45 , y : 0.1 } ) ;
111+ const b = blob ( "b" , 10 , 0.15 , { x : 0.45 , y : 0.1 } ) ;
108112 drawShape ( ctx , debug , interpolateBetweenLoop ( percentage , ...prepShapes ( a , b ) ) ) ;
109113} ;
110114
111115const testPrepShapesB = ( percentage : number ) => {
112- const a = blob ( "a" , 8 , 0.2 , { x : 0.5 , y : 0.5 } ) ;
116+ const a = blob ( "a" , 8 , 0.15 , { x : 0.45 , y : 0.25 } ) ;
117+ const b : Shape = [
118+ point ( 0.45 , 0.25 , 0 , 0 , 0 , 0 ) ,
119+ point ( 0.6 , 0.25 , 0 , 0 , 0 , 0 ) ,
120+ point ( 0.6 , 0.4 , 0 , 0 , 0 , 0 ) ,
121+ point ( 0.45 , 0.4 , 0 , 0 , 0 , 0 ) ,
122+ ] ;
123+ drawShape ( ctx , debug , interpolateBetweenLoop ( percentage , ...prepShapes ( a , b ) ) ) ;
124+ } ;
125+
126+ const testPrepShapesC = ( percentage : number ) => {
127+ const a = blob ( "c" , 8 , 0.15 , { x : 0.45 , y : 0.45 } ) ;
113128 const b : Shape = [
129+ point ( 0.5 , 0.45 , 0 , 0 , 0 , 0 ) ,
130+ point ( 0.55 , 0.45 , 0 , 0 , 0 , 0 ) ,
131+ point ( 0.55 , 0.5 , 0 , 0 , 0 , 0 ) ,
132+ point ( 0.6 , 0.5 , 0 , 0 , 0 , 0 ) ,
133+ point ( 0.6 , 0.55 , 0 , 0 , 0 , 0 ) ,
134+ point ( 0.55 , 0.55 , 0 , 0 , 0 , 0 ) ,
135+ point ( 0.55 , 0.6 , 0 , 0 , 0 , 0 ) ,
136+ point ( 0.5 , 0.6 , 0 , 0 , 0 , 0 ) ,
137+ point ( 0.5 , 0.55 , 0 , 0 , 0 , 0 ) ,
138+ point ( 0.45 , 0.55 , 0 , 0 , 0 , 0 ) ,
139+ point ( 0.45 , 0.5 , 0 , 0 , 0 , 0 ) ,
114140 point ( 0.5 , 0.5 , 0 , 0 , 0 , 0 ) ,
115- point ( 0.7 , 0.5 , 0 , 0 , 0 , 0 ) ,
116- point ( 0.7 , 0.7 , 0 , 0 , 0 , 0 ) ,
117- point ( 0.5 , 0.7 , 0 , 0 , 0 , 0 ) ,
118141 ] ;
119142 drawShape ( ctx , debug , interpolateBetweenLoop ( percentage , ...prepShapes ( a , b ) ) ) ;
120143} ;
@@ -146,6 +169,7 @@ const blob = (seed: string, count: number, scale: number, offset: Coord): Shape
146169 testInterpolateBetween ( percentage ) ;
147170 testPrepShapesA ( percentage ) ;
148171 testPrepShapesB ( percentage ) ;
172+ testPrepShapesC ( percentage ) ;
149173
150174 percentage += animationSpeed / 1000 ;
151175 percentage = mod ( percentage , 1 ) ;
0 commit comments