Пример #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
void cleanUp(plPlotter* plotter) {
	/* close and cleanup the plotter */
	if(pl_closepl_r(plotter) < 0) {
		fprintf(stderr, "Couldn't close plotter \n");
	} else if( pl_deletepl_r(plotter) < 0) {
		fprintf(stderr, "Couldn't delete plotter\n");
	}
}
Пример #3
0
size_t
free_plotter (SCM x)
{
  plPlotter *plotter;

  assert (SCM_SMOB_PREDICATE (plotter_tag, x));

  plotter = (plPlotter *) SCM_SMOB_DATA (x);
  /* Plotters should already be null if delwin has been called on them */
  if (plotter != NULL)
    {
      pl_deletepl_r (plotter);
      SCM_SET_SMOB_DATA (x, 0);
    }

  return 0;
}
Пример #4
0
static void
PyLibPlot_dealloc(struct PyLibPlot* self)
{
    if (self->pl) {
        pl_deletepl_r(self->pl);
    }

    // must be closed *after* deleting the plPlotter
    if (self->fptr != NULL) {
        fclose(self->fptr);
    }

#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 6) || (PY_MAJOR_VERSION == 3))
    Py_TYPE(self)->tp_free((PyObject*)self);
#else
    self->ob_type->tp_free((PyObject*)self);
#endif

}
Пример #5
0
/* user-callable */
int
pl_deletepl (int handle)
{
  if (handle < 0 || handle >= _old_api_plotters_len 
      || _old_api_plotters[handle] == NULL)
    {
      _api_warning ("ignoring request to delete a nonexistent plotter");
      return -1;
    }

  if (_old_api_plotters[handle] == _old_api_plotter)
    {
      _api_warning ("ignoring request to delete currently selected plotter");
      return -1;
    }

  /* delete Plotter by invoking function in new API */
  pl_deletepl_r (_old_api_plotters[handle]);

  /* remove now-invalid pointer from local array */
  _old_api_plotters[handle] = NULL;

  return 0;
}