JSLで作成した動画です。
1920x1080ディスプレイ向けに設計されています。
JSLはデータテーブルを使用して、ビデオ内の移動点ごとに1行のデータを保持します。
ForEachRow ループは、列名変数 rowpos と colpos を使用してビットマップ行列の行、列に点を配置し、rowstep と colstep を使用して各フレームで rowpos と colpos を進めます。
dt = New Table( "points", "private", // private is *much* faster
Add Rows( npoints ), // this table has a row per moving point, location, vector, color
New Column( "rowpos" ), New Column( "colpos" ), New Column( "rowstep" ), New Column( "colstep" ),
New Column( "bounce" ), New Column( "rpix" ), New Column( "gpix" ), New Column( "bpix" )
);
次のフレームに向けてポイントを進めます。
movepoints = Function( {}, // on each frame the points are all advanced and checked for leaving the bitmap
For Each Row( dt,
If( 1 <= (dt:rowpos + dt:rowstep) < nr + 1, // hit bottom or top edge?
0 // not leaving
, // else...hit the edge
dt:bounce += 1;
If( dt:bounce > bounceLimit,
reset( Row() ) // restart
, // else keep bouncing
dt:rowstep = -dt:rowstep // if bouncing, reverse
);
);
If( 1 <= (dt:colpos + dt:colstep) < nc + 1, // hit left or right edge?
0 // not leaving
, // else...hit the edge
dt:bounce += 1;
If( dt:bounce > bounceLimit,
reset( Row() ) // restart
, // else keep bouncing
dt:colstep = -dt:colstep // reverse
);
);
dt:rowpos += dt:rowstep; // move this point along its path
dt:colpos += dt:colstep;
)
);
複雑なif文は、点がフレームから出ようとしているかどうかをテストしています。初期のバージョンでは、ステップを反転させることで点が一度跳ね返るように、bounceLimit=1を使用していました。
コードはGitHubにあります。