A..4 3_Animation.c

Animation.c

   1 #include<stdio.h>
   2 #include<glsc3d_3.h>
   3 
   4 int main()
   5 {
   6     int INTV = 100;
   7     g_init("Window", 600, 600);                 //Pixel Size
   8     g_def_scale_2D(0,                           //ID
   9                    -1, 1,                       //xmin,xmax
  10                    -1, 1,                       //ymin,ymax
  11                    20.0, 20.0,                  //Window (Left, Top) Position
  12                    560, 560);                   //Window Size (x,y)
  13 
  14     //////////// Start time loop ////////////
  15     for (int i_time = 0; ; i_time++) {
  16         double dt = 0.0001;                     //Time Discritization
  17         double t = i_time * dt;                 //Time
  18         //////////// Calculation Part ////////////
  19         double x = 0.5 * cos(2.0*M_PI * t);     //X Coordinate
  20         double y = 0.5 * sin(2.0*M_PI * t);     //Y Coordinate
  21         //////////// Draw Part ////////////
  22         if (i_time%INTV == 0) {
  23             g_cls();                            //Clear window
  24             g_sel_scale(0);                     //Select Virtual scale
  25             g_boundary();                       //Draw Boundary
  26             g_area_color(1,0,0,1);              //Area Color
  27             g_circle_2D(x, y, 0.1, G_NO, G_YES);//g_circle_2D
  28             g_finish();                         //flush Draw buffer
  29             g_sleep(0.01);                      //Sleep 0.01 sec
  30         }
  31     }
  32     return 0;
  33 }



桂田 祐史