当前位置: 首页>>代码示例>>C++>>正文


C++ save_extension函数代码示例

本文整理汇总了C++中save_extension函数的典型用法代码示例。如果您正苦于以下问题:C++ save_extension函数的具体用法?C++ save_extension怎么用?C++ save_extension使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了save_extension函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main() {

  screen s;
  color c;
 
  
  c.red = MAX_COLOR;
  c.green = MAX_COLOR;
  c.blue = 0;
  
  clear_screen(s);

  int i, j;

  for (i=0; i < YRES; i++)
    for (j=0; j < XRES; j++)
      plot(s, c, i, j);
  
  c.green = 0;
  for (i = 0; i<100; i++) {
    draw_line(250, 250, 10+i, 10+i, s, c);
  }
  draw_line(1, 1, 60, 70, s, c);
  //Note: Display may not work on your system
  //save_ppm and save_extension should be fine
  display(s);
  save_ppm(s, "pic.ppm");
  save_extension(s, "whatevs.png");
}
开发者ID:stuydw,项目名称:line,代码行数:29,代码来源:main.c

示例2: display

/*======== void display() ==========
Inputs:   screen s
Returns:
Will display the screen s on your monitor

02/12/10 09:16:30
jdyrlandweaver
====================*/
void display( screen s) {
   int x, i;
  char *fname = ".tmp.png";
  save_extension(s, fname);
  i = fork();
  if (i == 0) {
    execlp("display", "display", fname, NULL);
  }
  else {
    wait(&x);
    remove( fname );
  }
  /* For some reason, this refuses to run correctly
     on some systems. Most likely a strange imagemagick
     install issue.
     Above is a workaroudn for now.
  int x, y;
  FILE *f;

  f = popen("display", "w");

  fprintf(f, "P3\n%d %d\n%d\n", XRES, YRES, MAX_COLOR);
  for ( y=0; y < YRES; y++ ) {
    for ( x=0; x < XRES; x++)

      fprintf(f, "%d %d %d ", s[x][y].red, s[x][y].green, s[x][y].blue);
    fprintf(f, "\n");
  }
  pclose(f);
  */
}
开发者ID:leoncheng57,项目名称:graphics-9-final,代码行数:39,代码来源:display.c

示例3: main

int main() {

  screen s;
  color c;
 
  
  c.red = MAX_COLOR;
  c.green = MAX_COLOR;
  c.blue = 0;
  
  clear_screen(s);

  int i, j;

  for (i=0; i < YRES; i++)
    for (j=-500; j < XRES; j++ )
      plot(s, c, i, j);
  
  c.green = 0;

  draw_line(0, 0, 400, 350, s, c); //oct 1
  draw_line(0, 0, 400, 450, s, c); //oct 2
  //draw_line(20, 20, 300, 250, s, c); //oct 5
  draw_line(20, 350, 300, 100, s, c); //oct 6
  
  //draw_line(0, 0, 400, 350, s, c);
  //draw_line(0, 0, 400, 350, s, c);
  
  //Note: Display may not work on your system
  //save_ppm and save_extension should be fine
  save_ppm(s, "pic.ppm");
  save_extension(s, "whatevs.png");
  //display(s);
}  
开发者ID:sduncan,项目名称:Code,代码行数:34,代码来源:main.c

示例4: main

