Vídeo realizado con JSL.
Diseñado para pantallas de 1920x1080.
El lenguaje JSL utiliza una tabla de datos para mantener una fila de datos por cada punto en movimiento en el vídeo.
Los bucles ForEachRow utilizan las variables de nombre de columna rowpos y colpos para colocar un punto en una fila y columna en las matrices de mapa de bits, y rowstep y colstep para avanzar rowpos y colpos para cada fotograma.
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" )
);
Avanzando los puntos para el siguiente cuadro:
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;
)
);
Las complejas sentencias if comprueban si el punto está a punto de salir del marco; una versión anterior utilizaba bounceLimit=1 para permitir que rebotara una vez invirtiendo el paso.
El código está en GitHub .