home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / plot / plot2gl.sha / libplot.c next >
Encoding:
C/C++ Source or Header  |  1989-04-09  |  1.3 KB  |  93 lines

  1. /*
  2.  * plot(3) clone. Implements the commands described in the the V7 UNIX 
  3.  * manual pages and produces a standard UNIX plotfile. 
  4.  *
  5.  * The resulting plotfile is to be used with the plot(1) command.
  6.  *
  7.  * Author: Wietse Venema (wietse@wzv.UUCP)
  8.  */
  9.  
  10. #include <stdio.h>
  11.  
  12. /* some shorthands... */
  13.  
  14. #define    Write(x)        fwrite((char *) &x, sizeof(x), 1, stdout)
  15. #define    Write2(a,b)        Write(a); Write(b)
  16. #define    Write3(a,b,c)        Write2(a,b); Write(c)
  17. #define    Write4(a,b,c,d)        Write2(a,b); Write2(c,d)
  18. #define    Write6(a,b,c,d,e,f)    Write4(a,b,c,d); Write2(e,f)
  19.  
  20. openpl()
  21. {
  22. #ifndef unix
  23.     you may have to select binary mode for stdout
  24. #endif
  25. }
  26.  
  27. move(x, y)
  28. {
  29.     putchar('m');
  30.     Write2(x, y);
  31. }
  32.  
  33. cont(x, y)
  34. {
  35.     putchar('n');
  36.     Write2(x, y);
  37. }
  38.  
  39. point(x, y)
  40. {
  41.     putchar('p');
  42.     Write2(x, y);
  43. }
  44.  
  45. line(x1, y1, x2, y2)
  46. {
  47.     putchar('l');
  48.     Write4(x1, y1, x2, y2);
  49. }
  50.  
  51. label(s)
  52. char           *s;
  53. {
  54.     putchar('t');
  55.     fputs(s,stdout);
  56.     putchar('\0');
  57. }
  58.  
  59. arc(x, y, x0, y0, x1, y1)
  60. {
  61.     putchar('a');
  62.     Write6(x, y, x0, y0, x1, y1);
  63. }
  64.  
  65. circle(x, y, r)
  66. {
  67.     putchar('c');
  68.     Write3(x, y, r);
  69. }
  70.  
  71. erase()
  72. {
  73.     putchar('e');
  74. }
  75.  
  76. linemod(s)
  77. char           *s;
  78. {
  79.     putchar('f');
  80.     puts(s);
  81. }
  82.  
  83. space(x0, y0, x1, y1)
  84. {
  85.     putchar('s');
  86.     Write4(x0, y0, x1, y1);
  87. }
  88.  
  89. closepl()
  90. {
  91.     fflush(stdout);
  92. }
  93.