home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344b.lha / plplot_v2.6 / examples / example13.c < prev   
Encoding:
C/C++ Source or Header  |  1990-01-27  |  1.3 KB  |  68 lines

  1. /* Demonstration program for PLPLOT: */
  2.  
  3. #include "plplot.h"
  4. #include <stdio.h>
  5. #include <math.h>
  6.  
  7. static char *text[] = {
  8.    "Howard",
  9.    "Bobby",
  10.    "Georgios",
  11.    "Davendra"
  12. };
  13.  
  14. main()
  15. {
  16.    int i, j;
  17.    PLFLT dthet, theta0, theta1, theta, just, dx, dy;
  18.    static PLFLT x[400], y[400], per[4];
  19.  
  20.    per[0] = 10.;
  21.    per[1] = 40.;
  22.    per[2] = 15.;
  23.    per[3] = 35.;
  24.  
  25.    /* Ask user to specify the output device */
  26.    plstar(1,1);
  27.  
  28.    plenv(0.,10.,0.,10.,1,-2);
  29.    plcol(2);
  30.  
  31.    theta0 = 0.;
  32.    dthet = 2*PI/400;
  33.    for(i=0; i<=3; i++) {
  34.       j = 0;
  35.       x[j] = 5.;
  36.       y[j++] = 5.;
  37.       theta1 = theta0 + 2*PI*per[i]/100.;
  38.       if(i==3) theta1 = 2*PI;
  39.       for(theta = theta0; theta <=theta1; theta += dthet){
  40.          x[j] = 5 + 3*cos(theta);
  41.          y[j++] = 5 + 3*sin(theta);
  42.       }
  43.       plcol(i+1);
  44.       plpsty((i+3)%8+1);
  45.       plfill(j,x,y);
  46.       plcol(1);
  47.       plline(j,x,y);
  48.       just = (theta0+theta1)/2.;
  49.       dx = .25*cos(just);
  50.       dy = .25*sin(just);
  51.       if(just < PI/2 || just > 3*PI/2) {
  52.          just = 0.;
  53.       }
  54.       else {
  55.          just = 1.;
  56.       }
  57.       plptex(x[j/2]+dx,y[j/2]+dy,1.,0.,just,text[i]);
  58.       theta0 = theta-dthet;
  59.    }
  60.    plfont(2);
  61.    plschr(0.,1.3);
  62.    plptex(5.,9.,1.,0.,.5,"Percentage of Sales");
  63.  
  64.    /* Don't forget to call PLEND to finish off! */
  65.    plend();
  66. }
  67.  
  68.