home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume22 / transfig / part05 < prev    next >
Text File  |  1990-10-09  |  31KB  |  1,174 lines

  1. Subject:  v23i018:  Tools for creating TeX documents with portable graphics, Part05/06
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 8a059bdc f22e12ec b155b6b2 a054c52c
  5.  
  6. Submitted-by: Micah Beck <beck@cs.cornell.edu>
  7. Posting-number: Volume 23, Issue 18
  8. Archive-name: transfig/part05
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 5 (of 6)."
  17. # Contents:  transfig/fig2dev/dev/genepic.c
  18. # Wrapped by beck@rocky on Thu May 17 15:56:13 1990
  19. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  20. if test -f 'transfig/fig2dev/dev/genepic.c' -a "${1}" != "-c" ; then 
  21.   echo shar: Will not clobber existing file \"'transfig/fig2dev/dev/genepic.c'\"
  22. else
  23. echo shar: Extracting \"'transfig/fig2dev/dev/genepic.c'\" \(28053 characters\)
  24. sed "s/^X//" >'transfig/fig2dev/dev/genepic.c' <<'END_OF_FILE'
  25. X/*
  26. X * genepic.c: (E)EPIC driver for fig2dev
  27. X *
  28. X * Converted from fig2epic 5/89 by Micah Beck
  29. X */
  30. X/*==================================================================*/
  31. X/*    fig2epic (Fig to EPIC converter)                 */
  32. X/*         Version 1.1d <March 30, 1988>                */
  33. X/*                                    */
  34. X/*    Written by Conrad Kwok, Division of Computer Science, UCD   */
  35. X/*                                    */
  36. X/*    Permission is granted for freely distribution of this file  */
  37. X/*        provided that this message is included.            */
  38. X/*==================================================================*/
  39. X
  40. X/*====================================================================
  41. X  Changes:
  42. X
  43. X  Version 1.0d:<September 18, 1988>
  44. X  1. Add the option -P for Page mode. Two more configurable parameter---
  45. X     Preamble and Postamble.
  46. X
  47. X  Version 1.1a: <January 18, 1989>
  48. X  1. Fix the bug in closed control splines. The routine convertCS(p) is being
  49. X     called once too often.
  50. X
  51. X  2. Add supports to Variable line width
  52. X  3. Add supports to black, white or shaded area fill.
  53. X
  54. X  Version 1.1b: <Febrary 2, 1989>
  55. X  1. Draw outline for area-filled figures when using dvips.
  56. X
  57. X  Version 1.1c: <Febrary 7, 1989>
  58. X  1. Supports all 5 gray level in area fill.
  59. X
  60. X  Version 1.1d: <March 30, 1989>
  61. X  1. Add supports for Gould NP1 (Bsd4.3) (Recieve the changes from
  62. X        mcvax!presto.irisa.fr!hleroy@uunet.uu.net. Sorry
  63. X        I don't have his/her name)
  64. X  2. Add exit(0) before exit in the main.
  65. X====================================================================*/
  66. X
  67. X  
  68. X#include <stdio.h>
  69. X#include <math.h>
  70. X#include <string.h>
  71. X#include <varargs.h>
  72. X#include <ctype.h>
  73. X#include "object.h"
  74. X#include "fig2dev.h"
  75. X#include "texfonts.h"
  76. X#include "pi.h"
  77. X
  78. X#ifdef MSDOS
  79. X#define getopt egetopt
  80. X#define M_PI 3.14159265358979324
  81. X#endif
  82. X
  83. X#define DrawOutLine
  84. X#ifdef DrawOutLine
  85. Xint OutLine=0;
  86. X#endif
  87. X
  88. X#define TopCoord 840        /* 10.5 in * 80 (DPI)            */
  89. X                /* Actually, it can be any value */
  90. X#define PtPerLine 3
  91. X#define ThinLines 0
  92. X#define ThickLines 1
  93. X#define FALSE 0
  94. X#define TRUE 1
  95. X#define Epic 0
  96. X#define EEpic_emu 1
  97. X#define EEpic 2
  98. X#define None 0
  99. X#define SolidLineBox 1
  100. X#define DashLineBox 2
  101. X#define BothBoxType 3
  102. X#define Normal 0
  103. X#define Economic 1
  104. X#define DottedDash 2
  105. X
  106. Xvoid genepic_ctl_spline(), genepic_int_spline(); 
  107. Xvoid genepic_open_spline(), genepic_closed_spline(); 
  108. X
  109. X/* Structure for Point with "double" values */
  110. Xstruct fp_struct {
  111. X    double x,y;
  112. X};
  113. X
  114. Xtypedef struct fp_struct FPoint;
  115. X
  116. X/* Local to the file only */
  117. Xstatic int CoordSys = 2;
  118. Xstatic double Threshold;
  119. Xstatic int DPI;
  120. Xstatic int CurWidth = 0;
  121. Xstatic int LineStyle = SOLID_LINE;
  122. Xstatic int LLX = 0, LLY = 0;
  123. Xstatic char *LnCmd;
  124. Xstatic int MaxCircleRadius;
  125. Xstatic double DashLen;
  126. Xstatic int PageMode = FALSE;
  127. Xstatic F_pattern *PatternType=UNFILLED;
  128. Xstatic struct {
  129. X    double mag;
  130. X    int size;
  131. X} ScaleTbl[5] = {
  132. X    { 0.6667, 8 },
  133. X    { 0.75  , 9 },
  134. X    { 0.8333, 10 },
  135. X    { 0.9167, 11 },
  136. X    { 1.0   , 12 }
  137. X};
  138. X
  139. X/* Definition of Keywords for some of the configurable parameter */
  140. Xchar *Tlangkw[] = { /* The order must match the definition of corr. constants */
  141. X    "Epic", "EEpicemu", "EEpic", NULL
  142. X};
  143. X
  144. Xchar *EllCmdkw[] = {
  145. X    "ellipse", "oval", NULL
  146. X};
  147. X
  148. Xchar *EllCmdstr[] = {
  149. X    "\\%s%s{%d}{%d}}\n", "\\%s%s(%d,%d)}\n"
  150. X};
  151. X
  152. Xchar *FillCommands[] = {
  153. X    "", "\\blacken", "\\shade", "\\shade", "\\shade", "\\whiten"
  154. X};
  155. X
  156. X#define TEXT_LINE_SEP '\n'
  157. X/* The following two arrays are used to translate characters which
  158. X   are special to LaTeX into characters that print as one would expect.
  159. X   Note that the <> characters aren't really special LaTeX characters
  160. X   but they will not print as themselves unless one is using a font
  161. X   like tt. */
  162. Xchar latex_text_specials[] = "\\{}><^~$&#_%";
  163. Xchar *latex_text_mappings[] = {
  164. X  "$\\backslash$",
  165. X  "$\\{$",
  166. X  "$\\}$",
  167. X  "$>$",
  168. X  "$<$",
  169. X  "\\^{}",
  170. X  "\\~{}",
  171. X  "\\$",
  172. X  "\\&",
  173. X  "\\#",
  174. X  "\\_",
  175. X  "\\%"};
  176. X
  177. X
  178. X/* Configurable parameters */
  179. Xint LowerLeftX=0, LowerLeftY=0;
  180. Xdouble SegLen = 0.0625; /* inch */
  181. Xint Verbose = FALSE;
  182. Xint TopMargin = 5;
  183. Xint BottomMargin = 10;
  184. Xint DotDist = 5;
  185. Xint LineThick = 2;
  186. Xint TeXLang = EEpic;
  187. Xdouble DashScale=1;
  188. Xint EllipseCmd=0;
  189. Xint UseBox=None;
  190. Xint DashType=Normal;
  191. Xchar *Preamble="\\documentstyle[epic,eepic]{article}\n\\begin{document}\n\\begin{center}\n";
  192. Xchar *Postamble="\\end{center}\n\\end{document}\n";
  193. Xint VarWidth=FALSE;
  194. X
  195. Xvoid genepic_option(opt, optarg)
  196. Xchar opt, *optarg;
  197. X{
  198. X      int loop;
  199. X
  200. X        switch (opt) {
  201. X        case 'S':
  202. X            loop = atoi(optarg);
  203. X            if (loop < 8 || loop > 12) {
  204. X                put_msg("Scale must be between 8 and 12 inclusively\n");
  205. X                exit(1);
  206. X            }
  207. X            loop -= 8;
  208. X            mag = ScaleTbl[loop].mag;
  209. X            font_size = ScaleTbl[loop].size;
  210. X            break;
  211. X
  212. X        case 'l':
  213. X            LineThick = atoi(optarg);
  214. X            break;
  215. X
  216. X        case 'v':
  217. X            Verbose = TRUE;
  218. X            break;
  219. X
  220. X    case 'L':
  221. X        for (loop=0; loop < 3; loop++) {
  222. X            if (stricmp(optarg, Tlangkw[loop]) == 0) break;
  223. X        }
  224. X        TeXLang = loop;
  225. X        break;
  226. X
  227. X    case 'w':
  228. X    case 'W':
  229. X        VarWidth = opt=='W';
  230. X        break;
  231. X
  232. X    case 'f':
  233. X    {   int i;
  234. X
  235. X        for ( i = 1; i <= MAXFONT + 1; i++ )
  236. X        if ( !strcmp(optarg, fontnames[i]) ) break;
  237. X
  238. X        if ( i > MAXFONT + 1 )
  239. X        fprintf(stderr,
  240. X            "warning: non-standard font name %s\n", optarg);
  241. X    }
  242. X    
  243. X            fontnames[0] = fontnames[1] = optarg;
  244. X        break;
  245. X
  246. X    case 's':
  247. X        if (font_size <= 0 || font_size > MAXFONTSIZE) {
  248. X        fprintf(stderr,
  249. X            "warning: font size %d out of bounds\n", font_size);
  250. X        }
  251. X        break;
  252. X
  253. X    case 'm':
  254. X        break;
  255. X
  256. X    default:
  257. X        put_msg(Err_badarg, opt, "epic");
  258. X        exit(1);
  259. X        break;
  260. X        }
  261. X}
  262. X
  263. Xstatic fconvertCS(fpt)
  264. XFPoint *fpt;
  265. X{
  266. X    if (CoordSys) {
  267. X        fpt->y = TopCoord - fpt->y;
  268. X    }
  269. X    fpt->x -= LLX;
  270. X    fpt->y -= LLY;
  271. X}
  272. X
  273. XconvertCS(pt)
  274. XF_point *pt;
  275. X{
  276. X    if (CoordSys) {
  277. X        pt->y = TopCoord - pt->y;
  278. X    }
  279. X    pt->x -= LLX;
  280. X    pt->y -= LLY;
  281. X}
  282. X
  283. Xvoid genepic_start(objects)
  284. XF_compound *objects;
  285. X{
  286. X    int temp;
  287. X    F_point pt1, pt2;
  288. X    F_arc *arc;
  289. X    F_compound *comp;
  290. X    F_ellipse *ell;
  291. X    F_line *line;
  292. X    F_spline *spl;
  293. X    F_text *text;
  294. X
  295. X    fontsizes[0] = fontsizes[1] = TEXFONTSIZE(font_size);
  296. X
  297. X    switch (TeXLang) {
  298. X    case Epic:
  299. X        EllipseCmd = 1; /* Oval */
  300. X        LnCmd = "drawline";
  301. X        break;
  302. X    case EEpic_emu:
  303. X    case EEpic:
  304. X        LnCmd = "path";
  305. X        break;
  306. X    default:
  307. X        put_msg("Program error in main\n");
  308. X        break;
  309. X    }
  310. X    if (PageMode) {
  311. X        fputs(Preamble, stdout);
  312. X    }
  313. X
  314. X    DPI = objects->nwcorner.x;
  315. X    if (DPI <= 0) {
  316. X        put_msg("Resolution has to be positive. Default to 80!\n");
  317. X        DPI = 80;
  318. X    }
  319. X    coord_system = objects->nwcorner.y;
  320. X    switch (coord_system) {
  321. X    case 1:
  322. X        CoordSys = 0;
  323. X        break;
  324. X    case 2:
  325. X        CoordSys = 1;
  326. X        break;
  327. X    default:
  328. X        put_msg("Unknown Coordinate system -- %d\n", coord_system);
  329. X        exit(1);
  330. X    }
  331. X    pt1.x = llx;
  332. X    pt1.y = lly;
  333. X    pt2.x = urx;
  334. X    pt2.y = ury;
  335. X    convertCS(&pt1);
  336. X    convertCS(&pt2);
  337. X    if (pt1.x > pt2.x) {
  338. X        temp = pt1.x;
  339. X        pt1.x = pt2.x;
  340. X        pt2.x = temp;
  341. X    }
  342. X    if (pt1.y > pt2.y) {
  343. X        temp = pt1.y;
  344. X        pt1.y = pt2.y;
  345. X        pt2.y = temp;
  346. X    }
  347. X    LLX = pt1.x - LowerLeftX;
  348. X    LLY = pt1.y - LowerLeftY;
  349. X    if (Verbose) {
  350. X        fprintf(tfp, "%%\n%% Language in use is %s\n%%\n", Tlangkw[TeXLang]);
  351. X    }
  352. X    Threshold = 1.0 / DPI * mag;
  353. X    fprintf(tfp, "\\setlength{\\unitlength}{%.4fin}\n", Threshold);
  354. X    MaxCircleRadius = (int) (40 / 72.27 / Threshold);
  355. X    Threshold = SegLen / Threshold;
  356. X    fprintf(tfp, "\\begin{picture}(%d,%d)(%d,%d)\n",
  357. X           pt2.x-pt1.x, pt2.y-pt1.y + TopMargin + BottomMargin,
  358. X           LowerLeftX, LowerLeftY-BottomMargin);
  359. X}
  360. X
  361. Xvoid genepic_end()
  362. X{
  363. X    fprintf(tfp, "\\end{picture}\n");
  364. X    if (PageMode)
  365. X        fputs(Postamble, stdout);
  366. X}
  367. X
  368. Xstatic set_linewidth(w)
  369. Xint w;
  370. X{
  371. X    int old_width;
  372. X
  373. X    if (w < 0) return;
  374. X    old_width=CurWidth;
  375. X    CurWidth = (w >= LineThick) ? (VarWidth ? w : ThickLines) : ThinLines;
  376. X    if (old_width != CurWidth) {
  377. X    if (CurWidth==ThinLines) {
  378. X        fprintf(tfp, "\\thinlines\n");
  379. X    } else if (VarWidth) {
  380. X        fprintf(tfp, "\\allinethickness{%d}%%\n",w);
  381. X    } else {
  382. X        fprintf(tfp, "\\thicklines\n");
  383. X    }
  384. X    }
  385. X}
  386. X
  387. Xset_pattern(type)
  388. XF_pattern *type;
  389. X{
  390. X    static unsigned long patterns[3][32] = {
  391. X    { 0x55555555, 0, 0x55555555, 0, 0x55555555, 0, 0x55555555, 0,
  392. X      0x55555555, 0, 0x55555555, 0, 0x55555555, 0, 0x55555555, 0,
  393. X      0x55555555, 0, 0x55555555, 0, 0x55555555, 0, 0x55555555, 0,
  394. X      0x55555555, 0, 0x55555555, 0, 0x55555555, 0, 0x55555555, 0},
  395. X    { 0xcccccccc, 0, 0, 0, 0xcccccccc, 0, 0, 0,
  396. X      0xcccccccc, 0, 0, 0, 0xcccccccc, 0, 0, 0,
  397. X      0xcccccccc, 0, 0, 0, 0xcccccccc, 0, 0, 0,
  398. X      0xcccccccc, 0, 0, 0, 0xcccccccc, 0, 0, 0},
  399. X    { 0xc0c0c0c0, 0, 0, 0, 0, 0, 0, 0,
  400. X      0xc0c0c0c0, 0, 0, 0, 0, 0, 0, 0,
  401. X      0xc0c0c0c0, 0, 0, 0, 0, 0, 0, 0,
  402. X      0xc0c0c0c0, 0, 0, 0, 0, 0, 0, 0}};
  403. X    int count, loop1, loop2, i;
  404. X
  405. X    if (type < DARK_GRAY_FILL || type > LIGHT_GRAY_FILL) return;
  406. X    if (type != PatternType) {
  407. X    PatternType=type;
  408. X    i = (int) PatternType - (int) DARK_GRAY_FILL;
  409. X    fprintf(tfp, "\\texture{");
  410. X    count=0;
  411. X    for (loop1=4; loop1>0;) {
  412. X        for (loop2=8; loop2>0; loop2--) 
  413. X        fprintf(tfp, "%lx ", patterns[i][count++]);
  414. X        if (--loop1 > 0)
  415. X        fprintf(tfp, "\n\t");
  416. X        else
  417. X        fprintf(tfp, "}%\n");
  418. X    }
  419. X    }
  420. X}
  421. X
  422. Xvoid genepic_line(line)
  423. XF_line *line;
  424. X{
  425. X    F_point *p, *q;
  426. X    int pt_count = 0, temp;
  427. X    int boxflag = FALSE, llx, lly, urx, ury;
  428. X    double dtemp;
  429. X
  430. X    set_linewidth(line->thickness);
  431. X    set_style(line->style, line->style_val);
  432. X    p = line->points;
  433. X    q = p->next;
  434. X    convertCS(p);
  435. X    if (q == NULL) {
  436. X    fprintf(tfp, "\\drawline(%d,%d)(%d,%d)\n", p->x, p->y, p->x, p->y);
  437. X    return;
  438. X    }
  439. X    if (line->type == T_BOX) {
  440. X    if (Verbose) {
  441. X        fprintf(tfp, "%%\n%% A box\n%%\n");
  442. X    }
  443. X    switch (LineStyle) {
  444. X    case SOLID_LINE:
  445. X        if (UseBox == BothBoxType || UseBox == SolidLineBox) {
  446. X            boxflag = TRUE;
  447. X        }
  448. X        break;
  449. X    case DASH_LINE:
  450. X        if (UseBox == BothBoxType || UseBox == DashLineBox) {
  451. X            boxflag = TRUE;
  452. X        }
  453. X        break;
  454. X    }
  455. X    if (boxflag) {
  456. X        llx = urx = p->x;
  457. X        lly = ury = p->y;
  458. X        while (q != NULL) {
  459. X            convertCS(q);
  460. X            if (q->x < llx) {
  461. X                llx = q->x;
  462. X            } else if (q->x > urx) {
  463. X                urx = q->x;
  464. X            }
  465. X            if (q->y < lly) {
  466. X                lly = q->y;
  467. X            } else if (q->y > ury) {
  468. X                ury = q->y;
  469. X            }
  470. X            q = q->next;
  471. X        }
  472. X        switch(LineStyle) {
  473. X        case SOLID_LINE:
  474. X            fprintf(tfp, "\\put(%d,%d){\\framebox(%d,%d){}}\n",
  475. X                llx, lly, urx-llx, ury-lly);
  476. X            break;
  477. X        case DASH_LINE:
  478. X        temp = (int) ((urx-llx) / DashLen);
  479. X        dtemp = (double) (urx-llx) / temp;
  480. X            fprintf(tfp, "\\put(%d,%d){\\dashbox{%4.3f}(%d,%d){}}\n",
  481. X                llx, lly, dtemp , urx-llx, ury-lly);
  482. X            break;
  483. X        default:
  484. X            put_msg("Program Error! No other line styles allowed.\n");
  485. X            break;
  486. X        }
  487. X        return;
  488. X      }
  489. X    }
  490. X    set_pattern(line->area_fill);
  491. X    convertCS(q);
  492. X    if (line->back_arrow) {
  493. X    draw_arrow_head(q, p, line->back_arrow->ht, line->back_arrow->wid);
  494. X        if (Verbose) fprintf(tfp, "%%\n");
  495. X    }
  496. X    switch (LineStyle) {
  497. X    case SOLID_LINE:
  498. X    if (q->next != NULL && strcmp(LnCmd,"path")==0) {
  499. X        if (line->area_fill < UNFILLED) line->area_fill = UNFILLED;
  500. X        fprintf(tfp, "%s", FillCommands[(int) line->area_fill]);
  501. X    }
  502. X    fprintf(tfp, "\\%s", LnCmd);
  503. X#ifdef DrawOutLine
  504. X    if (line->area_fill != UNFILLED && OutLine == 0) OutLine=1;
  505. X#endif
  506. X    break;
  507. X    case DASH_LINE:
  508. X        if ((TeXLang==Epic || TeXLang ==EEpic_emu) && DashType == Economic) {
  509. X            fprintf(tfp, "\\drawline[-50]");
  510. X        } else {
  511. X        fprintf(tfp, "\\dashline{%4.3f}", DashLen);
  512. X    }
  513. X    break;
  514. X    case DOTTED_LINE:
  515. X    fprintf(tfp, "\\dottedline{%d}", DotDist);
  516. X    break;
  517. X    default:
  518. X    fprintf(stderr,"Unknown Style\n");
  519. X    exit(1);
  520. X    }
  521. X    fprintf(tfp, "(%d,%d)", p->x, p->y);
  522. X    pt_count++;
  523. X    while(q->next != NULL) {
  524. X    if (++pt_count > PtPerLine) {
  525. X        pt_count=1;
  526. X        fprintf(tfp, "\n\t");
  527. X    }
  528. X    fprintf(tfp, "(%d,%d)", q->x, q->y);
  529. X    p=q;
  530. X    q = q->next;
  531. X    convertCS(q);
  532. X    }
  533. X    fprintf(tfp, "(%d,%d)\n", q->x, q->y);
  534. X#ifdef DrawOutLine
  535. X    if (OutLine == 1) {
  536. X    OutLine=0;
  537. X    fprintf(tfp, "\\%s", LnCmd);
  538. X    p=line->points;
  539. X    pt_count=0;
  540. X    q=p->next;
  541. X    fprintf(tfp, "(%d,%d)", p->x, p->y);
  542. X    pt_count++;
  543. X    while(q->next != NULL) {
  544. X        if (++pt_count > PtPerLine) {
  545. X        pt_count=1;
  546. X        fprintf(tfp, "\n\t");
  547. X        }
  548. X        fprintf(tfp, "(%d,%d)", q->x, q->y);
  549. X        p=q;
  550. X        q = q->next;
  551. X    }
  552. X    fprintf(tfp, "(%d,%d)\n", q->x, q->y);
  553. X    }
  554. X#endif
  555. X    if (line->for_arrow) {
  556. X    draw_arrow_head(p, q, line->for_arrow->ht, line->for_arrow->wid);
  557. X        if (Verbose) fprintf(tfp, "%%\n");
  558. X    }
  559. X}
  560. X
  561. Xset_style(style, dash_len)
  562. Xint style;
  563. Xfloat dash_len;
  564. X{
  565. X    LineStyle = style;
  566. X    if (LineStyle == DASH_LINE) {
  567. X        switch (DashType) {
  568. X        case DottedDash:
  569. X            LineStyle = DOTTED_LINE;
  570. X            break;
  571. X        default:
  572. X            DashLen = dash_len * DashScale;
  573. X            break;
  574. X        }
  575. X    }
  576. X}
  577. X
  578. X
  579. Xvoid genepic_spline(spl)
  580. XF_spline *spl;
  581. X{
  582. X    set_linewidth(spl->thickness);
  583. X    set_style(SOLID_LINE, 0.0);
  584. X    if (int_spline(spl)) {
  585. X    genepic_itp_spline(spl);
  586. X    } else {
  587. X    genepic_ctl_spline(spl);
  588. X    }
  589. X}
  590. X
  591. Xvoid genepic_ctl_spline(spl)
  592. XF_spline *spl;
  593. X{
  594. X    if (closed_spline(spl)) {
  595. X    genepic_closed_spline(spl);
  596. X    } else {
  597. X    genepic_open_spline(spl);
  598. X    }
  599. X}
  600. X
  601. Xstatic void genepic_open_spline(spl)
  602. XF_spline *spl;
  603. X{
  604. X    F_point *p, *q, *r;
  605. X    FPoint first, mid;
  606. X    int pt_count = 0;
  607. X
  608. X    p = spl->points;
  609. X    q = p->next;
  610. X    convertCS(p);
  611. X    convertCS(q);
  612. X    if (spl->back_arrow) {
  613. X    draw_arrow_head(q, p, spl->back_arrow->ht, spl->back_arrow->wid);
  614. X        if (Verbose) fprintf(tfp, "%%\n");
  615. X    }
  616. X    if (q->next == NULL) {
  617. X    fprintf(tfp, "\\%s(%d,%d)(%d,%d)\n", LnCmd,
  618. X           p->x, p->y, q->x, q->y);
  619. X    return;
  620. X    }
  621. X    if (TeXLang == EEpic || TeXLang == EEpic_emu) {
  622. X        fprintf(tfp, "\\spline(%d,%d)\n", p->x, p->y);
  623. X        pt_count++;
  624. X        while(q->next != NULL) {
  625. X             if (++pt_count > PtPerLine) {
  626. X                 pt_count=1;
  627. X                 fprintf(tfp, "\n\t");
  628. X             }
  629. X             fprintf(tfp, "(%d,%d)", q->x, q->y);
  630. X             p=q;
  631. X             q = q->next;
  632. X             convertCS(q);
  633. X        }
  634. X        fprintf(tfp, "(%d,%d)\n", q->x, q->y);
  635. X    } else {
  636. X        fprintf(tfp, "\\%s(%d,%d)\n", LnCmd, p->x, p->y);
  637. X        r = q->next;
  638. X        convertCS(r);
  639. X        first.x = p->x;
  640. X        first.y = p->y;
  641. X        while (r->next != NULL) {
  642. X            mid.x = (q->x + r->x) / 2.0;
  643. X            mid.y = (q->y + r->y) / 2.0;
  644. X            chaikin_curve(first.x, first.y, (double) q->x, (double) q->y,
  645. X                            mid.x, mid.y);
  646. X            first = mid;
  647. X            q=r;
  648. X            r = r->next;
  649. X            convertCS(r);
  650. X        }
  651. X        chaikin_curve(first.x, first.y, (double) q->x, (double) q->y,
  652. X                        (double) r->x, (double) r->y);
  653. X        p=q;
  654. X        q=r;
  655. X    fprintf(tfp, "\n");
  656. X    }
  657. X    if (spl->for_arrow) {
  658. X    draw_arrow_head(p, q, spl->for_arrow->ht, spl->for_arrow->wid);
  659. X        if (Verbose) fprintf(tfp, "%%\n");
  660. X    }
  661. X}
  662. X
  663. Xstatic void genepic_closed_spline(spl)
  664. XF_spline *spl;
  665. X{
  666. X    F_point *p;
  667. X    double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
  668. X    double x1, y1, x2, y2;
  669. X
  670. X    p = spl->points;
  671. X    convertCS(p);
  672. X    x1 = p->x;  y1 = p->y;
  673. X    p = p->next;
  674. X    convertCS(p);
  675. X    x2 = p->x;  y2 = p->y;
  676. X    cx1 = (x1 + x2) / 2;      cy1 = (y1 + y2) / 2;
  677. X    cx2 = (x1 + 3 * x2) / 4;  cy2 = (y1 + 3 * y2) / 4;
  678. X    for (p = p->next; p != NULL; p = p->next) {
  679. X    fprintf(tfp, "\\%s(%.3f,%.3f)", LnCmd, cx1, cy1);
  680. X    x1 = x2;  y1 = y2;
  681. X    convertCS(p);
  682. X    x2 = p->x;  y2 = p->y;
  683. X    cx3 = (3 * x1 + x2) / 4;  cy3 = (3 * y1 + y2) / 4;
  684. X    cx4 = (x1 + x2) / 2;      cy4 = (y1 + y2) / 2;
  685. X    quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
  686. X    fprintf(tfp, "\n");
  687. X    cx1 = cx4;  cy1 = cy4;
  688. X    cx2 = (x1 + 3 * x2) / 4;  cy2 = (y1 + 3 * y2) / 4;
  689. X    }
  690. X    x1 = x2;  y1 = y2;
  691. X    p = spl->points->next;
  692. X    x2 = p->x;  y2 = p->y;
  693. X    cx3 = (3 * x1 + x2) / 4;  cy3 = (3 * y1 + y2) / 4;
  694. X    cx4 = (x1 + x2) / 2;      cy4 = (y1 + y2) / 2;
  695. X    fprintf(tfp, "\\%s(%.3f,%.3f)", LnCmd, cx1, cy1);
  696. X    quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
  697. X    fprintf(tfp, "\n");
  698. X}
  699. X
  700. Xchaikin_curve(a1, b1, a2, b2, a3, b3)
  701. Xdouble a1, b1, a2, b2, a3, b3;
  702. X{
  703. X    double xm1, xmid, xm2, ym1, ymid, ym2;
  704. X
  705. X    if (fabs(a1-a3) < Threshold && fabs(b1-b3) < Threshold) {
  706. X        fprintf(tfp, "\t(%.3f,%.3f)\n", a3, b3);
  707. X    } else {
  708. X        xm1 = (a1 + a2) / 2;
  709. X        ym1 = (b1 + b2) / 2;
  710. X        xm2 = (a2 + a3) / 2;
  711. X        ym2 = (b2 + b3) / 2;
  712. X        xmid = (xm1 + xm2) / 2;
  713. X        ymid = (ym1 + ym2) / 2;
  714. X        chaikin_curve(a1, b1, xm1, ym1, xmid, ymid);
  715. X        chaikin_curve(xmid, ymid, xm2, ym2, a3, b3);
  716. X    }
  717. X}
  718. X
  719. Xstatic quadratic_spline(a1, b1, a2, b2, a3, b3, a4, b4)
  720. Xdouble    a1, b1, a2, b2, a3, b3, a4, b4;
  721. X{
  722. X    double    x1, y1, x4, y4;
  723. X    double    xmid, ymid;
  724. X
  725. X    x1 = a1; y1 = b1;
  726. X    x4 = a4; y4 = b4;
  727. X
  728. X    xmid = (a2 + a3) / 2;
  729. X    ymid = (b2 + b3) / 2;
  730. X    if (fabs(x1 - xmid) < Threshold && fabs(y1 - ymid) < Threshold) {
  731. X    fprintf(tfp, "\t(%.3f,%.3f)\n", xmid, ymid);
  732. X    } else {
  733. X    quadratic_spline(x1, y1, ((x1+a2)/2), ((y1+b2)/2),
  734. X             ((3*a2+a3)/4), ((3*b2+b3)/4), xmid, ymid);
  735. X    }
  736. X
  737. X    if (fabs(xmid - x4) < Threshold && fabs(ymid - y4) < Threshold) {
  738. X    fprintf(tfp, "\t(%.3f,%.3f)\n", x4, y4);
  739. X    } else {
  740. X    quadratic_spline(xmid, ymid, ((a2+3*a3)/4), ((b2+3*b3)/4),
  741. X             ((a3+x4)/2), ((b3+y4)/2), x4, y4);
  742. X    }
  743. X}
  744. X
  745. Xgenepic_itp_spline(spl)
  746. XF_spline *spl;
  747. X{
  748. X    F_point *p1, *p2;
  749. X    FPoint pt1l, pt1r, pt2l, pt2r, tmpfpt;
  750. X    F_control *cp1, *cp2;
  751. X
  752. X    p1 = spl->points;
  753. X    convertCS(p1);
  754. X    cp1 = spl->controls;
  755. X    pt1l.x = cp1->lx;
  756. X    pt1l.y = cp1->ly;
  757. X    pt1r.x = cp1->rx;
  758. X    pt1r.y = cp1->ry;
  759. X    fconvertCS(&pt1l);
  760. X    fconvertCS(&pt1r);
  761. X
  762. X    if (spl->back_arrow) {
  763. X    tmpfpt.x = p1->x;
  764. X    tmpfpt.y = p1->y;
  765. X    fdraw_arrow_head(&pt1r, &tmpfpt, 
  766. X        spl->back_arrow->ht, spl->back_arrow->wid);
  767. X        if (Verbose) fprintf(tfp, "%%\n");
  768. X    }
  769. X
  770. X    for (p2 = p1->next, cp2 = cp1->next; p2 != NULL;
  771. X     p1 = p2, pt1r = pt2r, p2 = p2->next, cp2 = cp2->next) {
  772. X    fprintf(tfp, "\\%s(%d,%d)", LnCmd, p1->x, p1->y);
  773. X    convertCS(p2);
  774. X    pt2l.x = cp2->lx;
  775. X    pt2l.y = cp2->ly;
  776. X    pt2r.x = cp2->rx;
  777. X    pt2r.y = cp2->ry;
  778. X    fconvertCS(&pt2l);
  779. X    fconvertCS(&pt2r);
  780. X    bezier_spline((double) p1->x, (double) p1->y,
  781. X              pt1r.x, pt1r.y,
  782. X              pt2l.x, pt2l.y,
  783. X              (double) p2->x, (double) p2->y);
  784. X    fprintf(tfp, "\n");
  785. X    }
  786. X
  787. X    if (spl->for_arrow) {
  788. X    tmpfpt.x = p1->x;
  789. X    tmpfpt.y = p1->y;
  790. X    fdraw_arrow_head(&pt2l, &tmpfpt, 
  791. X             spl->for_arrow->ht, spl->for_arrow->wid);
  792. X    if (Verbose) fprintf(tfp, "%%\n");
  793. X    }
  794. X}
  795. X
  796. Xstatic bezier_spline(a0, b0, a1, b1, a2, b2, a3, b3)
  797. Xdouble    a0, b0, a1, b1, a2, b2, a3, b3;
  798. X{
  799. X    double    x0, y0, x3, y3;
  800. X    double    sx1, sy1, sx2, sy2, tx, ty, tx1, ty1, tx2, ty2, xmid, ymid;
  801. X
  802. X    x0 = a0; y0 = b0;
  803. X    x3 = a3; y3 = b3;
  804. X    if (fabs(x0 - x3) < Threshold && fabs(y0 - y3) < Threshold) {
  805. X    fprintf(tfp, "\t(%.3f,%.3f)\n", x3, y3);
  806. X    } else {
  807. X    tx = (a1 + a2) / 2;        ty = (b1 + b2) / 2;
  808. X    sx1 = (x0 + a1) / 2;    sy1 = (y0 + b1) / 2;
  809. X    sx2 = (sx1 + tx) / 2;    sy2 = (sy1 + ty) / 2;
  810. X    tx2 = (a2 + x3) / 2;    ty2 = (b2 + y3) / 2;
  811. X    tx1 = (tx2 + tx) / 2;    ty1 = (ty2 + ty) / 2;
  812. X    xmid = (sx2 + tx1) / 2;    ymid = (sy2 + ty1) / 2;
  813. X
  814. X    bezier_spline(x0, y0, sx1, sy1, sx2, sy2, xmid, ymid);
  815. X    bezier_spline(xmid, ymid, tx1, ty1, tx2, ty2, x3, y3);
  816. X    }
  817. X}
  818. X
  819. Xvoid genepic_ellipse(ell)
  820. XF_ellipse *ell;
  821. X{
  822. X    F_point pt;
  823. X
  824. X    set_linewidth(ell->thickness);
  825. X    pt.x = ell->center.x;
  826. X    pt.y = ell->center.y;
  827. X    convertCS(&pt);
  828. X    if (TeXLang == EEpic || TeXLang == EEpic_emu ||
  829. X      ell->radiuses.x != ell->radiuses.y ||
  830. X          ell->radiuses.x > MaxCircleRadius) {
  831. X    set_pattern(ell->area_fill);
  832. X        fprintf(tfp, "\\put(%d,%d){", pt.x, pt.y );
  833. X#ifndef OLDCODE
  834. X        if (EllipseCmd == 0) {
  835. X        if (ell->area_fill < UNFILLED) ell->area_fill = UNFILLED;
  836. X        fprintf(tfp, "%s", FillCommands[(int) ell->area_fill]);
  837. X#  ifdef DrawOutLine
  838. X        if (ell->area_fill != UNFILLED && OutLine == 0) OutLine = 1;
  839. X#  endif
  840. X        }
  841. X     fprintf(tfp, EllCmdstr[EllipseCmd],EllCmdkw[EllipseCmd], "",
  842. X           2 * ell->radiuses.x, 2 * ell->radiuses.y);
  843. X#  ifdef DrawOutLine
  844. X    if (OutLine == 1) {
  845. X        OutLine=0;
  846. X            fprintf(tfp, "\\put(%d,%d){", pt.x, pt.y );
  847. X        fprintf(tfp, EllCmdstr[EllipseCmd],EllCmdkw[EllipseCmd], "",
  848. X           2 * ell->radiuses.x, 2 * ell->radiuses.y);
  849. X    }
  850. X#  endif
  851. X#else
  852. X    fprintf(tfp, EllCmdstr[EllipseCmd], EllCmdkw[EllipseCmd],
  853. X           (EllipseCmd==0 && ell->area_fill==BLACK_FILL ? "*" : ""),
  854. X           2 * ell->radiuses.x, 2 * ell->radiuses.y);
  855. X#endif
  856. X    } else {
  857. X        fprintf(tfp, "\\put(%d,%d){\\circle", pt.x, pt.y);
  858. X        if (ell->area_fill == BLACK_FILL) {
  859. X            fputc('*', tfp);
  860. X        }
  861. X        fprintf(tfp, "{%d}}\n", 2*ell->radiuses.x);
  862. X    }
  863. X}
  864. X
  865. Xvoid genepic_text(text)
  866. XF_text *text;
  867. X{
  868. X    F_point pt;
  869. X    char *tpos, *cp, *esc_cp, *special_index;
  870. X
  871. X    pt.x=text->base_x;
  872. X    pt.y=text->base_y;
  873. X    convertCS(&pt);
  874. X    switch (text->type) {
  875. X    case T_LEFT_JUSTIFIED:
  876. X    case DEFAULT:
  877. X    tpos = "[lb]";
  878. X    break;
  879. X    case T_CENTER_JUSTIFIED:
  880. X    tpos = "[b]";
  881. X    break;
  882. X    case T_RIGHT_JUSTIFIED:
  883. X    tpos = "[rb]";
  884. X    break;
  885. X    default:
  886. X    fprintf(stderr, "unknown text position type\n");
  887. X    exit(1);
  888. X    }
  889. X    fprintf(tfp, "\\put(%d,%d){\\makebox(0,0)%s{\\raisebox{0pt}[0pt][0pt]{",
  890. X           pt.x, pt.y, tpos);
  891. X    /* Output a shortstack in case there are multiple lines. */
  892. X    fprintf(tfp, "\\shortstack" );
  893. X    /* Output the justification for the shortstack. */
  894. X    switch (text->type) {
  895. X    case T_LEFT_JUSTIFIED:
  896. X    case DEFAULT:
  897. X    fprintf(tfp, "[l]");
  898. X    break;
  899. X    case T_CENTER_JUSTIFIED:
  900. X    break;
  901. X    case T_RIGHT_JUSTIFIED:
  902. X    fprintf(tfp, "[r]");
  903. X    break;
  904. X    default:
  905. X    fprintf(stderr, "unknown text position type\n");
  906. X    exit(1);
  907. X    }
  908. X    fprintf(tfp, "{{\\%s%s ", TEXFONTSIZE(text->size), TEXFONT(text->font));
  909. X    if (text->font && text->font != DEFAULT_FONT)
  910. X    /* This loop escapes special LaTeX characters. */
  911. X    for(cp = text->cstring; *cp; cp++) {
  912. X              if (special_index=strchr(latex_text_specials, *cp)) {
  913. X          /* Write out the replacement.  Implementation note: we can't
  914. X         use puts since that will output an additional newline. */
  915. X          esc_cp=latex_text_mappings[special_index-latex_text_specials];
  916. X          while (*esc_cp)
  917. X        fputc(*esc_cp++, tfp);
  918. X        }
  919. X        else if (*cp == TEXT_LINE_SEP) {
  920. X          /* Handle multi-line text strings. The problem being addressed here
  921. X         is a LaTeX bug where LaTeX is unable to handle a font which
  922. X         spans multiple lines.  What we are doing here is closing off
  923. X         the current font, starting a new line, and then resuming with
  924. X         the current font. */
  925. X          fprintf(tfp, "} \\\\\n");
  926. X          fprintf(tfp, "{\\%s%s ", TEXFONTSIZE(text->size), TEXFONT(text->font));
  927. X        }
  928. X        else
  929. X        fputc(*cp, tfp);
  930. X          }
  931. X    else 
  932. X    for(cp = text->cstring; *cp; cp++) {
  933. X      if (*cp == TEXT_LINE_SEP) {
  934. X          /* Handle multi-line text strings. */
  935. X          fprintf(tfp, "} \\\\\n");
  936. X          fprintf(tfp, "{\\%s%s ", TEXFONTSIZE(text->size), TEXFONT(text->font));
  937. X        }
  938. X        else 
  939. X          fputc(*cp, tfp);
  940. X      }
  941. X    fprintf(tfp, "}}}}}\n");
  942. X}
  943. X
  944. Xvoid genepic_arc(arc)
  945. XF_arc *arc;
  946. X{
  947. X    FPoint pt1, pt2, ctr, tmp;
  948. X    double r1, r2, th1, th2, theta;
  949. X    double dx1, dy1, dx2, dy2;
  950. X    double arrowfactor;
  951. X
  952. X    ctr.x = arc->center.x;
  953. X    ctr.y = arc->center.y;
  954. X    pt1.x = arc->point[0].x;
  955. X    pt1.y = arc->point[0].y;
  956. X    pt2.x = arc->point[2].x;
  957. X    pt2.y = arc->point[2].y;
  958. X    fconvertCS(&ctr);
  959. X    fconvertCS(&pt1);
  960. X    fconvertCS(&pt2);
  961. X
  962. X    dx1 = pt1.x - ctr.x;
  963. X    dy1 = pt1.y - ctr.y;
  964. X    dx2 = pt2.x - ctr.x;
  965. X    dy2 = pt2.y - ctr.y;
  966. X
  967. X    rtop(dx1, dy1, &r1, &th1);
  968. X    rtop(dx2, dy2, &r2, &th2);
  969. X    arrowfactor = (r1+r2) / 30.0;
  970. X    if (arrowfactor > 1) arrowfactor = 1;
  971. X    set_linewidth(arc->thickness);
  972. X    if (arc->for_arrow) {
  973. X    arc_tangent(&ctr, &pt2, arc->direction, &tmp);
  974. X    fdraw_arrow_head(&tmp, &pt2,
  975. X             arc->for_arrow->ht*arrowfactor,
  976. X             arc->for_arrow->wid*arrowfactor);
  977. X        if (Verbose) fprintf(tfp, "%%\n");
  978. X    }
  979. X    if (arc->back_arrow) {
  980. X    arc_tangent(&ctr, &pt1, !arc->direction, &tmp);
  981. X    fdraw_arrow_head(&tmp, &pt1,
  982. X             arc->back_arrow->ht*arrowfactor,
  983. X             arc->back_arrow->wid*arrowfactor);
  984. X        if (Verbose) fprintf(tfp, "%%\n");
  985. X    }
  986. X    if (TeXLang == EEpic) {
  987. X    set_pattern(arc->area_fill);
  988. X        fprintf(tfp, "\\put(%4.3lf,%4.3lf){", ctr.x, ctr.y);
  989. X    } else {
  990. X    fprintf(tfp, "\\drawline");
  991. X    }
  992. X    if (TeXLang == EEpic) {
  993. X    if (arc->area_fill < UNFILLED) arc->area_fill = UNFILLED;
  994. X    fprintf(tfp, "%s", FillCommands[(int) arc->area_fill]);
  995. X#ifdef DrawOutLine
  996. X    if (arc->area_fill != UNFILLED && OutLine==0) OutLine=1;
  997. X#endif
  998. X    }
  999. X    if (arc->direction) {
  1000. X    theta = th2 - th1;
  1001. X    if (theta < 0) theta += 2 * M_PI;
  1002. X    th2 = 2*M_PI-th2;
  1003. X    if (TeXLang == EEpic) {
  1004. X        fprintf(tfp, "\\arc{%4.3f}{%2.4f}{%2.4f}}\n", 2*r1, th2, th2+theta);
  1005. X#ifdef DrawOutLine
  1006. X        if (OutLine==1) {
  1007. X        OutLine=0;
  1008. X            fprintf(tfp, "\\put(%4.3lf,%4.3lf){", ctr.x, ctr.y);
  1009. X        fprintf(tfp, "\\arc{%4.3f}{%2.4f}{%2.4f}}\n", 2*r1, th2, th2+theta);
  1010. X        }
  1011. X#endif
  1012. X        } else {
  1013. X            drawarc(&ctr, r1, 2*M_PI - th2 - theta, theta);
  1014. X        }
  1015. X    } else {
  1016. X    theta = th1 - th2;
  1017. X    if (theta < 0) theta += 2 * M_PI;
  1018. X    th1 = 2*M_PI-th1;
  1019. X    if (TeXLang == EEpic) {
  1020. X        fprintf(tfp, "\\arc{%4.3f}{%2.4f}{%2.4f}}\n", 2*r2, th1, th1+theta);
  1021. X#ifdef DrawOutLine
  1022. X        if (OutLine==1) {
  1023. X        OutLine=0;
  1024. X        fprintf(tfp, "\\arc{%4.3f}{%2.4f}{%2.4f}}\n", 2*r2, th1, th1+theta);
  1025. X        }
  1026. X#endif
  1027. X        } else {
  1028. X            drawarc(&ctr, r2, 2*M_PI - th1 - theta, theta);
  1029. X        }
  1030. X    }
  1031. X}
  1032. X
  1033. Xdrawarc(ctr, r, th1, angle)
  1034. XFPoint *ctr;
  1035. Xdouble r, th1, angle;
  1036. X{
  1037. X    double arclength, delta;
  1038. X    int division, pt_count = 0;
  1039. X
  1040. X
  1041. X    division = angle * r / Threshold;
  1042. X    delta = angle / division;
  1043. X    division++;
  1044. X    while (division-- > 0) {
  1045. X        if (++pt_count > PtPerLine) {
  1046. X            fprintf(tfp, "\n\t");
  1047. X            pt_count = 1;
  1048. X        }
  1049. X        fprintf(tfp, "(%.3lf,%.3lf)", ctr->x + cos(th1) * r,
  1050. X                                ctr->y + sin(th1) * r);
  1051. X        th1 += delta;
  1052. X    }
  1053. X    fprintf(tfp, "\n");
  1054. X}
  1055. X
  1056. Xstatic arc_tangent(pt1, pt2, direction, pt3)
  1057. XFPoint *pt1, *pt2, *pt3;
  1058. Xint direction;
  1059. X{
  1060. X    if (direction) {
  1061. X    pt3->x = pt2->x + (pt2->y - pt1->y);
  1062. X    pt3->y = pt2->y - (pt2->x - pt1->x);
  1063. X    } else {
  1064. X    pt3->x = pt2->x - (pt2->y - pt1->y);
  1065. X    pt3->y = pt2->y + (pt2->x - pt1->x);
  1066. X    }
  1067. X}
  1068. X
  1069. Xrtop(x, y, r, th)
  1070. Xdouble x, y, *r, *th;
  1071. X{
  1072. X    *r = hypot(x,y);
  1073. X    *th = acos(x/(*r));
  1074. X    if (*th < 0) *th = M_PI + *th;
  1075. X    if (y < 0) *th = 2*M_PI - *th;
  1076. X}
  1077. X
  1078. Xstatic draw_arrow_head(pt1, pt2, arrowht, arrowwid)
  1079. XF_point *pt1, *pt2;
  1080. Xdouble arrowht, arrowwid;
  1081. X{
  1082. X    FPoint fpt1, fpt2;
  1083. X
  1084. X    fpt1.x = pt1->x;
  1085. X    fpt1.y = pt1->y;
  1086. X    fpt2.x = pt2->x;
  1087. X    fpt2.y = pt2->y;
  1088. X    fdraw_arrow_head(&fpt1, &fpt2, arrowht, arrowwid);
  1089. X}
  1090. X
  1091. Xfdraw_arrow_head(pt1, pt2, arrowht, arrowwid)
  1092. XFPoint *pt1, *pt2;
  1093. Xdouble arrowht, arrowwid;
  1094. X{
  1095. X    double x1, y1, x2, y2;
  1096. X    double x,y, xb,yb,dx,dy,l,sina,cosa;
  1097. X    double xc, yc, xd, yd;
  1098. X
  1099. X    x1 = pt1->x;
  1100. X    y1 = pt1->y;
  1101. X    x2 = pt2->x;
  1102. X    y2 = pt2->y;
  1103. X
  1104. X    if (Verbose) fprintf(tfp, "%%\n%% arrow head\n%%\n");
  1105. X
  1106. X    dx = x2 - x1;  dy = y1 - y2;
  1107. X    l = hypot(dx,dy);
  1108. X    sina = dy / l;  cosa = dx / l;
  1109. X    xb = x2*cosa - y2*sina;
  1110. X    yb = x2*sina + y2*cosa;
  1111. X    x = xb - arrowht;
  1112. X    y = yb - arrowwid / 2;
  1113. X    xc = x*cosa + y*sina;
  1114. X    yc = -x*sina + y*cosa;
  1115. X    y = yb + arrowwid / 2;
  1116. X    xd = x*cosa + y*sina;
  1117. X    yd = -x*sina + y*cosa;
  1118. X
  1119. X    fprintf(tfp, "\\%s(%4.3f,%4.3f)(%4.3f,%4.3f)(%4.3f,%4.3f)\n", LnCmd,
  1120. X        xc, yc, x2, y2, xd, yd);
  1121. X}
  1122. X
  1123. X#ifndef MSDOS
  1124. Xstricmp(s, t)
  1125. Xchar *s, *t;
  1126. X{
  1127. X    char a, b;
  1128. X
  1129. X    for (;;) {
  1130. X        a= *s++; b= *t++;
  1131. X        a = islower(a) ? toupper(a) : a;
  1132. X        b = islower(b) ? toupper(b) : b;
  1133. X        if (a != b) break;
  1134. X        if (a == '\0') return(0);
  1135. X    }
  1136. X    return(a - b);
  1137. X}
  1138. X#endif
  1139. X
  1140. Xstruct driver dev_epic = {
  1141. X         genepic_option,
  1142. X    genepic_start,
  1143. X    genepic_arc,
  1144. X    genepic_ellipse,
  1145. X    genepic_line,
  1146. X    genepic_spline,
  1147. X    genepic_text,
  1148. X    genepic_end,
  1149. X    INCLUDE_TEXT
  1150. X};
  1151. END_OF_FILE
  1152. if test 28053 -ne `wc -c <'transfig/fig2dev/dev/genepic.c'`; then
  1153.     echo shar: \"'transfig/fig2dev/dev/genepic.c'\" unpacked with wrong size!
  1154. fi
  1155. # end of 'transfig/fig2dev/dev/genepic.c'
  1156. fi
  1157. echo shar: End of archive 5 \(of 6\).
  1158. cp /dev/null ark5isdone
  1159. MISSING=""
  1160. for I in 1 2 3 4 5 6 ; do
  1161.     if test ! -f ark${I}isdone ; then
  1162.     MISSING="${MISSING} ${I}"
  1163.     fi
  1164. done
  1165. if test "${MISSING}" = "" ; then
  1166.     echo You have unpacked all 6 archives.
  1167.     rm -f ark[1-9]isdone
  1168. else
  1169.     echo You still need to unpack the following archives:
  1170.     echo "        " ${MISSING}
  1171. fi
  1172. ##  End of shell archive.
  1173. exit 0
  1174.