/*
* testlayer1.c
*/
#include <stdio.h>
#include <math.h>
#include <eggxlib.h>
double f(double x)
{
return sin(x) + sin(3 * x);
}
int main()
{
/* */
int win;
double xmin, xmax, ymin, ymax;
double a, b, pi, x, y, c, t, dt;
int i, j, N, Nt;
double dx;
/* 描画範囲 */
pi = 4 * atan(1.0);
a = 0; b = 2 * pi;
/* ウィンドウを開く */
win = eggx_gopen(500, 500);
eggx_winname(win, "mygraph");
eggx_gclr(win);
xmin = a - (b - a) / 10; xmax = b + (b - a) / 10; ymin = - 2.0; ymax = 2.0;
eggx_window(win, xmin, ymin, xmax, ymax);
eggx_newcolor(win, "green");
/* */
N = 200;
dx = (b - a) / N;
Nt = 500;
c = 1; dt = 10.0 / Nt;
/* layer=1 を表示、layer=0 に描画 */
eggx_layer(win, 1, 0);
for (i = 0; i <= Nt; i++) {
eggx_gclr(win);
t = i * dt;
x = a; y = f(x - c * t);
eggx_line(win, x, y, PENUP);
for (j = 1; j <= N; j++) {
x = j * dx; y = f(x - c * t);
eggx_line(win, x, y, PENDOWN);
}
/* layer=0 の画像を layer=1 にコピーする */
eggx_copylayer(win, 0, 1);
}
eggx_ggetch(win);
/* eggx のウィンドウを閉じる */
eggx_gclose(win);
return 0;
}