home *** CD-ROM | disk | FTP | other *** search
- /* Demonstration program for PLPLOT: */
-
- #include "plplot.h"
- #include <stdio.h>
- #include <math.h>
-
- static char *text[] = {
- "Howard",
- "Bobby",
- "Georgios",
- "Davendra"
- };
-
- main()
- {
- int i, j;
- PLFLT dthet, theta0, theta1, theta, just, dx, dy;
- static PLFLT 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();
- }
-
-