Sindbad~EG File Manager

Current Path : /usr/home/beeson/MathXpert/cgraph/
Upload File :
Current File : /usr/home/beeson/MathXpert/cgraph/grpaperSamples.c

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>  /* frexp */
#include <stdio.h> /* for printf debugging output */

#include "globals.h"
//#include "mp2.h"
#include "mathpert.h"
#include "graphstr.h"  /* graph */
#include "svgGraph.h"
#include "grpaper.h"
#include "grafinit.h"  /* needs_circular_aspect */
#include "deval.h"   /* nearint */
#include "tdefn.h"

// 2.16.25  removed unused  xgap1, xgap2, ygap1, ygap2 

static void GraphPaperSample(int index, int size, char *outbuffer, int bytesavailable);
/*___________________________________________________________________*/
static void GraphPaperSample(int index, int size, char *outbuffer, int bytesavailable)
/* Produce a size-pixel-square sample of
the graph paper with the specified index, and write it in SVG to outbuffer,
which is assumed to have bytesavailable bytes of space.
*/
{ GraphPaper H = GetGraphPaper(index);
  GraphPaper *G = &H;
  rect r;
  if(index > NGRAPHPAPERS)
     { printf("%s", "illegal index of graph paper\n");
       return;
     }
  r.left = r.top = 0;
  r.right = r.bottom = size/2;
  set_svgDevice(outbuffer, bytesavailable,&r);
  char id[32];
  sprintf(id,"sample%d",index);
  begin_svg("GraphPaperSample", id);
  /* Since drawing will be done in world coordinates
  we must determine what world coordinates correspond
  to the spacings specified in the GraphPaper.  Those
  spacings are specified in printer's points.
  */
  double a,b,c,d;
  a = -size/2;
  b = size/2;
  c = -size/2;
  d = size/2;
  set_world(a,b,c,d);
  set_graphpencolor(G->background); // so no border, as the foreground color is used for the border
  set_graphbackgroundcolor(G->background);
  filled_rect(a,c,b,d);
  drawGraphPaper(G,a,b,c,d);
  set_graphpencolor(G->axescolor);
  set_linewidth(G->thickness1);
  begin_path();
  move_to(-size/2,0);
  line_to(size/2,0);
  move_to(0,-size/2);
  line_to(0,size/2);
  end_path();
  end_svg();
}
/*_________________________________________________________*/
// this is used by temporarily calling it in main()
// to create an svg file of graph paper samples

void printSamples(void)
// print them to a file
{ static char outbuffer[3000000];
  static char *outfile = "/users/beeson/Dropbox/Sites/WebMathXpert/NewSamples.svg";
  // don't overwrite graphPaperSamples.svg in case something goes wrong
  FILE *fp = fopen(outfile,"w");
  int n;
  for(n=0;n<NGRAPHPAPERS;n++)
    {  memset(outbuffer,0,3000000);
       GraphPaperSample(n,148,outbuffer,3000000);
       fprintf(fp,"%s", outbuffer);
    }
  fclose(fp);
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists