使用 JSL 制作的视频。
专为 1920x1080 显示器设计。
JSL 使用数据表来保存视频中每个移动点的一行数据。
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 。