home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / postscri / 6443 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.0 KB  |  92 lines

  1. Path: sparky!uunet!mcsun!uknet!turing!coulin!arthur
  2. From: arthur@turing.ac.uk (Arthur van Hoff)
  3. Newsgroups: comp.lang.postscript
  4. Subject: Hexagonal Pattern
  5. Message-ID: <ARTHUR.93Jan25122827@lurch.turing.ac.uk>
  6. Date: 25 Jan 93 12:34:39 GMT
  7. Sender: usenet@turing.ac.uk (Usenet for nntp)
  8. Organization: The Turing Institute Ltd., Glasgow, Scotland
  9. Lines: 81
  10.  
  11.  
  12. Hi,
  13.  
  14. Here is a simple PdB program (the compiled PostScript is also
  15. included) that draws an amazing hexagonal pattern resembling
  16. that of the human retina.
  17.  
  18.     Arthur van Hoff
  19.  
  20. ************************
  21. Start of the PdB program
  22. ************************
  23. #include <graphics.h>
  24.  
  25. #define RADIUS        25        /* Radius of fovia */
  26. #define CIRCLES        30        /* The number of circles */
  27. #define SEGMENTS    64        /* Segments on each circle */
  28. #define FACTOR1        1.05        /* Scaling factor */
  29. #define FACTOR2        (FACTOR1 * 0.995)
  30.  
  31. void main()
  32. {
  33.     float r1 = RADIUS, r2, r3;
  34.     int n, i;
  35.  
  36.     clippath();
  37.     fill(1);
  38.     setgray(0);
  39.     translate(250,250);
  40.  
  41.     for (n = 0 ; n < CIRCLES ; n++) {
  42.     r3 = r1;
  43.     r2 = r3 * FACTOR1;
  44.     r1 = r2 * FACTOR2;
  45.  
  46.     for (i = 0 ; i < SEGMENTS ; i++) {
  47.         moveto(0,r1);
  48.         lineto(0,r2);
  49.         rotate(180 / SEGMENTS);
  50.         lineto(0,r3);
  51.         rotate(180 / SEGMENTS);
  52.         lineto(0,r2);
  53.     }
  54.     rotate(180 / SEGMENTS);
  55.     stroke();
  56.     }
  57. }
  58.  
  59. extern "PostScript" {main};
  60.  
  61. ************************
  62. Verbatim compiler output
  63. ************************
  64. /main {
  65.   % --
  66.   25 clippath 1 setgray fill 0 setgray 250 250 translate 30 {
  67.     dup 1.05 mul exch 1 index 1.04475 mul 3 1 roll 64 {
  68.       0 3 index moveto 0 2 index lineto 2.8125 rotate 0 1 index
  69.       lineto 2.8125 rotate 0 2 index lineto
  70.     } repeat
  71.     pop pop 2.8125 rotate stroke
  72.   } repeat
  73.   pop
  74. } def
  75. %begin postscript section
  76. main
  77. %end
  78.  
  79. --
  80.  
  81.     Arthur van Hoff 
  82.     The Turing Institute Limited
  83.     36 North Hanover Street, 
  84.     G1 2AD Glasgow, Scotland
  85.  
  86.     Tel: +44 41 552 8858 or +44 41 552 6400
  87.     Fax: +44 41 552 2985
  88.     Email: arthur@turing.com
  89.  
  90.     The opinions expressed in this message are not 
  91.     necessarily those of The Turing Institute Limited.
  92.