home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / graphics / 14160 < prev    next >
Encoding:
Text File  |  1993-01-24  |  3.4 KB  |  135 lines

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!darwin.sura.net!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!uknet!turing!coulin!arthur
  2. From: arthur@turing.ac.uk (Arthur van Hoff)
  3. Newsgroups: comp.graphics
  4. Subject: PDB -- ANSI-C to PostScript compiler
  5. Message-ID: <ARTHUR.93Jan24181634@lurch.turing.ac.uk>
  6. Date: 24 Jan 93 18:22:45 GMT
  7. Sender: usenet@turing.ac.uk (Usenet for nntp)
  8. Organization: The Turing Institute Ltd., Glasgow, Scotland
  9. Lines: 124
  10.  
  11.  
  12. Hi PostScript Hackers,
  13.  
  14. PdB version 2.1 (ANSI-C to PostScript compiler) is now available
  15. via anonymous ftp from:
  16.  
  17.      turing.com (192.133.90.28) in pub/pdb2.1-demo.tar.Z
  18.      ftp.uu.net (192.48.96.9) in graphics/NeWS/pdb2.1-demo.tar.Z
  19.  
  20. There is no more need to write PostScript! Start using PdB right now!
  21. PdB is an optimizing compiler to compile ANSI-C (like) code into Adobe
  22. compatible PostScript. It includes executables, examples and many 
  23. useful header files. Note that it is not dependend on NeWS.
  24.  
  25. The release of version 2.1 includes:
  26.  
  27. - Binaries for Sun SPARC station and IBM RS6000.
  28. - Include files for Abobe PostScript level I.
  29. - Include files for NeWS upto version 3.1.
  30. - Include files for TNT upto version 3.1.
  31. - Support for CPS OpenWindows upto version 3.1.
  32. - Support NeWS classing in a C++ manner.
  33. - Plenty of examples of all the above functions.
  34. - NeWS/OpenWindows test suite.
  35. - PostScript reference manual.
  36. - UNIX manual pages.
  37.  
  38. Below are some examples of PdB code together with the PostScript
  39. produced by the compiler.
  40.  
  41. Have fun,
  42.  
  43.     Arthur van Hoff
  44.     pdb@turing.com
  45.  
  46.  
  47.  
  48. ################################
  49. Code to draw a star shape in PdB
  50. ################################
  51.  
  52. #include <graphics.h>
  53.  
  54. void starpath(int ang)
  55. {
  56.         int i;
  57.  
  58.         newpath();
  59.         moveto(100,100);
  60.         for (i = 1 ; i <= (int)(360 / ang) ; i++) {
  61.                 rotate(180 + ang);
  62.                 rlineto(100,0);
  63.         }
  64.         setgray(0);
  65.         stroke();
  66. }
  67.  
  68. ########################
  69. Verbatim Compiler output
  70. ########################
  71.  
  72. /starpath {
  73.   % int --
  74.   newpath 100 100 moveto 1 360 2 index div cvi exch sub 1 add 0 max {
  75.     dup 180 add rotate 100 0 rlineto
  76.   } repeat
  77.   pop 0 setgray stroke
  78. } def
  79.  
  80. ###########################
  81. Code for bubble-sort in PdB
  82. ###########################
  83.  
  84. #include <postscript.h>
  85.  
  86. /******************************************************
  87.  * Bubble sort (page 66)
  88.  * From: Algorithms + Data Structures = Programs
  89.  *       Nicklaus Wirth
  90.  */
  91.  
  92. void bubblesort(int *a)
  93. {
  94.         int i, j;
  95.  
  96.         for (i = length(a)-1 ; i > 1 ; i--)
  97.                 for (j = 0 ; j < i ; j++)
  98.                         if (a[j] > a[j+1]) {
  99.                                 int x = a[j+1];
  100.                                 a[j+1] = a[j];
  101.                                 a[j] = x;
  102.                         }
  103. }
  104.  
  105. ########################
  106. Verbatim Compiler output
  107. ########################
  108.  
  109. /bubblesort {
  110.   % int * --
  111.   dup length 1 sub -1 2 {
  112.     0 1 3 -1 roll 1 sub {
  113.       2 copy get 2 index 2 index 1 add get gt {
  114.         2 copy 1 add get 2 index 2 index 1 add 4 index 4 index get put
  115.         2 index 3 1 roll put
  116.       } {pop} ifelse
  117.     } for
  118.   } for
  119.   pop
  120. } def
  121.  
  122. --
  123.  
  124.     Arthur van Hoff 
  125.     The Turing Institute Limited
  126.     36 North Hanover Street, 
  127.     G1 2AD Glasgow, Scotland
  128.  
  129.     Tel: +44 41 552 8858 or +44 41 552 6400
  130.     Fax: +44 41 552 2985
  131.     Email: arthur@turing.com
  132.  
  133.     The opinions expressed in this message are not 
  134.     necessarily those of The Turing Institute Limited.
  135.