cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.
  • See how to access JMP Marketplace - and - find, create & share add-ins to extend your JMP. Watch video.

Uncharted

Choose Language Hide Translation Bar
Craige_Hales
Super User
Using a datatable as a JSL data structure

1000429.jpg Video made with JSL.

Designed for 1920x1080 display.

The JSL uses a data table to keep a row of data per moving point in the video. 

The ForEachRow loops use the column name variables rowpos and colpos to place a point at a row,column in the bitmap matrices and rowstep and colstep to advance the rowpos and colpos for each frame.

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" )
);

Advancing the points for the next frame:


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;
	)
);

The complicated if statements are testing if the point is about to leave the frame; an early version used bounceLimit=1 to let them bounce once by reversing the step.

The code is on github.

Last Modified: Jul 2, 2026 4:29 PM