@@ -319,45 +319,55 @@ addCanvas(
319
319
size : width * 0.7 ,
320
320
} ;
321
321
const center : Coord = { x : width * 0.5 , y : height * 0.5 } ;
322
- const interval = 1000 ;
322
+ const interval = 2000 ;
323
323
324
324
const blob = centeredBlob ( options , center ) ;
325
325
const handles = mapPoints ( blob , ( { curr : p } ) => {
326
- p . handleIn . length = 75 ;
327
- p . handleOut . length = 75 ;
326
+ p . handleIn . length = 150 ;
327
+ p . handleOut . length = 150 ;
328
328
return p ;
329
329
} ) ;
330
330
const polyBlob = blob . map ( coordPoint ) ;
331
331
const pointCount = polyBlob . length ;
332
332
333
333
animate ( ( frameTime ) => {
334
334
const activeIndex = Math . floor ( frameTime / interval ) % pointCount ;
335
+ const opacity = Math . abs ( Math . sin ( frameTime * Math . PI / interval ) ) ;
335
336
336
337
tempStyles (
337
338
ctx ,
338
339
( ) => {
339
- ctx . fillStyle = colors . secondary ;
340
340
ctx . strokeStyle = colors . secondary ;
341
+ ctx . globalAlpha = opacity ;
341
342
} ,
342
343
( ) => {
343
- drawPoint ( ctx , center , 2 ) ;
344
- forPoints ( polyBlob , ( { prev , next } ) => {
344
+ forPoints ( polyBlob , ( { prev , next , index } ) => {
345
+ if ( index !== activeIndex ) return ;
345
346
drawLine ( ctx , prev ( ) , next ( ) , 1 , 2 ) ;
346
347
} ) ;
347
- forPoints ( handles , ( { curr} ) => {
348
+ forPoints ( handles , ( { curr, index} ) => {
349
+ if ( index !== activeIndex ) return ;
348
350
drawHandles ( ctx , curr , 1 ) ;
349
351
} ) ;
350
- drawPoint ( ctx , polyBlob [ activeIndex ] , 10 ) ;
351
-
352
+ } ,
353
+ ) ;
354
+
355
+ tempStyles (
356
+ ctx ,
357
+ ( ) => {
358
+ ctx . fillStyle = colors . secondary ;
359
+ } ,
360
+ ( ) => {
361
+ drawPoint ( ctx , center , 2 ) ;
352
362
} ,
353
363
) ;
354
364
355
365
drawClosed ( ctx , polyBlob , false ) ;
356
366
} ) ;
357
367
358
368
return `The angle of the handles for each point is parallel with the imaginary line
359
- stretching between the points before and after the point. A polygon's points have zero
360
- length handles.` ;
369
+ stretching between its neighbors. Technically, a polygon's points have zero
370
+ length handles, but the angle can still be calculated .` ;
361
371
} ,
362
372
( ctx , width , height , animate ) => {
363
373
const period = Math . PI * 1000 ;
0 commit comments