ftp.nice.ch/pub/next/unix/developer/plplot.3.0.s.tar.gz#/plplot/examples/example13.c

This is example13.c in view mode; [Download] [Up]

/* Demonstration program for PLPLOT: */
#include <stdio.h>
#include <math.h>

#define PI      3.141592654

static char *text[] = {
   "Howard",
   "Bobby",
   "Georgios",
   "Davendra"
};

main()
{
   int i, j;
   double dthet, theta0, theta1, theta, just, dx, dy;
   static FLOAT x[400], y[400], per[4];

   per[0] = 10.;
   per[1] = 40.;
   per[2] = 15.;
   per[3] = 35.;

   /* Ask user to specify the output device */
   plstar(1,1);

   plenv(0.,10.,0.,10.,1,-2);
   plcol(2);

   theta0 = 0.;
   dthet = 2*PI/400;
   for(i=0; i<=3; i++) {
      j = 0;
      x[j] = 5.;
      y[j++] = 5.;
      theta1 = theta0 + 2*PI*per[i]/100.;
      if(i==3) theta1 = 2*PI;
      for(theta = theta0; theta <=theta1; theta += dthet){
         x[j] = 5 + 3*cos(theta);
         y[j++] = 5 + 3*sin(theta);
      }
      plcol(i+1);
      plpsty((i+3)%8+1);
      plfill(j,x,y);
      plcol(1);
      plline(j,x,y);
      just = (theta0+theta1)/2.;
      dx = .25*cos(just);
      dy = .25*sin(just);
      if(just < PI/2 || just > 3*PI/2) {
         just = 0.;
      }
      else {
         just = 1.;
      }
      plptex(x[j/2]+dx,y[j/2]+dy,1.,0.,just,text[i]);
      theta0 = theta-dthet;
   }
   plfont(2);
   plschr(0.,1.3);
   plptex(5.,9.,1.,0.,.5,"Percentage of Sales");

   /* Don't forget to call PLEND to finish off! */
   plend();
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.