int main() {

  screen s;
  color c;

  c.red = 0;
  c.green = 255;
  c.blue = 255;

  int i, j;

  for( i=0; i<XRES; i++) 
    for ( j=0; j<YRES; j++) {
      /*
      c.red = random() % (MAX_COLOR + 1);
      c.green = random() % (MAX_COLOR + 1);
      c.blue = random() % (MAX_COLOR + 1);
      */
      c.red= 190; 
      c.blue =150; 
      c.green=175; 
      plot( s, c, i, j);
    }

  c.blue=255; 
  c.red =0; 
  c.green = 150; 

  printf("Matrix Testing Area. Please stand well out of range of the matrix that is about to happen.\n"); 

  printf("Making a 3X6 matrix.\n\n"); 
  struct matrix* testing = new_matrix(3,6); 
  add_edge(testing, 1, 11, 1, 2, 12, 1); 
  add_edge(testing, 3, 13, 1, 4, 14, 1); 
  add_edge(testing, 5, 15, 1, 6, 16, 1); 

  printf("Points made. Print test.\n"); 
  print_matrix(testing); 
  printf("Scalar Multiplication Test:\n"); 
  scalar_mult(3, testing); 
  print_matrix(testing); 

  printf("Identity test. Time to face the facts.\n"); 
  struct matrix* identity = new_matrix(6, 6); 
  ident(identity); 
  print_matrix(identity); 

  printf("Testing matrix multiplication. Prepare your eyes. Multiplying by the identity matrix now.\n"); 
  matrix_mult(testing, identity); 
  print_matrix(identity); 


  drawPicture(s, c); 
  display( s );    
  save_ppm(s,  "image" );
  save_extension(s, "image.jpg");
  
}  
开发者ID:stuydw,项目名称:matrix,代码行数:58,代码来源:main.c

示例5: main

int main() {

  screen s;
  color c;

  /* Setup color and screen */

  clear_screen(s);
  
  c.red = 255;
  c.green = 150;
  c.blue = 100;

  /* Setup matrices */
  
  struct matrix *edges;
  struct matrix *transform;

  edges = new_matrix(4, 1);

  /* Finally Testing */
  
  add_edge(edges, 80, 80, 0, 80, 120, 0);
  add_edge(edges, 80, 120, 0, 120, 120, 0);
  add_edge(edges, 120, 120, 0, 120, 80, 0);
  add_edge(edges, 120, 80, 0, 80, 80, 0);

  add_edge(edges, 60, 80, 0, 80, 120, 0);
  add_edge(edges, 80, 120, 0, 100, 100, 0);
  add_edge(edges, 100, 100, 0, 80, 60, 0);
  add_edge(edges, 80, 60, 0, 60, 80, 0);

  add_edge(edges, 90, 90, 0, 110, 90, 0);
  add_edge(edges, 110, 90, 0, 110, 110, 0);
  add_edge(edges, 110, 110, 0, 90, 110, 0);
  add_edge(edges, 90, 110, 0, 90, 90, 0);
  
  draw_lines(edges, s, c);

  int i;
  for (i = 0; i < 40; i+=2) {
    transform = make_translate(i, i, i);
    matrix_mult(transform, edges);
    draw_lines(edges, s, c);
  }  
  
  display(s);
  save_extension(s, "matrix.png");

  /* Free Matrices */
  
  free_matrix( transform );
  free_matrix( edges );

  return 0;
}  
开发者ID:young-k,项目名称:Notes,代码行数:56,代码来源:main.c

示例6: main

int main() {

    screen s;
    color c;

    int x1, y1;

    c.red = MAX_COLOR;
    c.green = MAX_COLOR;
    c.blue = MAX_COLOR;

    clear_screen(s);

    int i, j;

    for (i=0; i < YRES; i++)
        for (j=0; j < XRES; j++ )
            plot(s, c, i, j);

    c.green = 0;
    c.blue = 0;
    
    x1 = 500;
    y1 = 250;
    while (x1 >= 250) {
        draw_line(250, 250, x1, y1, s, c);
        c.red-=2;
        c.green++;
        x1--;
        y1++;
    }
    while (y1 >= 250) {
        draw_line(250, 250, x1, y1, s, c);
        c.green--;
        c.blue--;
        x1--;
        y1--;
    }
    while (x1 <= 250) {
        draw_line(250, 250, x1, y1, s, c);
        c.red++;
        x1++;
        y1--;
    }
    while (y1 <= 250) {
        draw_line(250, 250, x1, y1, s, c);
        c.green++;
        x1++;
        y1++;
    }
    //Note: Display may not work on your system
    //save_ppm and save_extension should be fine
    display(s);
    save_ppm(s, "pic.ppm");
    save_extension(s, "whatevs.png");
}  
开发者ID:stuydw,项目名称:line,代码行数:56,代码来源:main.c

示例7: main

