示例#1
0
文件: gnuplot.c 项目: w-maeda/bigdata
int main(void){
  FILE *gp;
  int i;
  char color[256];

  //sin,cosの画像出力
  gp=popen("gnuplot -persist","w");
  plot_color(2,color);
  fprintf(gp, "plot sin(x) lt rgb \"#%s\"\n",color);
  plot_color(3,color);
  fprintf(gp, "replot cos(x) lt rgb \"#%s\"\n",color);
  fprintf(gp, "set terminal postscript eps enhanced color\n");
  fprintf(gp, "set output \"image1.eps\"\n");
  fprintf(gp, "replot\n");
  //sin,cosの画像出力完了
  pclose(gp);

  gp=popen("gnuplot -persist","w");
  //ファイルからの画像出力
  plot_color(1,color);
  fprintf(gp, "plot \'list/folder/1/number.txt\' pt 13 ps 1 lt rgb \"#%s\"\n",color);
  plot_color(2,color);
  fprintf(gp, "replot \'list/folder/2/number.txt\' pt 13 ps 0.8 lt rgb \"#%s\"\n",color);
  fprintf(gp, "set terminal postscript eps enhanced color\n");
  fprintf(gp, "set output \"image2.eps\"\n");
  fprintf(gp, "replot\n");

  pclose(gp);

}
示例#2
0
void render(double time)
   {
   int i,j,k;

   int width,height;

   char state[size]={0};
   char state2[size]={0};

   width=get_winwidth();
   height=get_winheight();

   if (width>size) width=size;

   for (i=0; i<width; i++) state[i]=drand48()<0.5;

   for (i=0; i<height; i++)
      {
      for (j=0; j<width; j++)
         {
         unsigned int s=0;

         for (k=-b; k<=b; k++)
            {
            int l=j+k;

            if (l<0) l+=width;
            else if (l>=width) l-=width;

            s|=(state[l]<<(k+b));
            }

         state2[j]=(code&(1<<s))!=0;
         }

      for (j=0; j<width; j++) state[j]=state2[j];

      plot_color(0,0,0);
      for (j=0; j<width; j++)
         {
         double x=(j+0.5)/width;
         double y=1.0-(i+0.5)/height;

         if (state[j])
            plot_point(x,y);
         }
      }
   }
示例#3
0
void render(double time)
   {
   int i,j;

   int width,height;

   double x,y;
   float r,g,b;

   double l;

   static double alpha=0.0,beta=0.0,gamma=0.0;

   width=get_winwidth();
   height=get_winheight();

   for (i=0; i<width; i++)
      for (j=0; j<height; j++)
         {
         x=(i+0.5)/width;
         y=(j+0.5)/height;

         l=fsqr(x-0.5)+fsqr(y-0.5);

         r=sin(300*l+alpha-PI);
         g=sin(300*l+beta);
         b=sin(300*l+gamma+PI);

         plot_color(r,g,b);
         plot_point(x,y);
         }

   if (scroll)
      {
      alpha+=0.15;
      beta+=0.3;
      gamma+=0.6;
      }
   }