There are two ways to program interactive graphics for Sysquake: SQ scripts and SQ files. Both are text files based on LME, Sysquake's language. For small programs, SQ scripts are simpler than SQ files, because they do not require the declarations of variables, figures and functions; but they have limitations which make them less suitable for large applications. They should be used only for interactive graphics when no other form of user interface is necessary. The table below summaries the differences.
SQ scripts | SQ files | |
---|---|---|
Interactive graphics | x | x |
Sliders and buttons | x | x |
Zoom and Shift | x | x |
Multiple synchronized graphics | x | x |
Easy access to variables | x | |
Figure menu | x | |
Settings menu | x | |
Undo/Redo | x | |
Save | x | |
Functions | libraries only | x |
Suitable for long computation | x | |
Help | x | |
Multiple instances | on some platforms |
An SQ script is a sequence of LME commands and expressions, very similar to what could be typed in the command-line interface. The single command
plot(sin(0:0.1:2*pi));
is enough to display a sine evaluated for angles between 0 and
The typical structure of an SQ script which supports the interactive manipulation of graphical element(s) is described below. Code samples show a typical implementation for manipulating the vertical position of points; but of course, many variants are possible.
if firstrun x = 1:10; y = rand(2,10); end
Name | Description |
---|---|
_z | initial position of the mouse as a complex number |
_x | initial horizontal position of the mouse |
_y | initial vertical position of the mouse |
_z0 | initial position of the clicked element as a complex number |
_x0 | initial horizontal position of the clicked element |
_y0 | initial vertical position of the clicked element |
_p0 | initial position of the clicked element as a 2D or 3D vector |
_z1 | current position of the mouse as a complex number |
_x1 | current horizontal position of the mouse |
_y1 | current vertical position of the mouse |
_p1 | current position of the mouse as a 2D or 3D vector |
_str1 | current string parameter |
_kx | factor the horizontal position is multiplied by (_x1/_x) |
_ky | factor the horizontal position is multiplied by (_y1/_y) |
_kz | complex factor the position is multiplied by in the complex plane (_z1/_z) |
_q | additional data specific to the plot |
_m | true if the modifier key (Shift key) is held down |
_id | ID of the manipulated object |
_nb | number of the manipulated trace (1-based) |
_ix | index of the manipulated point (1-based) |
switch _id case 1 y(_nb,_ix) = _y1; end
plot(x, y, 'r', 1);
Here is the complete program, which is probably not very useful
but shows the basic elements of an SQ script
if firstrun x = 1:10; y = rand(2,10); end switch _id case 1 y(_nb,_ix) = _y1; end plot(x, y, 'r', 1);