int main() {

  screen s;
  color c;
 
  
  c.red = 0;
  c.green = MAX_COLOR;
  c.blue = 0;
  
  clear_screen(s);


  //octant 1
  draw_line( 0, 0, XRES-1, YRES - 75, s, c);
  //octant 2
  draw_line( 0, 0, XRES - 75, YRES-1, s, c); 
  //octant 8
  draw_line( 0, YRES-1, XRES-1, 75, s, c);  
  //octant 7
  draw_line( 0, YRES-1, XRES - 75, 0, s, c);
  
  c.green = 0;
  c.blue = MAX_COLOR;
  //octant 5
  draw_line( XRES - 1, YRES - 1, 0, 75, s, c);
  //octant 6
  draw_line( XRES - 1, YRES -1, 75, 0, s, c);
  //octant 4
  draw_line( XRES - 1, 0, 0, YRES - 75, s, c);
  //octant 3
  draw_line( XRES - 1, 0, 75, YRES - 1, s, c);
  
  c.blue = 0;
  c.red = MAX_COLOR;
  //y = x, y = -x
  draw_line( 0, 0, XRES - 1, YRES - 1, s, c);
  draw_line( 0, YRES - 1, XRES - 1, 0, s, c);

  //horizontal, vertical line
  draw_line( 0, YRES / 2, XRES - 1, YRES / 2, s, c);
  draw_line( XRES / 2, 0, XRES / 2, YRES - 1, s, c);
  
  int len = 1;
  int i;
  while (i<XRES-1){
    c.blue = (c.blue + 1)%256;
    draw_line(i,i,(i*i)%XRES,i,s,c);
    draw_line(i,i,i,(i*i)%YRES,s,c);
    i++;
  }

  display(s);
  save_extension(s, "lines.png");
}  
开发者ID:ivlin,项目名称:graphics-homeworks,代码行数:55,代码来源:main.c

示例8: main

int main(){

  screen s;
  color c;

  c.red = 0;
  c.green = 0;
  c.blue = MAX_COLOR;

  int ctr = 0;
  while (ctr <= 200){
    draw_line(0, ctr, XRES-1, YRES-1, s, c);
    ctr ++;
    c.red = ctr % MAX_COLOR;
  }

  c.red = 0;
  ctr = 0;
  while (ctr <= 200){
    draw_line(XRES-1, YRES-1, ctr, 0, s, c);
    ctr ++;
    c.green = ctr % MAX_COLOR;
  }

  c.green = 0;
  ctr = 0;
  while (ctr < XRES){
    draw_line(0, 201, ctr, YRES-1, s, c);
    ctr ++;
    c.green = ctr % MAX_COLOR;
  }

  c.green = 0;
  ctr = 0;
  while (ctr < YRES){
    draw_line(201, 0, XRES-1, ctr, s, c);
    ctr ++;
    c.red = ctr % MAX_COLOR;
  }
  
  
  save_extension(s, "pic.png");
  display(s);
  
  return 0;
}
开发者ID:mpapallo,项目名称:Graphics_Work1,代码行数:46,代码来源:coolmain.c

示例9: main

int main() {

  screen s;
  color c;
 
  
  c.red = 0;
  c.green = MAX_COLOR;
  c.blue = 0;
  
  clear_screen(s);


  //octant 1
  draw_line( 0, 0, XRES-1, YRES - 75, s, c);
  //octant 2
  draw_line( 0, 0, XRES - 75, YRES-1, s, c); 
  //octant 8
  draw_line( 0, YRES-1, XRES-1, 75, s, c);  
  //octant 7
  draw_line( 0, YRES-1, XRES - 75, 0, s, c);

  c.green = 0;
  c.blue = MAX_COLOR;
  //octant 5
  draw_line( XRES - 1, YRES - 1, 0, 75, s, c);
  //octant 6
  draw_line( XRES - 1, YRES -1, 75, 0, s, c);
  //octant 4
  draw_line( XRES - 1, 0, 0, YRES - 75, s, c);
  //octant 3
  draw_line( XRES - 1, 0, 75, YRES - 1, s, c);
  
  c.blue = 0;
  c.red = MAX_COLOR;
  //y = x, y = -x
  draw_line( 0, 0, XRES - 1, YRES - 1, s, c);
  draw_line( 0, YRES - 1, XRES - 1, 0, s, c);

  //horizontal, vertical line
  draw_line( 0, YRES / 2, XRES - 1, YRES / 2, s, c);
  draw_line( XRES / 2, 0, XRES / 2, YRES - 1, s, c);
  */
  display(s);
  save_extension(s, "lines.png");
}  
开发者ID:JayStuy,项目名称:line_maker,代码行数:46,代码来源:main.c

