Code 1 below is an example Scilab script that produces an animation of a point moving along x-axis.
// animation_point.sce clear; xdel(winsid()); // Create motion data -- (1) t = 0:0.001:1; // Time data x = sin(2*%pi*t); // Position data // Draw initial figure -- (2) h_fig = figure; h_fig.background = 8; h_point = plot(x(1), 0, 'Marker', 'o', 'MarkerSize', 20,.. 'MarkerEdgeColor', 'blue', 'MarkerFaceColor', 'blue'); h_axes = gca(); h_axes.data_bounds = [-1.5, -1.5; 1.5, 1.5]; // Animation Loop -- (3) for i = 1:length(x) drawlater(); h_point.data = [x(i), 0]; drawnow(); end
First at (1), the motion data of the point are created. Next at (2), the initial point is drawn by the
plot command and the handle of the Polyline object is saved in the variable
h_point. Finally in the loop at (3), the value of
data property of the Polyline object is replaced and the figure is updated with
drawnow() command resulting in animation. This is the basic code to make an animation in Scilab.
The animation produced by this script is shown in Movie 1.