topical media & game development
lib-ch-example-sample-plot2-11.cgi / cgi
#!/bin/ch
/* use data from a file */
include <stdio.h>
include <math.h>
include <numeric.h>
include <chplot.h>
int main() {
string_t file;
int i;
class CPlot plot;
FILE *out;
setvbuf(stdout, NULL, _IONBF, 0);
printf("Content-type: image/png\n\n");
file = tmpnam(NULL); //Create temporary file.
out=fopen (file,"w"); //Write data to file.
for(i=0;i<=359;i++)
fprintf(out,"\%i \%f \n",i,sin(i*M_PI/180));
fclose(out);
plot.dataFile(file);
plot.outputType(PLOT_OUTPUTTYPE_STREAM, "png");
plot.plotting();
remove(file);
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.