示例10: main

int main( int argc, char** argv ) {

  screen s;
  struct matrix *edges;
  struct matrix *transform;
  color c;
  c.red = 0;
  c.green = 255;
  c.blue = 255;

  edges = new_matrix(4, 4);
  transform = new_matrix(4, 4);

  if ( argc == 2 )
    parse_file( argv[1], transform, edges, s );
  else
    parse_file( "stdin", transform, edges, s );

  add_edge( edges, 250,0,0, 250,25,0 );//M                       
  add_edge( edges, 250,25,0, 263,0,0 );
  add_edge( edges, 263,0,0, 275,25,0 );
  add_edge( edges, 275,25,0, 275,0,0 );
  add_edge( edges, 280,0,0, 293,25,0 );//A                      
  add_edge( edges, 293,25,0, 305,0,0 );
  add_edge( edges, 287,13,0, 299,13,0 );
  add_edge( edges, 310,0,0, 325,25,0 );//Y                               
  add_edge( edges, 318,13,0, 305,25,0 );
  add_edge( edges, 330,0,0, 343,25,0 );//A                              
  add_edge( edges, 343,25,0, 355,0,0 );
  add_edge( edges, 337,13,0, 349,13,0 );
  add_edge( edges, 360,0,0, 360,25,0 );//N                         
  add_edge( edges, 360,25,0, 385,0,0 );
  add_edge( edges, 385,0,0, 385,25,0 );
  add_edge( edges, 390,0,0, 390,25,0 );//K                           
  add_edge( edges, 390,13,0, 408,25,0 );
  add_edge( edges, 395,14,0, 408,0,0 );
  draw_lines(edges, s, c);

  save_extension(s, "dimensional.png");
  display(s);

  free_matrix( transform );
  free_matrix( edges );
}  
开发者ID:mayankvanjani,项目名称:mayank_el_3D,代码行数:44,代码来源:main.c

示例11: arguemnts


//.........这里部分代码省略.........
the trig functions int math.h use radian mesure, but us normal
humans use degrees, so the file will contain degrees for rotations,
be sure to conver those degrees to radians (M_PI is the constant
for PI)

jdyrlandweaver
====================*/
void parse_file ( char * filename, 
                  struct matrix * transform, 
                  struct matrix * pm,
                  screen s) {


  double args [6];
  char command [25];

  color c;
  c.red = 255;
  c.blue = 0;
  c.green = 0;

  FILE *f = fopen(filename, "r");


  if(f == NULL) {
    printf("cannot find file\n");
    exit(1);
  }

  while(fgets(command, 25, f)){
    if(command[0] == 'l') {
      fgets(command, 25, f);
      sscanf(command, "%lf %lf %lf %lf %lf %lf", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5]);
      add_edge(pm, args[0], args[1], args[2], args[3], args[4], args[5]);
    }

    else if (command[0] == 'i') {
      ident(transform);
    }

    else if (command[0] == 's') {
      fgets(command, 25, f);
      sscanf(command, "%lf %lf %lf", &args[0], &args[1], &args[2]);
      matrix_mult(make_scale(args[0], args[1], args[2]), transform);
    }

    else if (command[0] == 't') {
      fgets(command, 25, f);
      sscanf(command, "%lf %lf %lf", &args[0], &args[1], &args[2]);
      struct matrix *m;
      m = make_translate(args[0], args[1], args[2]);
      matrix_mult(m, transform);
    }

    else if (command[0] == 'x') {
      fgets(command, 25, f);
      sscanf(command, "%lf", &args[0]);
      struct matrix *m;
      m = make_rotX(args[0]);
      matrix_mult(m, transform);
    }

    else if (command[0] == 'y') {
      fgets(command, 25, f);
      sscanf(command, "%lf", &args[0]);
      struct matrix *m;
      m = make_rotY(args[0]);
      matrix_mult(m, transform);
    }

    else if (command[0] == 'z') {
      fgets(command, 25, f);
      sscanf(command, "%lf", &args[0]);
      struct matrix *m;
      m = make_rotZ(args[0]);
      matrix_mult(m, transform);
    }

    else if (command[0] == 'a') {
      matrix_mult(transform, pm);
    }

    else if (command[0] == 'v') {
      draw_lines(pm, s, c);
    }

    else if (command[0] == 'g') {
      draw_lines(pm, s, c);
      fgets(command, 25, f);
      int i = strlen(command);
      command[i] = '\0';
      save_extension(s, command);
    }

    else if (command[0] == 'q') {
      exit(1);
    }
  }
  
}
开发者ID:stuydw,项目名称:transformations,代码行数:101,代码来源:parser.c

