home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / windows / openloo / 5124 < prev    next >
Encoding:
Text File  |  1993-01-22  |  3.3 KB  |  136 lines

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