home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / m / m242 / 3.ddi / DEMOS1.ZIP / PIE3D.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-16  |  1.9 KB  |  76 lines

  1. /* This program will draw 6-slice 3D pie chart */
  2. #include "stdio.h"
  3. #include "conio.h"
  4. #include "eg_proto.h"
  5.  
  6. int val[6]={5,4,3,2,3,2};
  7. extern  int main(void );
  8.  
  9. main() {
  10.     int num=10,den=25;        /* aspect ratio */
  11.     int e=24,off=40;            /* exploded the 4th and 5th slices by 40 pixels */
  12.     int width=30;                /* width of the pie */
  13.     int pos=3;                    /* position of the labels, in this case no label
  14.                                         but legend */
  15.     int tdnpie=6;                /* pie which has 6 slices */
  16.     int radius=150,x0=320,y0=165;        /* data for the pie */
  17.     int location=9;            /* location where to put the legend */
  18.     int border=1;                /* border for the legend */
  19.     int linec=12,labelc=12;
  20.     int i,fn=0,fn1=1;         /* bit map font */    
  21.     int titlec=12;                /* color for the title */    
  22.     int borderc=12;            /* border's color of the pie */
  23.     struct vfont *vfn;       /* vector font to use */
  24.  
  25.     /* set the EGA mode 16 */
  26.     setega();
  27.     initgraf(16,0,0); 
  28.  
  29.     /* set the world coordinate */    
  30.     setview(0,0,639,349);
  31.     setworld(0,0,639,349);
  32.     worldon(1);
  33.  
  34.     /* load the ibmrom */
  35.     fontinit();
  36.     if ((font_load(fn,"ibmrom"))!=0) {
  37.         printf("Wrong from loading ibmrom\n");
  38.         exit(0);
  39.         }
  40.     if ((font_load(fn1,"roman3.sms"))!=0) {
  41.         printf("Wrong from loading ibmrom\n");
  42.         exit(0);
  43.         }
  44.  
  45.     /* set aspect ratio */
  46.     setaspec(num,den);
  47.  
  48.     /* using the default hatching style */
  49.       color_hatch();
  50.  
  51.     /* set 3D pie */
  52.     i = td_pie_set(tdnpie,fn,pos,width,linec,labelc);
  53.     td_pie_legend(location,border);
  54.     /* for labeling */
  55.     td_pie_slice(0,1,1,"Jan-Feb");
  56.     td_pie_slice(1,2,2,"Mar-Apr");
  57.     td_pie_slice(2,3,3,"May-Jun");
  58.     td_pie_slice(3,4,4,"Jul-Aug");
  59.     td_pie_slice(4,5,5,"Sep-Oct");
  60.     td_pie_slice(5,6,6,"Nov-Dec"); 
  61.  
  62.     /* put the title */
  63.     td_title(TOP,"South Mountain Software",titlec,fn1,vfn); 
  64.             
  65.     /* for the 3D pie */
  66.     i = td_pie(x0,y0,radius,e,borderc,off,val); 
  67.  
  68.     /* free fonts */
  69.     fontquit();
  70.  
  71.     /* return to the text mode */
  72.     getch();
  73.     initgraf(3,0,0);
  74.     return(0);
  75. }
  76.