示例12: arguemnts


//.........这里部分代码省略.........
      add_box(pm, x, y, z, width, height, depth);
      //printf( "%lf %lf %lf\n", x, y, z);
    }    
    else if ( strncmp(line, "sphere", strlen(line)) == 0 ) {
      //printf("SPHERE\n");
      fgets(line, 255, f);
      sscanf(line, "%lf %lf %lf", &x, &y, &radius);
      add_sphere(pm, x, y, radius, 0.01);
      //printf( "%lf %lf %lf\n", x, y, z);
    }    
    else if ( strncmp(line, "torus", strlen(line)) == 0 ) {
      //printf("TORUS\n");ds
      fgets(line, 255, f);
      sscanf(line, "%lf %lf %lf %lf", &x, &y, &radius1, &radius2 );
      add_torus(pm, x, y, radius1, radius2, 0.01);
      //printf( "%lf %lf %lf\n", x, y, z);
    }    
    else if ( strncmp(line, "scale", strlen(line)) == 0 ) {
      //printf("SCALE\n");
      fgets(line, 255, f);
      //line[strlen(line)-1]='\0';      
      sscanf(line, "%lf %lf %lf", &x, &y, &z);
      tmp = make_scale(x, y, z);
      matrix_mult(tmp, transform);
      //print_matrix(transform);
    }
    else if ( strncmp(line, "translate", strlen(line)) == 0 ) {
      //printf("TRANSLATE\n");
      fgets(line, 255, f);
      //      line[strlen(line)-1]='\0';      
      sscanf(line, "%lf %lf %lf", &x, &y, &z);
      tmp = make_translate(x, y, z);
      matrix_mult(tmp, transform);
      //print_matrix(transform);
    }
    else if ( strncmp(line, "xrotate", strlen(line)) == 0 ) {
      //printf("ROTATE!\n");
      fgets(line, 255, f);
      sscanf(line, "%lf", &angle);
      angle = angle * (M_PI / 180);
      tmp = make_rotX( angle);
      matrix_mult(tmp, transform);
    }
    else if ( strncmp(line, "yrotate", strlen(line)) == 0 ) {
      //printf("ROTATE!\n");
      fgets(line, 255, f);
      sscanf(line, "%lf", &angle);
      angle = angle * (M_PI / 180);
      tmp = make_rotY( angle);
      matrix_mult(tmp, transform);
    }
    else if ( strncmp(line, "zrotate", strlen(line)) == 0 ) {
      //printf("ROTATE!\n");
      fgets(line, 255, f);
      sscanf(line, "%lf", &angle);
      angle = angle * (M_PI / 180);
      tmp = make_rotZ( angle);
      matrix_mult(tmp, transform);
    }
    else if ( strncmp(line, "ident", strlen(line)) == 0 ) {
      ident(transform);
    }
    else if ( strncmp(line, "apply", strlen(line)) == 0 ) {
      //printf("APPLY!\n");
      //print_matrix( transform );
      //      print_matrix(pm);
      matrix_mult(transform, pm);
    }
    else if ( strncmp(line, "display", strlen(line)) == 0 ) {
      clear_screen(s);
      draw_lines(pm, s, g);
      display(s);
    }
    else if ( strncmp(line, "save", strlen(line)) == 0 ) {
      fgets(line, 255, f);
      // line[strlen(line)-1] = '\0';
      clear_screen(s);
      draw_lines(pm, s, g);
      save_extension(s, line);
    }
    else if ( strncmp(line, "clear", strlen(line)) == 0 ) {
      fgets(line, 255, f);
      // line[strlen(line)-1] = '\0';
      clear_screen(s);
    }
    
    else if ( strncmp(line, "quit", strlen(line)) == 0 ) {
      return;
    }
    else if (strncmp(line, "#", strlen(1)) == 0){
    }
    else {
      printf("Invalid command\n");
    }
  }
  
  free_matrix(tmp);
  fclose(f);
  //printf("END PARSE\n");
}
开发者ID:nspektor,项目名称:3dHW,代码行数:101,代码来源:parser.c

