home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / graphedit / part06 < prev    next >
Encoding:
Internet Message Format  |  1987-10-05  |  49.2 KB

  1. Subject:  v11i102:  Graphics editor for Suns, Part06/06
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rs@uunet.UU.NET
  5.  
  6. Submitted-by: steinmetz!sbcs!nyfca1!chan (Douglas Chan)
  7. Posting-number: Volume 11, Issue 102
  8. Archive-name: graphedit/part06
  9.  
  10. # This is a shell archive.  Remove anything before this line,
  11. # then unpack it by saving it in a file and typing "sh file".
  12. #
  13. # Contents:  images/ images/arc.pr images/border.pr images/borderfill.pr
  14. #    images/circle.pr images/dash.pr images/dot.pr images/dotdash.pr
  15. #    images/ellipse.pr images/fill.pr images/norotate.pr images/polygon.pr
  16. #    images/polyline.pr images/rect.pr images/rotate.pr images/solid.pr
  17. #    images/text.pr images/trace.pr images/graphedit.icon ps.head
  18. #    graphedit.l optmize.c misc.c ps2pic.c ps2plot.c optm.c
  19.  
  20. echo mkdir - images
  21. mkdir images
  22. chmod u=rwx,g=rx,o=rx images
  23.  
  24. echo x - images/arc.pr
  25. sed 's/^@//' > "images/arc.pr" <<'@//E*O*F images/arc.pr//'
  26. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  27.  */
  28.     0x0000,0x0000,0x7C00,0x0300,0x00C0,0x0020,0x0020,0x0010,
  29.     0x0010,0x0008,0x0008,0x0008,0x0008,0x0008,0x0000,0x0000
  30. @//E*O*F images/arc.pr//
  31. chmod u=r,g=r,o=r images/arc.pr
  32.  
  33. echo x - images/border.pr
  34. sed 's/^@//' > "images/border.pr" <<'@//E*O*F images/border.pr//'
  35. /* Format_version=1, Width=64, Height=14, Depth=1, Valid_bits_per_item=16
  36.  */
  37.     0x00FF,0xFFFF,0xFFFF,0xFF00,0x00FF,0xFFFF,0xFFFF,0xFF00,
  38.     0x00C0,0x0000,0x0000,0x0300,0x00C0,0x0000,0x0000,0x0300,
  39.     0x00C0,0x0000,0x0000,0x0300,0x00C0,0x0000,0x0000,0x0300,
  40.     0x00C0,0x0000,0x0000,0x0300,0x00C0,0x0000,0x0000,0x0300,
  41.     0x00C0,0x0000,0x0000,0x0300,0x00C0,0x0000,0x0000,0x0300,
  42.     0x00C0,0x0000,0x0000,0x0300,0x00C0,0x0000,0x0000,0x0300,
  43.     0x00FF,0xFFFF,0xFFFF,0xFF00,0x00FF,0xFFFF,0xFFFF,0xFF00
  44. @//E*O*F images/border.pr//
  45. chmod u=r,g=r,o=r images/border.pr
  46.  
  47. echo x - images/borderfill.pr
  48. sed 's/^@//' > "images/borderfill.pr" <<'@//E*O*F images/borderfill.pr//'
  49. /* Format_version=1, Width=64, Height=14, Depth=1, Valid_bits_per_item=16
  50.  */
  51.     0x00FF,0xFFFF,0xFFFF,0xFF00,0x00FF,0xFFFF,0xFFFF,0xFF00,
  52.     0x00E2,0x2222,0x2222,0x2300,0x00E2,0x2222,0x2222,0x2300,
  53.     0x00C8,0x8888,0x8888,0x8B00,0x00C8,0x8888,0x8888,0x8B00,
  54.     0x00E2,0x2222,0x2222,0x2300,0x00E2,0x2222,0x2222,0x2300,
  55.     0x00C8,0x8888,0x8888,0x8B00,0x00C8,0x8888,0x8888,0x8B00,
  56.     0x00E2,0x2222,0x2222,0x2300,0x00E2,0x2222,0x2222,0x2300,
  57.     0x00FF,0xFFFF,0xFFFF,0xFF00,0x00FF,0xFFFF,0xFFFF,0xFF00
  58. @//E*O*F images/borderfill.pr//
  59. chmod u=r,g=r,o=r images/borderfill.pr
  60.  
  61. echo x - images/circle.pr
  62. sed 's/^@//' > "images/circle.pr" <<'@//E*O*F images/circle.pr//'
  63. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  64.  */
  65.     0x07C0,0x1830,0x2008,0x4004,0x4004,0x8002,0x8002,0x8002,
  66.     0x8002,0x8002,0x4004,0x4004,0x2008,0x1830,0x07C0,0x0000
  67. @//E*O*F images/circle.pr//
  68. chmod u=r,g=r,o=r images/circle.pr
  69.  
  70. echo x - images/dash.pr
  71. sed 's/^@//' > "images/dash.pr" <<'@//E*O*F images/dash.pr//'
  72. /* Format_version=1, Width=64, Height=14, Depth=1, Valid_bits_per_item=16
  73.  */
  74.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  75.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  76.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  77.     0x0FC3,0xF0FC,0x3F0F,0xC3F0,0x0FC3,0xF0FC,0x3F0F,0xC3F0,
  78.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  79.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  80.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
  81. @//E*O*F images/dash.pr//
  82. chmod u=r,g=r,o=r images/dash.pr
  83.  
  84. echo x - images/dot.pr
  85. sed 's/^@//' > "images/dot.pr" <<'@//E*O*F images/dot.pr//'
  86. /* Format_version=1, Width=64, Height=14, Depth=1, Valid_bits_per_item=16
  87.  */
  88.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  89.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  90.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  91.     0x0C30,0xC30C,0x30C3,0x0C30,0x0C30,0xC30C,0x30C3,0x0C30,
  92.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  93.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  94.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
  95. @//E*O*F images/dot.pr//
  96. chmod u=r,g=r,o=r images/dot.pr
  97.  
  98. echo x - images/dotdash.pr
  99. sed 's/^@//' > "images/dotdash.pr" <<'@//E*O*F images/dotdash.pr//'
  100. /* Format_version=1, Width=64, Height=14, Depth=1, Valid_bits_per_item=16
  101.  */
  102.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  103.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  104.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  105.     0x0FC3,0x0FC3,0x0FC3,0x0FC0,0x0FC3,0x0FC3,0x0FC3,0x0FC0,
  106.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  107.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  108.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
  109. @//E*O*F images/dotdash.pr//
  110. chmod u=r,g=r,o=r images/dotdash.pr
  111.  
  112. echo x - images/ellipse.pr
  113. sed 's/^@//' > "images/ellipse.pr" <<'@//E*O*F images/ellipse.pr//'
  114. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  115.  */
  116.     0x0000,0x07E0,0x1818,0x2004,0x4002,0x8001,0x8001,0x8001,
  117.     0x8001,0x8001,0x4002,0x2004,0x1818,0x07E0,0x0000,0x0000
  118. @//E*O*F images/ellipse.pr//
  119. chmod u=r,g=r,o=r images/ellipse.pr
  120.  
  121. echo x - images/fill.pr
  122. sed 's/^@//' > "images/fill.pr" <<'@//E*O*F images/fill.pr//'
  123. /* Format_version=1, Width=64, Height=14, Depth=1, Valid_bits_per_item=16
  124.  */
  125.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  126.     0x0022,0x2222,0x2222,0x2000,0x0022,0x2222,0x2222,0x2000,
  127.     0x0008,0x8888,0x8888,0x8800,0x0008,0x8888,0x8888,0x8800,
  128.     0x0022,0x2222,0x2222,0x2000,0x0022,0x2222,0x2222,0x2000,
  129.     0x0008,0x8888,0x8888,0x8800,0x0008,0x8888,0x8888,0x8800,
  130.     0x0022,0x2222,0x2222,0x2000,0x0022,0x2222,0x2222,0x2000,
  131.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
  132. @//E*O*F images/fill.pr//
  133. chmod u=r,g=r,o=r images/fill.pr
  134.  
  135. echo x - images/norotate.pr
  136. sed 's/^@//' > "images/norotate.pr" <<'@//E*O*F images/norotate.pr//'
  137. /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  138.  */
  139.     0x01FF,0xFFFF,0xFFFF,0xFFF0,0x0100,0x4000,0x0000,0x0010,
  140.     0x0100,0xE000,0x0000,0x0010,0x0100,0x4000,0x0000,0x0010,
  141.     0x0101,0x0000,0x0000,0x0010,0x0101,0x0000,0x0000,0x0010,
  142.     0x0101,0x6000,0x0000,0x0010,0x0101,0x9000,0x0000,0x0010,
  143.     0x0101,0x1000,0x0000,0x0010,0x0101,0x1000,0x0000,0x0010,
  144.     0x0101,0x9000,0x0000,0x0010,0x0101,0x6000,0x0000,0x0010,
  145.     0x0100,0x0000,0x0000,0x0010,0x0100,0x4000,0x0000,0x0010,
  146.     0x0118,0xE000,0x0000,0x0010,0x01A5,0x4000,0x0000,0x0010,
  147.     0x019D,0xFFFF,0xFFFF,0xF110,0x01A5,0x4000,0x0000,0x1390,
  148.     0x0124,0x4000,0x0000,0x1110,0x011A,0x4000,0x0000,0x1110,
  149.     0x0100,0x4000,0x0000,0x1110,0x0100,0x4000,0x0000,0x1110,
  150.     0x0100,0x4000,0x0000,0x1110,0x0100,0x4000,0x0000,0x1110,
  151.     0x0100,0x4080,0x0000,0x1110,0x0100,0x53C0,0x0000,0x1110,
  152.     0x0100,0x5280,0x0000,0x1110,0x0100,0x5280,0x0000,0x1010,
  153.     0x0100,0x4E80,0x0000,0x1410,0x0100,0x4280,0x0000,0x1410,
  154.     0x0100,0x5280,0x0000,0x1590,0x0100,0x4E80,0x0000,0x1650,
  155.     0x0100,0x4080,0x0000,0x1450,0x0100,0x4080,0x0000,0x1450,
  156.     0x0100,0x4080,0x0020,0x1450,0x0100,0x40FF,0xFFF0,0x1450,
  157.     0x0100,0x4000,0x0020,0x1010,0x0100,0x4000,0x0000,0x1010,
  158.     0x0100,0x4000,0x0110,0x1110,0x0100,0x4000,0x00A0,0x1110,
  159.     0x0100,0x4000,0x0040,0x1110,0x0100,0x4000,0x00A0,0x1110,
  160.     0x0100,0x4000,0x0110,0x1110,0x0100,0x4000,0x0000,0x1110,
  161.     0x0100,0x4000,0x0000,0x1390,0x0100,0x7FFD,0xFFFF,0xF110,
  162.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0001,0x1000,0x0010,
  163.     0x0100,0x2001,0x1000,0x2010,0x0100,0x7FF9,0x53FF,0xF010,
  164.     0x0100,0x2001,0x5000,0x2010,0x0100,0x0001,0x5000,0x0010,
  165.     0x0100,0x0000,0xA000,0x0010,0x0100,0x0000,0x0000,0x0010,
  166.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0000,0x0000,0x0010,
  167.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0000,0x0000,0x0010,
  168.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0000,0x0000,0x0010,
  169.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0000,0x0000,0x0010,
  170.     0x0100,0x0000,0x0000,0x0010,0x01FF,0xFFFF,0xFFFF,0xFFF0
  171. @//E*O*F images/norotate.pr//
  172. chmod u=r,g=r,o=r images/norotate.pr
  173.  
  174. echo x - images/polygon.pr
  175. sed 's/^@//' > "images/polygon.pr" <<'@//E*O*F images/polygon.pr//'
  176. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  177.  */
  178.     0x8003,0xE00D,0x9032,0x4CC2,0x4302,0x4002,0x4004,0x4004,
  179.     0x2004,0x2008,0x2008,0x2008,0x2008,0x1010,0x11F0,0x1E00
  180. @//E*O*F images/polygon.pr//
  181. chmod u=r,g=r,o=r images/polygon.pr
  182.  
  183. echo x - images/polyline.pr
  184. sed 's/^@//' > "images/polyline.pr" <<'@//E*O*F images/polyline.pr//'
  185. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  186.  */
  187.     0x8003,0xE00D,0x9032,0x4CC2,0x4302,0x4002,0x4004,0x4004,
  188.     0x2004,0x2008,0x2008,0x2008,0x2008,0x1010,0x1010,0x1000
  189. @//E*O*F images/polyline.pr//
  190. chmod u=r,g=r,o=r images/polyline.pr
  191.  
  192. echo x - images/rect.pr
  193. sed 's/^@//' > "images/rect.pr" <<'@//E*O*F images/rect.pr//'
  194. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  195.  */
  196.     0x0000,0x0000,0xFFFF,0x8001,0x8001,0x8001,0x8001,0x8001,
  197.     0x8001,0x8001,0x8001,0x8001,0xFFFF,0x0000,0x0000,0x0000
  198. @//E*O*F images/rect.pr//
  199. chmod u=r,g=r,o=r images/rect.pr
  200.  
  201. echo x - images/rotate.pr
  202. sed 's/^@//' > "images/rotate.pr" <<'@//E*O*F images/rotate.pr//'
  203. /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  204.  */
  205.     0x01FF,0xFFFF,0xFFFF,0xFFF0,0x0100,0x4000,0x0000,0x0010,
  206.     0x0100,0xE000,0x0000,0x0010,0x0100,0x4000,0x0000,0x0010,
  207.     0x0101,0x0000,0x0000,0x0010,0x0101,0x0000,0x0000,0x0010,
  208.     0x0101,0x6000,0x0000,0x0010,0x0101,0x9000,0x0000,0x0010,
  209.     0x0101,0x1000,0x0000,0x0010,0x0101,0x1000,0x0000,0x0010,
  210.     0x0101,0x9000,0x0000,0x0010,0x0101,0x6000,0x0000,0x0010,
  211.     0x0100,0x0000,0x0000,0x0010,0x0100,0x4000,0x0000,0x0010,
  212.     0x0118,0xE000,0x0000,0x0010,0x01A5,0x4000,0x0000,0x0010,
  213.     0x019D,0xFFFF,0xFFFF,0xF110,0x01A5,0x4000,0x0000,0x1390,
  214.     0x0124,0x4000,0x0000,0x1110,0x011A,0x4000,0x0000,0x1110,
  215.     0x0100,0x4000,0x0000,0x1110,0x0100,0x4000,0x0000,0x1110,
  216.     0x0100,0x4000,0x0000,0x1110,0x0100,0x4000,0x0000,0x1110,
  217.     0x0100,0x4000,0x0010,0x1110,0x0100,0x4000,0x0038,0x1110,
  218.     0x0100,0x4000,0x0010,0x1110,0x0100,0x4000,0x0014,0x5010,
  219.     0x0100,0x4000,0x0012,0x9410,0x0100,0x4000,0x0011,0x1410,
  220.     0x0100,0x4000,0x0012,0x9590,0x0100,0x4000,0x0014,0x5650,
  221.     0x0100,0x4000,0x0010,0x1450,0x0100,0x4000,0x0010,0x1450,
  222.     0x0100,0x4040,0x0010,0x1450,0x0100,0x40FF,0xFFF0,0x1450,
  223.     0x0100,0x4040,0x0000,0x1010,0x0100,0x4012,0x0000,0x1010,
  224.     0x0100,0x4012,0x0000,0x1110,0x0100,0x4012,0x0000,0x1110,
  225.     0x0100,0x400E,0x0000,0x1110,0x0100,0x4002,0x0000,0x1110,
  226.     0x0100,0x4012,0x0000,0x1110,0x0100,0x400E,0x0000,0x1110,
  227.     0x0100,0x4000,0x0000,0x1390,0x0100,0x7FFD,0xFFFF,0xF110,
  228.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0001,0x1000,0x0010,
  229.     0x0100,0x2001,0x1000,0x2010,0x0100,0x7FF9,0x53FF,0xF010,
  230.     0x0100,0x2001,0x5000,0x2010,0x0100,0x0001,0x5000,0x0010,
  231.     0x0100,0x0000,0xA000,0x0010,0x0100,0x0000,0x0000,0x0010,
  232.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0000,0x0000,0x0010,
  233.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0000,0x0000,0x0010,
  234.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0000,0x0000,0x0010,
  235.     0x0100,0x0000,0x0000,0x0010,0x0100,0x0000,0x0000,0x0010,
  236.     0x0100,0x0000,0x0000,0x0010,0x01FF,0xFFFF,0xFFFF,0xFFF0
  237. @//E*O*F images/rotate.pr//
  238. chmod u=r,g=r,o=r images/rotate.pr
  239.  
  240. echo x - images/solid.pr
  241. sed 's/^@//' > "images/solid.pr" <<'@//E*O*F images/solid.pr//'
  242. /* Format_version=1, Width=64, Height=14, Depth=1, Valid_bits_per_item=16
  243.  */
  244.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  245.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  246.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  247.     0x0FFF,0xFFFF,0xFFFF,0xFFF0,0x0FFF,0xFFFF,0xFFFF,0xFFF0,
  248.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  249.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  250.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
  251. @//E*O*F images/solid.pr//
  252. chmod u=r,g=r,o=r images/solid.pr
  253.  
  254. echo x - images/text.pr
  255. sed 's/^@//' > "images/text.pr" <<'@//E*O*F images/text.pr//'
  256. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  257.  */
  258.     0x0000,0x0000,0x0000,0x0040,0x0040,0x1858,0x2464,0x1C44,
  259.     0x2444,0x2464,0x1A58,0x0000,0x0000,0x0000,0x0000,0x0000
  260. @//E*O*F images/text.pr//
  261. chmod u=r,g=r,o=r images/text.pr
  262.  
  263. echo x - images/trace.pr
  264. sed 's/^@//' > "images/trace.pr" <<'@//E*O*F images/trace.pr//'
  265. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  266.  */
  267.     0x0100,0x0280,0x0440,0x0820,0x0810,0x0810,0x0410,0x0210,
  268.     0x0220,0x8140,0x4080,0x2140,0x1221,0x0C12,0x000C,0x0000
  269. @//E*O*F images/trace.pr//
  270. chmod u=r,g=r,o=r images/trace.pr
  271.  
  272. echo x - images/graphedit.icon
  273. sed 's/^@//' > "images/graphedit.icon" <<'@//E*O*F images/graphedit.icon//'
  274. /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  275.  */
  276.     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8000,0x0000,0x0000,0x0001,
  277.     0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  278.     0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  279.     0x803F,0xFFFF,0xFFFF,0xC001,0x8020,0x0000,0x0000,0x4001,
  280.     0x8020,0x0000,0x0000,0x4001,0x8020,0x0000,0x0000,0x4001,
  281.     0x8020,0x0000,0x0000,0x4001,0x8020,0x0000,0x0000,0x4001,
  282.     0x80FF,0xFFFF,0xF000,0x4001,0x808A,0xAAAA,0x2000,0x4001,
  283.     0x8088,0x8888,0x4000,0x4001,0x8080,0x0000,0x8000,0x4001,
  284.     0x80EF,0xFFE1,0x0000,0x4001,0x8088,0x0042,0x0000,0x4001,
  285.     0x80C8,0x0084,0x0000,0x4001,0x8088,0x0108,0x0000,0x4001,
  286.     0x80E8,0x0210,0x0000,0x4001,0x8088,0x0420,0x0000,0x4001,
  287.     0x80C8,0x0840,0x0000,0x4001,0x8088,0x1080,0x0000,0x4001,
  288.     0x80E8,0x2100,0x0000,0x4001,0x8088,0x4200,0x0400,0x4001,
  289.     0x80C8,0x8400,0x0600,0x4001,0x8089,0x0800,0x0600,0x4001,
  290.     0x80EA,0x1000,0x0500,0x4001,0x808C,0x2000,0x0500,0x4001,
  291.     0x80C8,0x4000,0x0480,0x4001,0x8080,0x8000,0x0580,0x4001,
  292.     0x80E1,0x0000,0x0740,0x4001,0x8082,0x0000,0x0340,0x4001,
  293.     0x80C4,0x0000,0x02C0,0x4001,0x8088,0x0000,0x02A0,0x4001,
  294.     0x8090,0x0000,0x01A0,0x4001,0x80A0,0x0000,0x0160,0x4001,
  295.     0x80E0,0x0000,0x0150,0x4001,0x80A0,0x0000,0x00D0,0x4001,
  296.     0x8020,0x0000,0x00B0,0x4001,0x8020,0x0000,0x00A8,0x4001,
  297.     0x8000,0x0001,0x0068,0x4001,0x8000,0x0001,0x0058,0x4001,
  298.     0x8D2C,0x30B1,0x6054,0x4001,0x9332,0x48C9,0x9034,0x4001,
  299.     0x9120,0x3889,0x1034,0x4001,0x9120,0x4889,0x102A,0x4001,
  300.     0x9320,0x48C9,0x101A,0x4001,0x8D20,0x34B1,0x101A,0x4001,
  301.     0x8100,0x0080,0x0015,0x4001,0x9120,0x0080,0x000D,0x4001,
  302.     0x8E20,0x0088,0x400D,0x4001,0x8020,0x0008,0x010A,0xC001,
  303.     0x8020,0x3869,0xC3C6,0xC001,0x803F,0x4498,0x410E,0xC001,
  304.     0x8000,0x7888,0x4105,0xC001,0x8000,0x4088,0x4103,0xC001,
  305.     0x8000,0x4498,0x4123,0x4001,0x8000,0x3868,0x40C2,0x2001,
  306.     0x8000,0x0000,0x0001,0x2001,0x8000,0x0000,0x0001,0x4001,
  307.     0x8000,0x0000,0x0000,0x8001,0xFFFF,0xFFFF,0xFFFF,0xFFFF
  308. @//E*O*F images/graphedit.icon//
  309. chmod u=r,g=r,o=r images/graphedit.icon
  310.  
  311. echo x - ps.head
  312. sed 's/^@//' > "ps.head" <<'@//E*O*F ps.head//'
  313. %!
  314. % @(#)ps.head    1.2    6/8/87 Copyright 1987 SBCS-chan
  315. %
  316. /$graphedit 100 dict def
  317. $graphedit begin
  318. /GE_X 512 array def
  319. /GE_Y 512 array def
  320. /GE_PI 3.1415927 def
  321. /GE_FONT 0 def
  322. /GE_CHARSIZE 12. def
  323. /GE_FILL_VALUE 0 def
  324. /GE_FONT_NAME [ /Courier /Times-Roman /Symbol
  325.                 /Times-BoldItalic /Helvetica-Bold ] def
  326.  
  327. /GE_LINE_STYLES [
  328.    { [] 0 setdash }
  329.    { [1 2] 1 setdash }
  330.    { [5] 0 setdash }
  331.    { [10 2 1 2] 0 setdash } ] def
  332.  
  333. /GE_DO_FILL {
  334.    0 GE_FILL_VALUE eq
  335.      {stroke}
  336.      {1 GE_FILL_VALUE eq
  337.        {greylevel setgray fill 0. setgray}
  338.        {gsave greylevel setgray fill 0. setgray grestore stroke}
  339.       ifelse
  340.      }
  341.    ifelse
  342.    /GE_FILL_VALUE 0 def
  343. } def
  344. /GE_MOVE {
  345.    moveto
  346. } def
  347. /GE_LINE {
  348.    lineto currentpoint stroke moveto
  349. } def
  350. /GE_TEXT {
  351.    0. GE_CHARSIZE -3. div rmoveto
  352.    show
  353. } def
  354. /GE_DO_POLYLINE {
  355.    newpath
  356.    /GE_I 0 def
  357.    0 1 GE_N {
  358.      GE_X GE_I get
  359.      GE_Y GE_I get lineto
  360.      /GE_I GE_I 1 add def
  361.      pop
  362.    } for
  363.    stroke
  364. } def
  365. /GE_DO_POLYGON {
  366.    newpath
  367.    /GE_I 1 def
  368.    GE_X 0 get
  369.    GE_Y 0 get moveto
  370.    1 1 GE_N 1 sub {
  371.      GE_X GE_I get
  372.      GE_Y GE_I get lineto
  373.      /GE_I GE_I 1 add def
  374.      pop
  375.    } for
  376.    closepath GE_DO_FILL} def
  377. /GE_POLYLINE {
  378.    /GE_TMP_Y exch def
  379.    /GE_TMP_X exch def
  380.    /GE_N 0 def
  381.    /GE_LASTINSTR { GE_DO_POLYLINE } def
  382.    GE_X GE_N GE_TMP_X put
  383.    GE_Y GE_N GE_TMP_Y put
  384.    /GE_N GE_N 1 add def
  385. } def
  386. /GE_POLYGON {
  387.    /GE_TMP_Y exch def
  388.    /GE_TMP_X exch def
  389.    /GE_N 0 def
  390.    /GE_LASTINSTR { GE_DO_POLYGON } def
  391.    GE_X GE_N GE_TMP_X put
  392.    GE_Y GE_N GE_TMP_Y put
  393.    /GE_N GE_N 1 add def
  394. } def
  395. /GE_CIRCLE {
  396.    /GE_RADIUS exch def
  397.    currentpoint newpath GE_RADIUS 0. 365. arc GE_DO_FILL
  398. } def
  399. /GE_ELLIPSE {
  400.    /GE_B exch def
  401.    /GE_A exch def
  402.    gsave
  403.    1. GE_B GE_A div scale
  404.    currentpoint newpath 
  405.    GE_A 0. 365. arc GE_DO_FILL
  406.    grestore
  407. } def
  408. /GE_ARC {
  409.    /GE_ANG2 exch 180. mul GE_PI div def
  410.    /GE_ANG1 exch 180. mul GE_PI div def
  411. } def
  412. /GE_ARCEXT {
  413.    /GE_RADIUS exch def
  414.    currentpoint currentpoint newpath 
  415.    GE_RADIUS GE_ANG1 GE_ANG2 arc stroke moveto
  416. } def
  417. /GE_CONT {
  418.    /GE_TMP_Y exch def
  419.    /GE_TMP_X exch def
  420.    GE_X GE_N GE_TMP_X put
  421.    GE_Y GE_N GE_TMP_Y put
  422.    /GE_N GE_N 1 add def
  423. } def
  424. /GE_END {
  425.    GE_LASTINSTR
  426. } def
  427. /GE_SET_FONT {
  428.    /GE_FONT exch def
  429.    GE_FONT_NAME GE_FONT get findfont
  430.    GE_CHARSIZE scalefont setfont
  431. } def
  432. /GE_SET_LINESTYLE {
  433.    /GE_LINESTYLE exch def
  434.    GE_LINE_STYLES GE_LINESTYLE get exec
  435. } def
  436. /GE_SET_COLOR {
  437.    1 add 12 div 1 exch sub /greylevel exch def
  438. } def
  439. /GE_SET_LINEWIDTH {
  440.    2. div setlinewidth
  441. } def
  442. /GE_SET_CHARSIZE {
  443.    1.5 mul /GE_CHARSIZE exch def
  444.    GE_FONT_NAME GE_FONT get findfont
  445.    GE_CHARSIZE scalefont setfont
  446. } def
  447. /GE_NEW_SEG {
  448.    gsave
  449. } def
  450. /GE_END_SEG {
  451.    grestore
  452. } def
  453. /GE_TRANSLATE {
  454.    translate
  455. } def
  456. /GE_ROTATE {
  457.    rotate
  458. } def
  459. /GE_SCALE {
  460.    scale
  461. } def
  462. /GE_TERM {
  463.   restore
  464.   showpage
  465.   end
  466. } def
  467. /GE_FILL {
  468.    /GE_FILL_VALUE exch def
  469. } def
  470. save
  471. initgraphics
  472. 1 setlinecap 1 setlinejoin
  473. @//E*O*F ps.head//
  474. chmod u=r,g=r,o=r ps.head
  475.  
  476. echo x - graphedit.l
  477. sed 's/^@//' > "graphedit.l" <<'@//E*O*F graphedit.l//'
  478. @.\" @(#)graphedit.l    1.2 6/8/87 Copyright 1987 SBCS-chan;
  479. @.TH GRAPHEDIT 1 "18 May 1987"
  480. @.SH NAME
  481. graphedit \- a general purpose graphic editor
  482. @.SH SYNOPSIS
  483. \fBgraphedit\fP
  484. @.SH DESCRIPTION
  485. \fIGraphedit\fP is a general purpose graphic editor used to
  486. create and edit diagrams, which may be printed on high quality
  487. laser printers after convertion to format acceptable
  488. by the printers.  Diagrams are saved and load in
  489. PostScript, which can be printed directly on any PostScript printers
  490. without any convertion.  Diagrams can also be written in
  491. \fIrasterfile(5)\fP, \fIplot(5)\fP and as input to \fIpic(1)\fP.
  492. @.LP
  493. Each diagram by \fIgraphedit\fP consists of a number of segments.
  494. Each segment may consists of any number of primitives such as
  495. rectangles, circles, polygons and text strings.  Most editing are
  496. performed as operations on segments.  Each primitive may be
  497. drawn with some attributes, such as color, font, and line width.
  498. @.LP
  499. \fIGraphedit\fP must be started in the \fIsuntools(1)\fP environment.
  500. It takes generic tool arguments.
  501. A view surface and a control pad is displayed when \fIgraphedit\fP is started.
  502. The view surface displays the diagram being edited.
  503. At the upper left corner of the view surface, samples are displayed
  504. to show the attributes currently selected.
  505. @.LP
  506. The control pad is used to display messages from \fIgraphedit\fP and to
  507. select operations, attributes and options.  The control pad consists of
  508. the message window, editor operations window, segment operations window,
  509. primitives window and the attributes and options selection window
  510. from top to bottom.
  511. @.LP
  512. Messages
  513. @.RS
  514. The first line of the message window displays messages from
  515. \fIgraphedit\fP, while the second displays the effect of
  516. pressing the Left, Middle, and Right buttons of the mouse inside
  517. the view surface.
  518. @.RE
  519. @.LP
  520. Editor Operations
  521. @.RS
  522. \fBSave\fP - Save diagram in <File> in PostScript.
  523. @.LP
  524. \fBLoad\fP - Load diagram from <File>.  <File> must be written by \fBSave\fP.
  525. @.LP
  526. \fBRedisplay\fP - Redislay diagram in view_surface.
  527. @.LP
  528. \fBQuit\fP - Exit from editor.
  529. @.LP
  530. \fBClear\fP - Clear diagram.  Unsaved diagram will be lost.
  531. @.LP
  532. \fBScale\fP - Scale the diagram to within a rectangular region on the view
  533. surface.
  534. @.LP
  535. \fBOutput\fP - Write the diagram to <File> in a format other than PostScript.
  536. <File> cannot be \fBLoad\fP.  Available formats are \fIrasterfile(5)\fP,
  537. \fIplot(5)\fP, and \fIpic(1)\fP.  The format used is specified by the
  538. \fBOutput Format\fP option.  Whole or part of the view surface can be
  539. written in \fIrasterfile(5)\fP as specified by the \fBSelect Area for Raster\fP
  540. option.
  541. @.LP
  542. \fBFile\fP - File name used in save,load and output of diagrams and segments.
  543. @.RE
  544. @.LP
  545. Segment Operations
  546. @.RS
  547. \fBCreate\fP - Create a new segment to be the current segment.
  548. @.LP
  549. \fBEdit\fP - Select an existing segment to be the current segment.
  550. @.LP
  551. \fBDelete\fP - Delete a selected segment.
  552. @.LP
  553. \fBSave\fP - Save a selected segment in <File>.
  554. @.LP
  555. \fBLoad\fP - Load segment saved in <File>.
  556. @.LP
  557. \fBCopy\fP - Copy a selected segment to a new location.
  558. @.LP
  559. \fBMove\fP - Move a selected segment to a new location.
  560. @.LP
  561. \fBRotate\fP - Rotate a selected segment on where it is selected.  The
  562. angle of rotation is adjusted by moving the cursor left and right.
  563. @.LP
  564. \fBScale\fP - Scale a selected segment on where it is selected.  Moving
  565. the cursor right and up will increase the size of the segment, while moving
  566. it left and down will decrease the size initially and eventually reverse
  567. the segment.  Only moving the cursor right/left will increase/decrease the
  568. size of the segment when the \fBProportional Scale\fP option is on.
  569. @.LP
  570. \fBJoin\fP - Join other segments selected to the first selected segment
  571. to form a single segment.
  572. @.LP
  573. \fBBreak\fP - Break up a selected segment such that each individual primitive
  574. in it will be a segment.
  575. @.LP
  576. \fBUndelete\fP - Undelete the last deleted segment.
  577. @.RE
  578. @.LP
  579. Primitives
  580. @.RS
  581. Any primitive drawn will be added to the current segment with the
  582. attributes currently selected.  If there is no current segment,
  583. a new segment will be created before the primitive is drawn.
  584. The current segment is redrawn every two seconds if the
  585. \fBBlink Current Segment\fP option is on.
  586. @.LP
  587. The primitives on the first row, from left to right, are
  588. \fBPolyline\fP, \fBPolygon\fP, \fBCircle\fP, \fBRectangle\fP,
  589. \fBFreehand\fP, \fBEllipse\fP and \fBArc\fP.  The second row is
  590. used by \fBText\fP.
  591. @.LP
  592. \fBPolyline\fP - Draw any number of connecting lines.
  593. @.LP
  594. \fBPolygon\fP - Draw a polygon. The last point will be connected to
  595. the first point.
  596. @.LP
  597. \fBCircle\fP - Draw a circle before any scaling.  Appear as
  598. an ellipse after it is scaled.
  599. @.LP
  600. \fBRectangle\fP - Draw a rectangle.
  601. @.LP
  602. \fBFreehand\fP - Draw a number of lines following the movement of the
  603. cursor.
  604. @.LP
  605. \fBEllipse\fP - Draw an ellipse.
  606. @.LP
  607. \fBArc\fP - Draw an arc by giving the end points and a point
  608. the arc will go through.
  609. @.LP
  610. \fBText\fP - Draw the text string specified on the right of the button.
  611. @.RE
  612. @.LP
  613. Attributes and Options
  614. @.RS
  615. \fBLine width\fP - Specify the width of any line drawn in \fBPolyline\fP,
  616. \fBPolygon\fP, \fBCircle\fP and \fBRectangle\fP.
  617. @.LP
  618. \fBGrid interval\fP - Specify the interval of the grid displayed and used
  619. for alignment.
  620. @.LP
  621. \fBColor\fP - Specify the color used to fill \fBPolygon\fP, \fBCircle\fP,
  622. \fBEllipse\fP
  623. and \fBRectangle\fP.  It actually appears as lighter to darker patterns
  624. on output from printer.
  625. @.LP
  626. \fBFont size\fP - Specify the size of characters used for \fBText\fP.
  627. @.LP
  628. \fBLine style\fP - Specify the style of any line drawn in \fBPolyline\fP,
  629. \fBPolygon\fP, \fBCircle\fP, \fBRectangle\fP, \fBEllipse\fP, \fBFreehand\fP
  630. and \fBArc\fP.
  631. @.LP
  632. \fBFont\fP - Specify the PostScript font used on printer output for
  633. \fBText\fP drawn.  Only similar fonts are displayed on the view surface.
  634. @.LP
  635. \fBGrid\fP - The grid is displayed when it is on.  It is  independant to the
  636. \fBAlign\fP option.
  637. @.LP
  638. \fBAlign\fP - When it is on, any point chosen when drawing any primitive
  639. will be aligned to the closest point on the grid.  It also aligns the
  640. movement of segments in \fBMove\fP and \fBCopy\fP.
  641. It is independant to the \fBGrid\fP option.
  642. @.LP
  643. \fBShow Options/Options Done\fP - Show/Close the options window.
  644. @.LP
  645. The cycle below \fBShow Options/Options Done\fP is the \fBBorder/Fill\fP option.
  646. It specifies whether \fBPolyline\fP, \fBCircle\fP,
  647. \fBRectangle\fP, or \fBEllipse\fP  drawn will only have a border,
  648. only be filled with \fBColor\fP, or both.
  649. @.RE
  650. @.LP
  651. Options Window
  652. @.RS
  653. The Options Window consists of two parts.  The upper part specify how
  654. the saved diagram will be positioned on 8.5 x 11 paper when it is
  655. printed.  The lower part specify other options.
  656. @.LP
  657. \fBw\fP, \fBh\fP, \fBa\fP and \fBb\fP specify the width and height of the
  658. diagram, and the offset from the upper left corner of the paper as shown in the
  659. illustration in the window.
  660. @.LP
  661. \fBScale\fP/\fBFix Width\fP/\fBFix Height\fP specify whether the
  662. diagram should be scaled to the specified width and height, adjusted to
  663. the specified width, or adjusted to the specified height.
  664. @.LP
  665. \fBCenter\fP/\fBOffset a,b\fP specify whether the diagram will be centered
  666. on the paper,  or at the specified offset.
  667. @.LP
  668. Clicking the left mouse button on the illustration will change the
  669. direction of the x and y axis of the diagram on the paper.
  670. @.LP
  671. \fBAuto Create\fP - When it is on, a new segment will be created for every
  672. primitive drawn.
  673. @.LP
  674. \fBContinous\fP - When it is on, \fIgraphedit\fP will repeat
  675. the function chosen until the function is cancelled or no segment is selected.
  676. Functions affected by this options are \fBMove\fP, \fBRotate\fP, \fBScale\fP,
  677. \fBDelete\fP, \fBCopy\fP and all primitive functions.
  678. @.LP
  679. \fBProportional Scale\fP - When it is on, scale of segments will be done
  680. proportionally along the x and y axis.  Moving the cursor to the right/left
  681. will increase/decrease the size of the segment.
  682. @.LP
  683. \fBBlink Current Segment\fP - When it is on, \fIgraphedit\fP will blink
  684. the current segment every two seconds. Default is on.
  685. @.LP
  686. \fBOptimize Before Save\fP - When it is on, \fIgraphedit\fP will run
  687. an internal optimizer on the diagram before it is saved.  Default is on.
  688. @.LP
  689. \fBOutput Format\fP - Specify which output format to use for
  690. \fBOutput\fP.  Can be \fIRaster\fP, \fIPic\fP or \fIPlot\fP.
  691. @.LP
  692. \fBSelect Area for Raster\fP - When it is on, \fIgraphedit\fP will
  693. write the raster of a rectangular region on the view surface selected by the
  694. user instead of the whole view surface.
  695. @.LP
  696. The environment GEDIR can be set to indicate the directory where
  697. the required files for \fIgraphedit\fP are located.  A default
  698. directory will be used otherwise.
  699. @.SH "FILES"
  700. @.LP
  701. $GELIB/ps.head File included at beginning of saved diagram
  702. @.SH "SEE ALSO"
  703. suntools(1), pic(1), rasterfile(5), plot(5)
  704. @.SH BUGS
  705. @.LP
  706. The correct location of the cursor in the view surface cannot
  707. be read before the view surface is swapped in.  A crosshair is
  708. displayed at the location read by \fIgraphedit\fP when there is
  709. no other feedback. Moving the mouse slightly in the view suface
  710. will let \fIgraphedit\fP read the current location of the cursor.
  711. @.LP
  712. Primitives such as \fBText\fP, \fBCircle\fP, \fBEllipse\fP
  713. and \fBArc\fP in a segment
  714. may appear differently when it is joined to another segment with 
  715. different rotation and scale.
  716. @.LP
  717. Can \fBUndelete\fP only up to the last ten segments deleted.
  718. @.LP
  719. Fonts on view surface are different from PostScript fonts.
  720. @.LP
  721. Hidden regions on the view surface will be blackened in the
  722. raster file written.
  723. @.LP
  724. Output in \fIpic(1)\fP or \fIplot(5)\fP
  725. ignores attributes that \fIpic(1)\fP and \fIplot(5)\fP do not
  726. support.  Output in pic(1) ignores \fBColor\fI and \fBBorder/Fill\fP.
  727. Output in \fIplot(5)\fP ignores \fBLine width\fP,
  728. \fBColor\fP, \fBFont size\fP, \fBFont\fP and \fBBorder/Fill\fP.
  729. @//E*O*F graphedit.l//
  730. chmod u=r,g=r,o=r graphedit.l
  731.  
  732. echo x - optmize.c
  733. sed 's/^@//' > "optmize.c" <<'@//E*O*F optmize.c//'
  734.  
  735. static char SccsId[] = "@(#)optmize.c    1.1 6/8/87 Copyright 1987 SBCS-chan";
  736.  
  737. /*****************************************************************************
  738.  
  739.           (c) Copyright 1987 
  740.  
  741.           Lap-Tak Chan
  742.           Computer Science Department
  743.           State University of New York at Stony Brook
  744.           Stony Brook, NY 11794
  745.  
  746.     This software and its documentation may be used, copied, and
  747.   distributed, provided that this legend appear in all copies and
  748.   that it is not copied or distributed for a profit.
  749.  
  750.   No representations is made about the suitability of this software
  751.   for any purpose.  It is provided "as is" with no support and no
  752.   express or implied warranty.
  753.  
  754. *****************************************************************************/
  755.  
  756. /*****************************************************************************
  757.  
  758.                       Instruction List Optimizer
  759.                       ==========================
  760.  
  761.     This file contains routines which will optimize the instruction list
  762.   of the user segments.  Currently, it will only try to eliminate
  763.   unnecessary setting of attributes.
  764.  
  765. *****************************************************************************/
  766.  
  767. #include <stdio.h>
  768. #include "display.h"
  769.  
  770. /* external routines and data structures from display.c */
  771. extern struct list *ge_display_list();
  772. extern int ge_seglist; /* segment list */
  773. extern struct list ge_open[]; /* store display lists of segments */
  774.  
  775. /*****************************************************************************
  776.  
  777.     optimize will optimize the instruction lists of user segments by
  778.   scanning the segment list and optimize each user segment with opt_seg().
  779.  
  780. *****************************************************************************/
  781.  
  782. optimize()
  783. {
  784.   int i;
  785.  
  786.   /* scan the segment list */
  787.   for (i=ge_seglist; i; i=ge_open[i].next) {
  788.     /* maybe it should also optimize deleted segment */
  789.     if (ge_open[i].segno >= GE_MIN_SEG && ( ! ge_open[i].attr.deleted) ) {
  790.       opt_seg(&(ge_open[i]));
  791.     } /* if */
  792.   } /* for */
  793.   
  794. } /* optimize */
  795.  
  796. #define UNDEFINE 100000 /* indicate that an attribute is undefined */
  797. #define TMPSEG 100000 /* temporary segment used */
  798.  
  799. /*****************************************************************************
  800.  
  801.     opt_update will test whether an attribute need to be specified in the
  802.   instruction list.  If it has to be specified, it will try to specify it
  803.   as the initial attribute.  If the initial attribute has been specified,
  804.   it will specify it on the instruction list.
  805.  
  806.   Input
  807.     attrtype - type of attribute
  808.     instr - the instruction used to set the attribute
  809.  
  810. *****************************************************************************/
  811.  
  812. #define opt_update(attrtype,instr) \
  813.   if ( updated_attr.attrtype != UNDEFINE ) {\
  814.     /* need to specify the new attribute */\
  815.     if ( curr_attr.attrtype == UNDEFINE ) {\
  816.       /* specify as initial attribute */\
  817.       dlist->attr.attrtype = updated_attr.attrtype;\
  818.     }\
  819.     else {\
  820.       /* change the attribute in the instruction list */\
  821.       ge_graph(TMPSEG, instr, (float)updated_attr.attrtype, 0.);\
  822.     }\
  823.     curr_attr.attrtype = updated_attr.attrtype;\
  824.     updated_attr.attrtype = UNDEFINE;\
  825.   } /* opt_update */
  826.  
  827. /*****************************************************************************
  828.  
  829.     opt_attr will mark that a new attribute has been specified if it is
  830.   different from the current attribute.
  831.  
  832.   Input
  833.     attrtype - the attribute specified
  834.  
  835. *****************************************************************************/
  836.  
  837. #define opt_attr(attrtype) \
  838.   { if (((int)ptr->x) != curr_attr.attrtype)\
  839.       /* indicate that the attribute will have to be set */\
  840.       updated_attr.attrtype = ptr->x;\
  841.     else\
  842.       /* no change of attribute is necessary */\
  843.       updated_attr.attrtype = UNDEFINE;\
  844.   } /* opt_attr */
  845.  
  846. /*****************************************************************************
  847.  
  848.     opt_seg will optimize the instruction list of a segment.  Currently it
  849.   only try to eliminate unnecessary setting of attributes.  It is done
  850.   by delaying the setting of attributes until they are used.
  851.  
  852.   Input
  853.     dlist - pointer to display list of segment
  854.  
  855. *****************************************************************************/
  856.  
  857. opt_seg(dlist)
  858. struct list *dlist;
  859. {
  860.   static struct attr undefined_attr =
  861.     { 0.,0.,0.,1.,1.,
  862.       UNDEFINE, UNDEFINE, UNDEFINE, UNDEFINE, UNDEFINE, 0, 0 };
  863.   struct list *tmpdlist;
  864.   struct attr curr_attr; /* current attributes of segment */
  865.   struct attr updated_attr; /* attributes specified but not used yet */
  866.   struct list_item *ptr;
  867.   static int fill=0;
  868.  
  869.   /* no optimization necessary for empty instruction list */
  870.   if ( !dlist->d_list )
  871.     return;
  872.  
  873.   /* create temporary segment */
  874.   make_new_seg(TMPSEG);
  875.   tmpdlist = (struct list *)ge_display_list(TMPSEG);
  876.  
  877.   /* make current attribute undefined */
  878.   curr_attr = undefined_attr;
  879.  
  880.   /* set initail attributes as attributes to be updated */
  881.   updated_attr = dlist->attr;
  882.  
  883.   ptr = dlist->d_list->next;
  884.  
  885.   do {
  886.     switch (ptr->instr) {
  887.       /* set attribute */
  888.       case GE_SETCOLOR:
  889.         opt_attr(color);
  890.         break;
  891.       case GE_SETTYPELINE:
  892.         opt_attr(linestyle);
  893.         break;
  894.       case GE_SETLINEWIDTH:
  895.         opt_attr(linewidth);
  896.         break;
  897.       case GE_SETFONT:
  898.         opt_attr(font);
  899.         break;
  900.       case GE_SETCHARSIZE:
  901.         opt_attr(charsize);
  902.         break;
  903.  
  904.       case GE_MOVE:
  905.       case GE_CONT:
  906.       case GE_PLOT:
  907.       case GE_ARCEXT:
  908.         /* just copy them to the instruction list of TMPSEG */
  909.         ge_graph(TMPSEG, ptr->instr, ptr->x, ptr->y);
  910.         break;
  911.  
  912.       case GE_FILL:
  913.         /* save fill value which will be necessary for polygon, etc */
  914.         fill = (int)ptr->x;
  915.         ge_graph(TMPSEG, ptr->instr, ptr->x, ptr->y);
  916.         break;
  917.  
  918.       case GE_LINE:
  919.       case GE_ARC:
  920.       case GE_POLYLINE:
  921.         /* use line width and line style */
  922.         opt_update(linewidth,GE_SETLINEWIDTH);
  923.         opt_update(linestyle,GE_SETTYPELINE);
  924.         ge_graph(TMPSEG, ptr->instr, ptr->x, ptr->y);
  925.         break;
  926.  
  927.       case GE_TEXT:
  928.         /* use font and character size */
  929.         opt_update(font,GE_SETFONT);
  930.         opt_update(charsize,GE_SETCHARSIZE);
  931.         ge_graph(TMPSEG, ptr->instr, ptr->x, ptr->y);
  932.         break;
  933.  
  934.       case GE_ELLIPSE:
  935.       case GE_CIRCLE:
  936.       case GE_POLYGON:
  937.         /* use line width and line style for border */
  938.         if ( (fill == GE_BORDERONLY) || (fill == GE_FILLBORDER) ) {
  939.           opt_update(linewidth,GE_SETLINEWIDTH);
  940.           opt_update(linestyle,GE_SETTYPELINE);
  941.         }
  942.         /* use color for fill */
  943.         if ( (fill == GE_FILLONLY) || (fill == GE_FILLBORDER) ) {
  944.           opt_update(color,GE_SETCOLOR);
  945.         }
  946.  
  947.         fill = 0;
  948.         ge_graph(TMPSEG, ptr->instr, ptr->x, ptr->y);
  949.         break;
  950.  
  951.       /* check for instructions not properly handled */
  952.       default:
  953.         fprintf(stderr,
  954.                 "Internal Error-Action for instruction %d missing.\n",
  955.                 ptr->instr);
  956.         break;
  957.     } /* switch */
  958.  
  959.     ptr=ptr->next;
  960.   } while ( ptr != dlist->d_list->next );
  961.  
  962.   /* exchange instruction list of segment and temporary segment */
  963.   ptr = dlist->d_list;
  964.   dlist->d_list = tmpdlist->d_list;
  965.   tmpdlist->d_list = ptr;
  966.  
  967.   /* delete temporary segment */
  968.   ge_delete_segment(TMPSEG);
  969.  
  970. } /* opt_seg */
  971. @//E*O*F optmize.c//
  972. chmod u=r,g=r,o=r optmize.c
  973.  
  974. echo x - misc.c
  975. sed 's/^@//' > "misc.c" <<'@//E*O*F misc.c//'
  976.  
  977. static char SccsId[] = "%W% %G% Copyright 1987 SBCS-chan";
  978.  
  979. /*****************************************************************************
  980.  
  981.           (c) Copyright 1987 
  982.  
  983.           Lap-Tak Chan
  984.           Computer Science Department
  985.           State University of New York at Stony Brook
  986.           Stony Brook, NY 11794
  987.  
  988.     This software and its documentation may be used, copied, and
  989.   distributed, provided that this legend appear in all copies and
  990.   that it is not copied or distributed for a profit.
  991.  
  992.   No representations is made about the suitability of this software
  993.   for any purpose.  It is provided "as is" with no support and no
  994.   express or implied warranty.
  995.  
  996. *****************************************************************************/
  997.  
  998. /*****************************************************************************
  999.  
  1000.     This file contains a number of miscellaneous routines.
  1001.  
  1002. *****************************************************************************/
  1003.  
  1004. #include <math.h>
  1005. #define DELTA 0.0001
  1006.  
  1007. /*****************************************************************************
  1008.  
  1009.   ge_midline determine the equation of the line between (x1,y1) and
  1010.   (x2,y2) in the form of y=ax+b
  1011.  
  1012.   Input
  1013.     x1,y1 - one point
  1014.     x2,y2 - another point
  1015.  
  1016.   Output
  1017.     a,b - the equation is y=ax+b
  1018.  
  1019. *****************************************************************************/
  1020.  
  1021. ge_midline(x1,y1,x2,y2,a,b)
  1022. float x1, y1, x2, y2, *a, *b;
  1023. {
  1024.  
  1025.   *a = (x1-x2)/(y2-y1);
  1026.   *b = ((x2*x2-x1*x1)/(y2-y1)+y2+y1)/2;
  1027.  
  1028. } /* ge_midline */
  1029.  
  1030. /*****************************************************************************
  1031.  
  1032.   ge_intersect determine the intersection (x,y) of
  1033.     y=ax+b and y=cx+d
  1034.  
  1035.   Input
  1036.     a,b - one equation is y=ax+b
  1037.     c,d - the other equation is y=cx+d
  1038.  
  1039.   Output
  1040.     x,y - intersection of the two equations
  1041.  
  1042. *****************************************************************************/
  1043.  
  1044. ge_intersect(a,b,c,d,x,y)
  1045. float a,b,c,d,*x,*y;
  1046. {
  1047.   *x = (d-b)/(a-c);
  1048.   *y = a * *x +b;
  1049.  
  1050. } /* ge_intersect */
  1051.  
  1052. /*****************************************************************************
  1053.  
  1054.   ge_radius2 determine the radius of the arc joining (x1,y1), (x2,y2),
  1055.   (x3,y3)
  1056.  
  1057.   Input
  1058.     x1,y1 - starting point
  1059.     x2,y2 - point in the middle
  1060.     x3,y3 - end point
  1061.  
  1062.   Output
  1063.     x,y - center of arc
  1064.     Return radius of arc, will be 0 if points are on the same line
  1065.  
  1066. *****************************************************************************/
  1067.  
  1068. float ge_radius2(x1,y1,x2,y2,x3,y3,x,y)
  1069. float x1,y1,x2,y2,x3,y3,*x,*y;
  1070. {
  1071.   float a,b,c,d;
  1072.  
  1073.   /* abort if any two points are the same */
  1074.   if ( (x1==x2 && y1==y2) ||
  1075.        (x2==x3 && y2==y3) ||
  1076.        (x1==x3 && y1==y2) ||
  1077.        (y1==y2 && y1==y3) )
  1078.     return(0.);
  1079.  
  1080.   /* determine midlines between (x1,y1),(x2,y2) and (x2,y2),(x3,y3) */
  1081.   ge_midline(x1,y1,x2,y2,&a,&b);
  1082.   ge_midline(x2,y2,x3,y3,&c,&d);
  1083.  
  1084.   if ( y1 == y2 ) {
  1085.     /* midline between (x1,y1) and (x2,y2) is vertical */
  1086.     *x=(x1+x2)/2;
  1087.     *y=c * *x + d;
  1088.   }
  1089.   else {
  1090.  
  1091.     if ( y2 == y3) {
  1092.       /* midline between (x2,y2) and (x3,y3) is vertical */
  1093.       *x=(x2+x3)/2;
  1094.       *y=a * *x + b;
  1095.     }
  1096.     else {
  1097.  
  1098.       /* abort if slope of the midlines are the same */
  1099.       if ( fabs(a-c) < DELTA ) {
  1100.         return(0.);
  1101.       } /* if */
  1102.  
  1103.       /* find intersection of midlines */
  1104.       ge_intersect(a,b,c,d,x,y);
  1105.  
  1106.     }
  1107.  
  1108.   }
  1109.  
  1110.   /* return radius */
  1111.   return((float)sqrt((*x-x1)*(*x-x1)+(*y-y1)*(*y-y1)));
  1112.  
  1113. } /* ge_radius2 */
  1114.  
  1115. /*****************************************************************************
  1116.  
  1117.   ge_radius determine the radius of the arc joining (x1,y1), (x2,y2),
  1118.   (x3,y3)
  1119.  
  1120.   Input
  1121.     x1,y1 - starting point
  1122.     x2,y2 - point in the middle
  1123.     x3,y3 - end point
  1124.  
  1125.   Output
  1126.     Return radius of arc, will be 0 if points are on the same line
  1127.  
  1128. *****************************************************************************/
  1129.  
  1130. float ge_radius(x1,y1,x2,y2,x3,y3)
  1131. float x1,y1,x2,y2,x3,y3;
  1132. {
  1133.   float x,y;
  1134.  
  1135.   /* just call ge_radius2 and discard the returned (x,y) */
  1136.   return(ge_radius2(x1,y1,x2,y2,x3,y3,&x,&y));
  1137.  
  1138. } /* ge_radius */
  1139. @//E*O*F misc.c//
  1140. chmod u=rw,g=r,o=r misc.c
  1141.  
  1142. echo x - ps2pic.c
  1143. sed 's/^@//' > "ps2pic.c" <<'@//E*O*F ps2pic.c//'
  1144.  
  1145. static char SccsId[] = "@(#)ps2pic.c    1.1 6/8/87 Copyright 1987 SBCS-chan";
  1146.  
  1147. /*****************************************************************************
  1148.  
  1149.           (c) Copyright 1987 
  1150.  
  1151.           Lap-Tak Chan
  1152.           Computer Science Department
  1153.           State University of New York at Stony Brook
  1154.           Stony Brook, NY 11794
  1155.  
  1156.     This software and its documentation may be used, copied, and
  1157.   distributed, provided that this legend appear in all copies and
  1158.   that it is not copied or distributed for a profit.
  1159.  
  1160.   No representations is made about the suitability of this software
  1161.   for any purpose.  It is provided "as is" with no support and no
  1162.   express or implied warranty.
  1163.  
  1164. *****************************************************************************/
  1165.  
  1166. /*****************************************************************************
  1167.  
  1168.                       Pic Output Driver
  1169.                       =================
  1170.  
  1171.     This file contains a simple driver to run the pic output routine.  It
  1172.   just load the picture from standard input with psload and call
  1173.   the pic output routine to write the picture to standard output.
  1174.  
  1175. *****************************************************************************/
  1176.  
  1177. #include "display.h"
  1178. #include <stdio.h>
  1179.  
  1180. int segopen = 0;
  1181. int newseg = GE_MIN_SEG;
  1182. int opensegment = 0;
  1183. extern struct list *ge_display_list();
  1184.  
  1185. /* default parameters, currently unused */
  1186. struct saveattr save_attr=
  1187.   {1, 0, 65, 100, 1, 5, 5};
  1188.  
  1189. /*****************************************************************************
  1190.  
  1191.     main will initialize the display list, load the picture with ps_load,
  1192.   and write the picture to standard output with the pic output routine.
  1193.  
  1194. *****************************************************************************/
  1195.  
  1196. main(argc, argv)
  1197. int argc;
  1198. char **argv;
  1199. {
  1200.   /* initialize the display list */
  1201.   ge_init_display();
  1202.  
  1203.   /* load picture from standard input */
  1204.   if ( ps_load(stdin) ) {
  1205.     fprintf(stderr, "%s: Input is not saved picture\n", argv[0] );
  1206.     exit(1);
  1207.   }
  1208.  
  1209.   /* write pic output to standard output */
  1210.   pic_write(stdout);
  1211.  
  1212.   exit(0);
  1213.  
  1214. } /* main */
  1215.  
  1216. /*****************************************************************************
  1217.  
  1218.     make_new_seg is used by ps_load to create the display list
  1219.   of a new segment.
  1220.  
  1221.   Input
  1222.     segno - segment number of segment.
  1223.  
  1224. *****************************************************************************/
  1225.  
  1226. make_new_seg(segno)
  1227. int segno;
  1228. {
  1229.   struct list *dlist;
  1230.  
  1231.   if ( !segno ) {
  1232.     opensegment = newseg++;
  1233.     segno = opensegment;
  1234.     segopen = 1;
  1235.   }
  1236.   ge_new_segment(segno);
  1237.   dlist=ge_display_list(segno);
  1238.   dlist->attr.deleted=0;
  1239.   dlist->attr.tx=0.; dlist->attr.ty=0.;
  1240.   dlist->attr.sx=1.; dlist->attr.sy=1.;
  1241.   dlist->attr.ang=0.;
  1242.   return(segno);
  1243.  
  1244. } /* make_new_seg */
  1245.  
  1246. /*****************************************************************************
  1247.  
  1248.     ge_draw is a dummy routine which is called by ps_load to update the
  1249.   display of a segment on the screen.  It does not do anything here.
  1250.  
  1251. *****************************************************************************/
  1252.  
  1253. ge_draw(segno)
  1254. int segno;
  1255. {
  1256.   /* dummy routine */
  1257.  
  1258. } /* ge_draw */
  1259. @//E*O*F ps2pic.c//
  1260. chmod u=r,g=r,o=r ps2pic.c
  1261.  
  1262. echo x - ps2plot.c
  1263. sed 's/^@//' > "ps2plot.c" <<'@//E*O*F ps2plot.c//'
  1264.  
  1265. static char SccsId[] = "@(#)ps2plot.c    1.1 6/8/87 Copyright 1987 SBCS-achan";
  1266.  
  1267. /*****************************************************************************
  1268.  
  1269.           (c) Copyright 1987 
  1270.  
  1271.           Lap-Tak Chan
  1272.           Computer Science Department
  1273.           State University of New York at Stony Brook
  1274.           Stony Brook, NY 11794
  1275.  
  1276.     This software and its documentation may be used, copied, and
  1277.   distributed, provided that this legend appear in all copies and
  1278.   that it is not copied or distributed for a profit.
  1279.  
  1280.   No representations is made about the suitability of this software
  1281.   for any purpose.  It is provided "as is" with no support and no
  1282.   express or implied warranty.
  1283.  
  1284. *****************************************************************************/
  1285.  
  1286. /*****************************************************************************
  1287.  
  1288.                       Plot Output Driver
  1289.                       ==================
  1290.  
  1291.     This file contains a simple driver to run the plot output routine.  It
  1292.   just load the picture from standard input with psload and call
  1293.   the plot output routine to write the picture to standard output.
  1294.  
  1295. *****************************************************************************/
  1296.  
  1297. #include "display.h"
  1298. #include <stdio.h>
  1299.  
  1300. int segopen = 0;
  1301. int newseg = GE_MIN_SEG;
  1302. int opensegment = 0;
  1303. extern struct list *ge_display_list();
  1304. struct saveattr save_attr;
  1305.  
  1306. /*****************************************************************************
  1307.  
  1308.     main will initialize the display list, load the picture with ps_load,
  1309.   and write the picture to standard output with the plot output routine.
  1310.  
  1311. *****************************************************************************/
  1312.  
  1313. main(argc, argv)
  1314. int argc;
  1315. char **argv;
  1316. {
  1317.   /* initialize the display list */
  1318.   ge_init_display();
  1319.  
  1320.   /* load picture from standard input */
  1321.   if ( ps_load(stdin) ) {
  1322.     fprintf(stderr, "%s: Input is not saved picture\n", argv[0] );
  1323.     exit(1);
  1324.   }
  1325.  
  1326.   /* write plot output to standard output */
  1327.   plt_write();
  1328.  
  1329.   exit(0);
  1330.  
  1331. } /* main */
  1332.  
  1333. /*****************************************************************************
  1334.  
  1335.     make_new_seg is used by ps_load to create the display list
  1336.   of a new segment.
  1337.  
  1338.   Input
  1339.     segno - segment number of segment.
  1340.  
  1341. *****************************************************************************/
  1342.  
  1343. make_new_seg(segno)
  1344. int segno;
  1345. {
  1346.   struct list *dlist;
  1347.  
  1348.   if ( !segno ) {
  1349.     opensegment = newseg++;
  1350.     segno = opensegment;
  1351.     segopen = 1;
  1352.   }
  1353.   ge_new_segment(segno);
  1354.   dlist=ge_display_list(segno);
  1355.   dlist->attr.deleted=0;
  1356.   dlist->attr.tx=0.; dlist->attr.ty=0.;
  1357.   dlist->attr.sx=1.; dlist->attr.sy=1.;
  1358.   dlist->attr.ang=0.;
  1359.   return(segno);
  1360.  
  1361. } /* make_new_seg */
  1362.  
  1363. /*****************************************************************************
  1364.  
  1365.     ge_draw is a dummy routine which is called by ps_load to update the
  1366.   display of a segment on the screen.  It does not do anything here.
  1367.  
  1368. *****************************************************************************/
  1369.  
  1370. ge_draw(segno)
  1371. int segno;
  1372. {
  1373.   /* dummy routine */
  1374.  
  1375. } /* ge_draw */
  1376. @//E*O*F ps2plot.c//
  1377. chmod u=r,g=r,o=r ps2plot.c
  1378.  
  1379. echo x - optm.c
  1380. sed 's/^@//' > "optm.c" <<'@//E*O*F optm.c//'
  1381.  
  1382. static char SccsId[] = "@(#)optm.c    1.1 6/8/87 Copyright 1987 SBCS-chan";
  1383.  
  1384. /*****************************************************************************
  1385.  
  1386.           (c) Copyright 1987 
  1387.  
  1388.           Lap-Tak Chan
  1389.           Computer Science Department
  1390.           State University of New York at Stony Brook
  1391.           Stony Brook, NY 11794
  1392.  
  1393.     This software and its documentation may be used, copied, and
  1394.   distributed, provided that this legend appear in all copies and
  1395.   that it is not copied or distributed for a profit.
  1396.  
  1397.   No representations is made about the suitability of this software
  1398.   for any purpose.  It is provided "as is" with no support and no
  1399.   express or implied warranty.
  1400.  
  1401. *****************************************************************************/
  1402.  
  1403.  
  1404. /*****************************************************************************
  1405.  
  1406.                         Optimizer Driver
  1407.                         ================
  1408.  
  1409.     This file contains a simple driver to run the optimizer routine.  It
  1410.   just load the picture from standard input with psload, execute the 
  1411.   optimizer routine and save the picture to standard output.
  1412.  
  1413. *****************************************************************************/
  1414.  
  1415. #include "display.h"
  1416. #include <stdio.h>
  1417.  
  1418. int segopen = 0;
  1419. int newseg = GE_MIN_SEG;
  1420. int opensegment = 0;
  1421.  
  1422. extern struct list *ge_display_list();
  1423. struct saveattr save_attr;
  1424.  
  1425. /*****************************************************************************
  1426.  
  1427.     main will initialize the display list, load the picture with ps_load,
  1428.   run the optimizer, and save the picture with ps_save.
  1429.  
  1430. *****************************************************************************/
  1431.  
  1432. main(argc, argv)
  1433. int argc;
  1434. char **argv;
  1435. {
  1436.   /* initialize the display list */
  1437.   ge_init_display();
  1438.  
  1439.   /* load picture from standard input */
  1440.   if ( ps_load(stdin) ) {
  1441.     fprintf(stderr, "%s: Input is not saved picture\n", argv[0] );
  1442.     exit(1);
  1443.   }
  1444.  
  1445.   /* run the optimizer */
  1446.   optimize();
  1447.  
  1448.   /* save the picture to stardard output */
  1449.   ps_write(stdout);
  1450.   exit(0);
  1451.  
  1452. } /* main */
  1453.  
  1454. /*****************************************************************************
  1455.  
  1456.     make_new_seg is used by ps_load and optimize to create the display list
  1457.   of a new segment.
  1458.  
  1459.   Input
  1460.     segno - segment number of segment.
  1461.  
  1462. *****************************************************************************/
  1463.  
  1464. make_new_seg(segno)
  1465. int segno;
  1466. {
  1467.   struct list *dlist;
  1468.  
  1469.   if ( !segno ) {
  1470.     opensegment = newseg++;
  1471.     segno = opensegment;
  1472.     segopen = 1;
  1473.   }
  1474.   ge_new_segment(segno);
  1475.   dlist=ge_display_list(segno);
  1476.   dlist->attr.deleted=0;
  1477.   dlist->attr.tx=0.; dlist->attr.ty=0.;
  1478.   dlist->attr.sx=1.; dlist->attr.sy=1.;
  1479.   dlist->attr.ang=0.;
  1480.   return(segno);
  1481.  
  1482. } /* make_new_seg */
  1483.  
  1484. /*****************************************************************************
  1485.  
  1486.     ge_draw is a dummy routine which is called by ps_load to update the
  1487.   display of a segment on the screen.  It does not do anything here.
  1488.  
  1489. *****************************************************************************/
  1490.  
  1491. ge_draw(segno)
  1492. {
  1493.   /* dummy routine */
  1494.  
  1495. } /* ge_draw */
  1496. @//E*O*F optm.c//
  1497. chmod u=r,g=r,o=r optm.c
  1498.  
  1499. echo Inspecting for damage in transit...
  1500. temp=/tmp/shar$$; dtemp=/tmp/.shar$$
  1501. trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
  1502. cat > $temp <<\!!!
  1503.        4       9     193 arc.pr
  1504.        9      14     483 border.pr
  1505.        9      14     483 borderfill.pr
  1506.        4       9     193 circle.pr
  1507.        9      14     483 dash.pr
  1508.        9      14     483 dot.pr
  1509.        9      14     483 dotdash.pr
  1510.        4       9     193 ellipse.pr
  1511.        9      14     483 fill.pr
  1512.       34      39    1933 norotate.pr
  1513.        4       9     193 polygon.pr
  1514.        4       9     193 polyline.pr
  1515.        4       9     193 rect.pr
  1516.       34      39    1933 rotate.pr
  1517.        9      14     483 solid.pr
  1518.        4       9     193 text.pr
  1519.        4       9     193 trace.pr
  1520.       34      39    1933 graphedit.icon
  1521.      160     459    2972 ps.head
  1522.      251    1536    9776 graphedit.l
  1523.      237     801    7398 optmize.c
  1524.      163     455    4031 misc.c
  1525.      115     340    3141 ps2pic.c
  1526.      112     327    3071 ps2plot.c
  1527.      115     326    3095 optm.c
  1528.     1350    4531   44208 total
  1529. !!!
  1530. wc  images/arc.pr images/border.pr images/borderfill.pr images/circle.pr images/dash.pr images/dot.pr images/dotdash.pr images/ellipse.pr images/fill.pr images/norotate.pr images/polygon.pr images/polyline.pr images/rect.pr images/rotate.pr images/solid.p
  1531.  
  1532.  
  1533. r images/text.pr images/trace.pr images/graphedit.icon ps.head graphedit.l optmize.c misc.c ps2pic.c ps2plot.c optm.c | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
  1534. if [ -s $dtemp ]
  1535. then echo "Ouch [diff of wc output]:" ; cat $dtemp
  1536. else echo "No problems found."
  1537. fi
  1538. exit 0
  1539.  
  1540.  
  1541.