int main(){ int x; G_init_graphics(600,600); int i; char prefix[100], filename[100]; strncpy(prefix, "tetrahedron", 100); scanf("%s", textureName); //tetrahedron0000 //14 for(i=0; i < 73; i++){ printf("%d\n", i); init_scene(i); sprintf(filename, "%s%04d", prefix, i); filename[15] = '.'; filename[16] = 'x'; filename[17] = 'w'; filename[18] = 'd'; G_save_image_to_file(filename); G_wait_key(); G_rgb(1,1,1); G_clear(); } //main->init scene->draw }
int main (int argc, char **argv) { int w,h,nrows, ncols ; double r[2],g[2],b[2] ; int i,j,k,q ; double dx,dy ; if (argc != 12) { printf("Usage : pgm xwd_res_file_name width height nrows ncols r0 g0 b0 r1 g1 b1\n") ; exit(0) ; } w = atoi(argv[2]) ; h = atoi(argv[3]) ; nrows = atoi(argv[4]) ; ncols = atoi(argv[5]) ; r[0] = atof(argv[6]) ; g[0] = atof(argv[7]) ; b[0] = atof(argv[8]) ; r[1] = atof(argv[9]) ; g[1] = atof(argv[10]) ; b[1] = atof(argv[11]) ; G_init_graphics(w,h) ; G_rgb(0,1,0) ; G_clear() ; // reveals a green bottom line...error in FPT's G_fill_rectangle // ...now fixed dx = 1.0*w/ncols ; dy = 1.0*h/nrows ; for (i = 0 ; i < ncols ; i++) { for (j = 0 ; j < nrows ; j++) { k = (i + j) % 2 ; G_rgb(r[k],g[k],b[k]) ; G_fill_rectangle(i*dx,j*dy,dx,dy) ; } } q = G_wait_key() ; G_save_image_to_file(argv[1]) ; }
int main () { char prefix[100], sequence_name[100] ; int s,e,i ; double f ; printf("enter prefix name ") ; scanf("%s",prefix) ; printf("enter starting integer ") ; scanf("%d",&s) ; printf("enter ending integer ") ; scanf("%d",&e) ; /* printf("\n") ; for (i = s ; i <= e ; i++) { sprintf(sequence_name, "%s%04d.xwd", prefix, i) ; printf("%s\n",sequence_name) ; } */ G_init_graphics(400,400) ; for (i = s ; i <= e ; i++) { G_rgb(0,0,0) ; G_clear() ; f = 1.0*i/(e - s + 1) ; G_rgb(1,f,0) ; G_fill_circle(200,200,i) ; sprintf(sequence_name, "%s%04d.xwd", prefix, i) ; G_save_image_to_file(sequence_name) ; } G_close() ; }
int main() { double swidth, sheight ; double lowleftx, lowlefty, width, height ; double x[10],y[10] ; double numpoints,q, x0,y0,x1,y1 ; double p[2] ; // must do this before you do 'almost' any other // graphical tasks swidth = 400 ; sheight = 400 ; G_init_graphics (swidth, sheight) ; // draw a point, a line, some rectangles, some triangles G_rgb(1, 0, 0) ; // red G_point(200, 380) ; G_rgb(0, 1, 0) ; // green // G_line (0, 0, 400, 400) ; // won't show if part is off screen G_line (0, 0, 399, 399) ; G_rgb(0, 0, 1) ; // blue lowleftx = 200 ; lowlefty = 50 ; width = 10 ; height = 30 ; G_rectangle (lowleftx, lowlefty, width, height) ; lowleftx = 250 ; G_fill_rectangle (lowleftx, lowlefty, width, height) ; G_rgb(1, 1, 0) ; // yellow G_triangle (10, 300, 40,300, 60,250) ; G_fill_triangle (10,100, 40,100, 60,150) ; G_rgb(1, 0.5, 0) ; // orange G_circle (100, 300, 75) ; G_fill_circle (370, 200, 50) ; // prints text in your graphics window G_rgb(0, 0, 0) ; // black G_draw_string ("hello",300,100) ; // draw a polygon x[0] = 100 ; y[0] = 100 ; x[1] = 100 ; y[1] = 300 ; x[2] = 300 ; y[2] = 300 ; x[3] = 300 ; y[3] = 100 ; x[4] = 200 ; y[4] = 175 ; numpoints = 5 ; G_polygon (x,y,numpoints) ; q = G_wait_key() ; // pause to look ...any key to continue G_rgb (0.4, 0.2, 0.1) ; // brown G_fill_polygon (x,y,numpoints) ; G_rgb (0.5, 0.8, 0.4) ;// what color is this? G_wait_click(p) ; // wait for a mouse click x0 = p[0] ; y0 = p[1] ; // extract coordinates G_fill_rectangle (x0-2, y0-2, 4,4) ;// mark the clicked point G_wait_click(p) ; x1 = p[0] ; y1 = p[1] ; G_fill_rectangle (x1-2, y1-2, 4,4) ; G_rgb (0.5, 0.5, 0.5) ; // a grey G_line (x0,y0, x1,y1) ; q = G_wait_key() ; // pause again before exit G_save_image_to_file ("t01c.xwd") ; G_close() ; // terminate graphics...probably not fatal if forgotten }
int main() { // analog clock using double buffering...simpler double hours,minutes,seconds,x,y,nx,ny,theta,digit ; double hx,hy,mx,my,sx,sy,angle ; double oldhourtheta,oldminutetheta,oldsecondtheta ; char text[3] ; double hms[3] ; double xx[100],yy[100] ; int num ; G_init_graphics(600,600) ; while (0 < 1) { // blank the window G_rgb(0.3, 0.3, 0.3) ; G_clear() ; // outer circle of the clock face G_rgb(0,0,1) ; G_fill_circle(300,300,230) ; G_rgb (1,0.5,0) ; G_fill_circle(300,300,220) ; // digits on the clock face G_rgb (0,0,0) ; theta = 90 ; // degrees digit = 0 ; while (theta > -270) { theta = theta - 30 ; digit = digit + 1 ; nx = 200*cos(theta*M_PI/180) + 300 ; ny = 200*sin(theta*M_PI/180) + 300 ; if (digit >= 10) { text[0] = '1' ; text[1] = '0' + digit - 10 ; text[2] = '\0' ; } else { text[0] = '0' + digit ; text[1] = '\0' ; } G_draw_string(text,nx-5,ny-5) ; } // get_timeD(hms) ; // hours = hms[0] ; // minutes = hms[1] ; // seconds = hms[2] ; printf("enter hours minutes seconds") ; scanf("%lf %lf %lf",&hours,&minutes,&seconds) ; G_rgb (0,0,0) ; // set the second hand theta = 90 - 6*seconds ; angle = theta*M_PI/180 ; sx = 175*cos(angle) + 300 ; sy = 175*sin(angle) + 300 ; // G_line(300,300,sx,sy) ; num = make_arrow (300,300, sx,sy, 3.0, xx,yy) ; G_fill_polygon(xx,yy,num) ; // set the minute hand theta = 90 - 6*(minutes + seconds/60.0) ; angle = theta*M_PI/180 ; mx = 140*cos(angle) + 300 ; my = 140*sin(angle) + 300 ; // G_line(300,300,mx,my) ; num = make_arrow (300,300, mx,my, 3.0, xx,yy) ; G_fill_polygon(xx,yy,num) ; // set the hour hand theta = 90 - 30*(hours + minutes/60.0 + seconds/3600.0) ; angle = theta*M_PI/180 ; hx = 75*cos(angle) + 300 ; hy = 75*sin(angle) + 300 ; // G_line(300,300,hx,hy) ; num = make_arrow (300,300, hx,hy, 3.0, xx,yy) ; G_fill_polygon(xx,yy,num) ; G_rgb(0,0,0) ; G_fill_circle(300,300,12) ; G_display_image() ; break ; } // end while (0 < 1) G_save_image_to_file("clock.xwd") ; }