示例13: arguemnts


//.........这里部分代码省略.........
    }
    else if ( strncmp(line, "scale", strlen(line)) == 0 ) {
      fgets(line, 255, f);
      //line[strlen(line)-1]='\0';      
      sscanf(line, "%lf %lf %lf", &x, &y, &z);
      tmp = make_scale(x, y, z);
      //matrix_mult(tmp, transform);
      //print_matrix(transform);
      //matrix_mult( tmp, STACK->data[ STACK->top ] );
      matrix_mult( STACK->data[ STACK->top ], tmp );
      copy_matrix( tmp, STACK->data[ STACK->top ] );
    }
    else if ( strncmp(line, "translate", strlen(line)) == 0 ) {
      //printf("TRANSLATE\n");
      fgets(line, 255, f); 
      sscanf(line, "%lf %lf %lf", &x, &y, &z);
      tmp = make_translate(x, y, z);
      //matrix_mult(tmp, transform);
      //matrix_mult( tmp, STACK->data[ STACK->top ] );
      matrix_mult( STACK->data[ STACK->top ], tmp );
      copy_matrix( tmp, STACK->data[ STACK->top ] );
    }
    else if ( strncmp(line, "xrotate", strlen(line)) == 0 ) {
      //printf("ROTATE!\n");
      fgets(line, 255, f);
      sscanf(line, "%lf", &angle);
      angle = angle * (M_PI / 180);
      tmp = make_rotX( angle);
      //matrix_mult(tmp, transform);
      //matrix_mult( tmp, STACK->data[ STACK->top ] );
      matrix_mult( STACK->data[ STACK->top ], tmp );
      copy_matrix( tmp, STACK->data[ STACK->top ] );
    }
    else if ( strncmp(line, "yrotate", strlen(line)) == 0 ) {
      //printf("ROTATE!\n");
      fgets(line, 255, f);
      sscanf(line, "%lf", &angle);
      angle = angle * (M_PI / 180);
      tmp = make_rotY( angle);
      //matrix_mult(tmp, transform);
      //matrix_mult( tmp, STACK->data[ STACK->top ] );
      matrix_mult( STACK->data[ STACK->top ], tmp );
      copy_matrix( tmp, STACK->data[ STACK->top ] );
    }
    else if ( strncmp(line, "zrotate", strlen(line)) == 0 ) {
      //printf("ROTATE!\n");
      fgets(line, 255, f);
      sscanf(line, "%lf", &angle);
      angle = angle * (M_PI / 180);
      tmp = make_rotZ( angle);
      //matrix_mult(tmp, transform);
      //matrix_mult( tmp, STACK->data[ STACK->top ] );
      matrix_mult( STACK->data[ STACK->top ], tmp );
      copy_matrix( tmp, STACK->data[ STACK->top ] );
    }
    else if ( strncmp(line, "ident", strlen(line)) == 0 ) {
      ident(transform);
    }
    else if ( strncmp(line, "apply", strlen(line)) == 0 ) {
      //printf("APPLY!\n");
      //print_matrix( transform );
      //      print_matrix(pm);
      matrix_mult(transform, pm);
    }
    else if ( strncmp(line, "print", strlen(line)) == 0) {
      print_matrix( STACK->data[ STACK->top ] );
    }
    else if ( strncmp(line, "display", strlen(line)) == 0 ) {
      display(s);
    }
    else if ( strncmp(line, "save", strlen(line)) == 0 ) {
      fgets(line, 255, f);
      // line[strlen(line)-1] = '\0';
      //clear_screen(s);
      //draw_polygons(pm, s, g);
      save_extension(s, line);
    }
    else if ( strncmp(line, "clear", strlen(line)) == 0 ) {
      pm->lastcol = 0;
    }
    else if ( strncmp(line, "quit", strlen(line)) == 0 ) {
      return;
    }
    else if ( strncmp(line, "push", strlen(line)) == 0 ) {
      push( STACK ); //seg fault
      printf("Pushed\n");
    }
    else if ( strncmp(line, "pop", strlen(line)) == 0 ) {
      pop( STACK );
      printf("Popped\n");
    } 
    else if ( line[0] != '#' ) {
      printf("Invalid command\n");
    }
  }
  
  free_matrix(tmp);
  fclose(f);
  //printf("END PARSE\n");
}
开发者ID:RongYu98,项目名称:MDL,代码行数:101,代码来源:parser.c

