예제 #1
0
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);
    
}
예제 #2
0
/* Draws 5 planets (should draw 6 but sleep or flushpl is weird) */
void plot(plPlotter* plotter) {
	double scalar = 250000000000;
	for(int i = 0; i <= PLANETS; i++) {
		pl_flushpl_r(plotter);
		pl_pencolorname_r(plotter, "white");
		pl_fillcolorname_r(plotter, array[i].color);
		pl_fcircle_r(plotter, array[i].xPos, array[i].yPos, array[i].size*scalar);
		pl_flushpl_r(plotter);
	}
}
예제 #3
0
/* draws over previous planets in black */
void deletePlot(plPlotter* plotter) {
	double scalar = 250000000000;
	usleep(50000);
	for(int i = 0; i <= PLANETS; i++) {
		pl_flushpl_r(plotter);
		pl_pencolorname_r(plotter, "black");
		pl_fillcolorname_r(plotter, "black");
		pl_fcircle_r(plotter, array[i].xPos, array[i].yPos, array[i].size*scalar);
		pl_flushpl_r(plotter);
	}
}