chiark / gitweb /
Provide "help". Print a prompt
[moebius.git] / postscript.cc
1 /*
2  * PostScript output
3  */
4
5 #include <iostream.h>
6 #include "postscript.hh"
7
8 PostScriptOutput::PostScriptOutput(ofstream& f)
9 : file(f) {
10
11   file <<
12     "%!PS-Adobe-2.0 EPSF-2.0\n"
13     "%%Creator: moebius\n"
14     "%%BoundingBox: -500 -500 500 500\n"
15     "%%Pages: 1\n"
16     "%%DocumentFonts: \n"
17     "%%EndComments\n"
18     "    1 setlinecap 1 setlinejoin 0.002 setlinewidth\n"
19     "    500 500 scale\n"
20     "%%EndProlog\n"
21     "%%Page: 1 0\n"
22     "    save\n";
23 }
24
25 PostScriptOutput::~PostScriptOutput() {
26   file <<
27     "    restore\n"
28     "%%Trailer\n"
29     "%%EOF\n";
30 }
31
32 void PostScriptOutput::drawcell(const Point* list, int n) {
33   Onscreen p[4];
34   for (int i=0; i<4; i++) p[i]= Onscreen(list[i]);
35   docell(p,n,"1 setgray fill");
36   docell(p,n,"0 setgray stroke");
37 }
38
39 void PostScriptOutput::docell(const Onscreen* list, int n, const char *what) {
40   file << "    newpath\n";
41   file << "        " << list->x << " " << list->y << " moveto\n";
42   list++;
43   for (int i=1; i<n; i++, list++) {
44     file << "        " << list->x << " " << list->y << " lineto\n";
45   }
46   file << "      closepath  " << what << "\n";
47 }