示例14: main


//.........这里部分代码省略.........
  c.red = 0;
  c.green = MAX_COLOR;
  c.blue = 0;
  
  clear_screen(s);

  /*
  //octant 1
  draw_line( 0, 0, XRES-1, YRES - 75, s, c);  
  //  draw_line( XRES-1, YRES - 75, 0, 0, s, c);  

  //octant 2
  draw_line( 0, 0, XRES - 75, YRES-1, s, c); 
  //octant 8
  draw_line( 0, YRES-1, XRES-1, 75, s, c);  
  //octant 7
  draw_line( 0, YRES-1, XRES - 75, 0, s, c);

  c.green = 0;
  c.blue = MAX_COLOR;
  //octant 5
  draw_line( XRES - 1, YRES - 1, 0, 75, s, c);
  //octant 6
  draw_line( XRES - 1, YRES -1, 75, 0, s, c);
  //octant 4
  draw_line( XRES - 1, 0, 0, YRES - 75, s, c);
  //octant 3
  draw_line( XRES - 1, 0, 75, YRES - 1, s, c);
  
  c.blue = 0;
  c.red = MAX_COLOR;
  //y = x, y = -x
  draw_line( 0, 0, XRES - 1, YRES - 1, s, c);
  draw_line( 0, YRES - 1, XRES - 1, 0, s, c);

  //horizontal, vertical line
  draw_line( 0, YRES / 2, XRES - 1, YRES / 2, s, c);
  draw_line( XRES / 2, 0, XRES / 2, YRES - 1, s, c);

  draw_coord(s, c);
  draw_border(s, c);
  */
  c.red = MAX_COLOR;
  c.green = 0;
  c.blue = 0;
  for ( i = 0; i < XRES; i+=6 ) {
    draw_line( XRES / 2, YRES / 2, i, 0, s, c );
    c.red = c.red - 3;
    c.green = c.green + 3;
  }

  c.red = 0;
  c.green = MAX_COLOR;
  for ( i = 0; i < YRES; i+=6 ) {
    draw_line( XRES / 2, YRES / 2, YRES, i, s, c );
    c.green = c.green - 3;
    c.blue = c.blue + 3;
  }

  c.green = 0;
  c.blue = MAX_COLOR;
  for (i = 0; i < XRES; i+=6 ) {
    draw_line( XRES / 2, YRES /2, XRES - i, YRES, s, c );
    c.blue = c.blue - 3;
    c.green += 3;
    c.red += 3;
  }

  c.blue = 0;
  for (i = 0; i < XRES; i+=6 ) {
    draw_line( XRES / 2, YRES /2, 0, YRES - i, s, c );
    c.green -= 3;
  }

  for ( i = 0; i < XRES; i++ ) {
    for ( j = 0; j < YRES; j++ ) {
      if ( i % 100 <= 3 || j % 100 <= 3 ) {
	c.red = MAX_COLOR;
	c.green = MAX_COLOR / 2 + 50;
	c.blue = MAX_COLOR;
	plot (s, c, i, j);
      }
    }
  }

  for ( i = 0; i < XRES; i+=10 ) {
    c.red = 0;
    c.green = 0;
    c.blue = 0;
    draw_line( i, 0, 0, i, s, c );
    draw_line( i, 0, YRES - i, XRES, s, c );
    draw_line( 0, i, XRES, YRES - i, s, c );
  }

  draw_border(s, c);

  save_extension(s, "lines.png");  
  display(s);

}  
开发者ID:mayankvanjani,项目名称:mayank_el_lines,代码行数:101,代码来源:main.c

