void drawGIF( char* outputName, char* ieq, double xmin, double xmax, double ymin, double ymax, char* pass, char* fail ) { int i, j; //Open the output file FILE* outFile = fopen(outputName, "w"); if (outFile==NULL) { fprintf(stderr, "ERR: failed to open file.\n"); exit(1); } //Initialize the plotter plPlotterParams *pParams = pl_newplparams(); pl_setplparam(pParams, "BITMAPSIZE", "500x500"); plPlotter* p = pl_newpl_r("gif", stdin, outFile, stderr, pParams); //Set the plotter pl_openpl_r(p); pl_fspace_r(p, 0, 0, 500, 500); //Get the array values char*** colorArr = createImgArr(ieq, 500, 500, xmin, xmax, ymin, ymax, pass, fail); //Set the pixels for (i = 0; i < 500; i++){ for (j = 0; j < 500; j++){ pl_pencolorname_r(p, colorArr[i][j]); pl_fpoint_r(p,i,j); } } //cleanup freeImgArr(colorArr, 500); pl_endsubpath_r(p); pl_closepl_r(p); pl_deletepl_r(p); fclose(outFile); }
/* set up the plotter and the params */ plPlotter* setUp() { plPlotter* plotter; plPlotterParams* plotterParams; /* create a plotter parametric structure */ plotterParams = pl_newplparams(); pl_setplparam(plotterParams, "BITMAPSIZE", "750x750"); pl_setplparam(plotterParams, "USE_DOUBLE_BUFFERING", "no"); pl_setplparam(plotterParams, "BG_COLOR", "black"); /* create the plotter device and open it */ if((plotter = pl_newpl_r("X", stdin, stdout, stderr, plotterParams)) == NULL) { fprintf(stderr, "Couldn't create Xwindows plotter\n"); exit(1); } else if(pl_openpl_r(plotter) < 0) { fprintf(stderr, "Couldn't open Xwindows plotter\n"); exit(1); } /* set our coordinate space in the plotter window */ double winSize = windowSize(PLANETS); pl_fspace_r(plotter, -winSize, -winSize, winSize, winSize); /* pick a type for the pen and the fill */ pl_pentype_r(plotter, 1); pl_filltype_r(plotter, 1); return plotter; }