Home > リソース > Scilabでアニメーション作成 > 12. アニメーションをGIFファイルに保存
<<前へ | 次へ>>
Scilabでアニメーション作成

12. アニメーションをGIFファイルに保存

アニメーションをGIFファイルに保存しておけば、後から手軽に参照できて便利です。ATOMSで公開されている animated GIF creator モジュールを利用すれば、アニメーションGIFファイルを簡単に作成できます。

animated GIF creator モジュールのインストールは、Scilab 6.0 以上でコマンド atomsInstall("animaGIF") を実行するだけです。

コード1のスクリプトは、第3項の「運動する点のアニメーション」をGIFファイルに保存します。望ましい結果を得るためには、時間刻み(Time data)および animaGIF の delay パラメータを調整する必要があります。

animation_point_animaGIF.sce
// animation_point_animaGIF.sce

clear; xdel(winsid());

// Create motion data
t = 0:0.01:1;    // Time data
x = sin(2*%pi*t); // Position data

// Draw initial figure
h_fig = figure;
h_fig.background = 8;
drawlater();
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];

// Initiate animated GIF
outgif = 'animation_point_scilab.gif';
mdelete(outgif);
idGif = animaGIF(gcf(), outgif, 10, 0);

// Animation Loop
for i = 1:length(x)
    drawlater();
    h_point.data = [x(i), 0];
    drawnow();

    // Add snapshot to animated GIF
    idGif = animaGIF(gcf(), idGif);
end

// Close animated GIF
animaGIF(idGif);
コード1: 運動する点のアニメーションをGIFファイルに保存するMATLABスクリプト

スポンサーリンク