示例15: arguments


//.........这里部分代码省略.........
      add_curve(pm, x1, y1, x2, y2, x3, y3, x4, y4, 0.01, BEZIER_MODE );
      //printf( "%lf %lf %lf\n", x, y, z);
      break;
    case 'h':
      fgets(line, 255, f);
      sscanf(line, "%lf %lf %lf %lf %lf %lf %lf %lf",
	     &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
      add_curve(pm, x1, y1, x2, y2, x3, y3, x4, y4, 0.01, HERMITE_MODE );
      //printf( "%lf %lf %lf\n", x, y, z);
      break;
    case 's':
      //printf("SCALE\n");
      fgets(line, 255, f);
      //line[strlen(line)-1]='\0';      
      sscanf(line, "%lf %lf %lf", &x, &y, &z);
      tmp = make_scale(x, y, z);
      matrix_mult(tmp, transform);
      //print_matrix(transform);
      break;
    case 't':
      //printf("TRANSLATE\n");
      fgets(line, 255, f);
      //      line[strlen(line)-1]='\0';      
      sscanf(line, "%lf %lf %lf", &x, &y, &z);
      tmp = make_translate(x, y, z);
      matrix_mult(tmp, transform);
      //print_matrix(transform);
      break;
    case 'x':
      //printf("ROTATE!\n");
      fgets(line, 255, f);
      sscanf(line, "%lf", &angle);
      angle = angle * (M_PI / 180);
      tmp = make_rotX( angle);
      matrix_mult(tmp, transform);
      break;
    case 'y':
      //printf("ROTATE!\n");
      fgets(line, 255, f);
      sscanf(line, "%lf", &angle);
      angle = angle * (M_PI / 180);
      tmp = make_rotY( angle);
      matrix_mult(tmp, transform);
      break;
    case 'z':
      //printf("ROTATE!\n");
      fgets(line, 255, f);
      sscanf(line, "%lf", &angle);
      angle = angle * (M_PI / 180);
      tmp = make_rotZ( angle);
      matrix_mult(tmp, transform);
      break;
    case 'i':
      ident(transform);
      break;
    case 'a':
      //printf("APPLY!\n");
      //print_matrix( transform );
      //      print_matrix(pm);
      matrix_mult(transform, pm);
      break;
    case 'v':
 
      /*
      clear_screen(s);
      draw_lines(pm, s, g);
      display(s);
      break;
      */
      
      // Second version for triangles:
      clear_screen(s);
      draw_polygons(pm, s, g);
      display(s);
      break;
      
    case 'w':
      pm->lastcol = 0;
      break;
    case 'g':
      fgets(line, 255, f);
      // line[strlen(line)-1] = '\0';
      clear_screen(s);
      draw_polygons(pm, s, g);
      save_extension(s, line);
      break;
    case 'q':
      return;
    case '#':
      break;
    default:
      printf("Invalid command\n");
      break;
    }
  }

  free_matrix(tmp);
  fclose(f);
  //printf("END PARSE\n");
}
开发者ID:stuydw,项目名称:polygons,代码行数:101,代码来源:parser.c


注:本文中的save_extension函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。