Article View: comp.lang.postscript
Article #5913Re: Need postscript library callable from C
From: Jonathan Monsarrat
Date: Mon, 14 Dec 1992 19:28
Date: Mon, 14 Dec 1992 19:28
54 lines
2197 bytes
2197 bytes
> Is there any public domain postscript library that is callable from C?
It depends what you want to draw. I've written programs both for:
1. drawing a picture which is to be viewed later
and 2. drawing a picture which is to be viewed while the program's running
I can email sample code to anyone who is interested in this stuff.
Basically, however, it's just a matter of sending PostScript commands
either:
1. to a file
or 2. to GhostScript, using the "flushpage" command to force the screen
to be updated
And this means that you have to know PostScript programming.
If there were some library calls, there would be a very simple mapping
to PostScript, so you either learn the library or you learn PostScript.
Learning some simple PostScript is not hard.
-------------------------------
psline(x1, y1, x2, y2)
printf("%d %d moveto %d %d lineto stroke\n", x1, y1, x2, y2);
-------------------------------
psopen() would just be either
1. opening the file
or 2. popen() to GhostScript
-------------------------------
pstext(x1, y1, str);
Would just be
printf("Times-Roman findfont 12 scalefont setfont\n");
printf("%d %d moveto (%s) show\n", x1, y1, str);
------------------------------
psclose();
Would close the file pointer to either
1. the file you opened
2. the popen()
-Jon
%! Jon Monsarrat jgm@cs.brown.edu Brown University %! Obfuscated PostScript
/p 4/f{{}forall moveto gsave{dup 32 mod dup 15 mul rotate sub p div 0 rlineto}
forall fill grestore}def 4 scale 1 def(``f`f`f)dup( )f( i).3 setgray f/p 8 def
1 setgray/h(F!6! 2477!W)def h("4)h(,C)h(6O)h(LT)h(^O)h(tC)h(~6)(7!6!"7#$&6!7 #)
(9~)(""""""""""")(}~)(fTV``Vt)(9!)(e!FR"n&44ED-w@-7&&b)(C2)11{f}repeat showpage
Technical Details
Message-ID:
<1992Dec14.192801.24379@cs.brown.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!jgmReferences:
<Bz9HvB.74w@news.cso.uiuc.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.postscript Path: arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!jgm From: jgm@cs.brown.edu (Jonathan Monsarrat) Subject: Re: Need postscript library callable from C Message-ID: <1992Dec14.192801.24379@cs.brown.edu> Sender: news@cs.brown.edu Organization: Brown University Department of Computer Science References: <Bz9HvB.74w@news.cso.uiuc.edu> Date: Mon, 14 Dec 1992 19:28:01 GMT Lines: 54