1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256
|
/* Hello, Emacs, this is -*-C-*- */
/* GNUPLOT - metapost.trm */
/*[
* Copyright 1990 - 1993, 1998, 2004
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose with or without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted, but not the right to
* distribute the complete modified source code. Modifications are to
* be distributed as patches to the released version. Permission to
* distribute binaries produced by compiling modified sources is granted,
* provided you
* 1. distribute the corresponding source modifications from the
* released version in the form of a patch file along with the binaries,
* 2. add special version identification to distinguish your version
* in addition to the base release version number,
* 3. provide your name and address as the primary contact for the
* support of your modified version, and
* 4. retain our contact information in regard to use of the base
* software.
* Permission to distribute the released version of the source code along
* with corresponding source modifications in the form of a patch file is
* granted with same provisions 2 through 4 for binary distributions.
*
* This software is provided "as is" without express or implied warranty
* to the extent permitted by applicable law.
]*/
/* 1999/04/22
* GNUPLOT -- metapost.trm
*
* This terminal driver supports:
* Metapost Commands
*
* Based on metafont.trm, written by
* Pl Hedne
* Trondheim, Norway
* Pal.Hedne@termo.unit.no;
* with improvements by Carsten Steger
*
* and pstricks.trm, written by
* David Kotz and Raymond Toy
*
* Adapted to metapost by:
* Daniel H. Luecking <luecking@comp.uark.edu> and
* L Srinivasa Mohan <mohan@chemeng.iisc.ernet.in>
*/
#include "driver.h"
#ifdef TERM_REGISTER
register_term(mp)
#endif
#ifdef TERM_PROTO
TERM_PUBLIC void MP_options(void);
TERM_PUBLIC void MP_init(void);
TERM_PUBLIC void MP_graphics(void);
TERM_PUBLIC void MP_text(void);
TERM_PUBLIC void MP_linetype(int linetype);
TERM_PUBLIC void MP_move(unsigned int x, unsigned int y);
TERM_PUBLIC void MP_point(unsigned int x, unsigned int y, int number);
TERM_PUBLIC void MP_pointsize(double size);
TERM_PUBLIC void MP_linewidth(double width);
TERM_PUBLIC void MP_vector(unsigned int ux, unsigned int uy);
TERM_PUBLIC void MP_arrow(unsigned int sx, unsigned int sy,
unsigned int ex, unsigned int ey,
int head);
TERM_PUBLIC void MP_put_text(unsigned int x, unsigned int y, const char str[]);
TERM_PUBLIC int MP_justify_text(enum JUSTIFY mode);
TERM_PUBLIC int MP_text_angle(float ang);
TERM_PUBLIC void MP_reset(void);
TERM_PUBLIC int MP_set_font(const char *font);
TERM_PUBLIC void MP_boxfill(int style, unsigned int x1,
unsigned int y1, unsigned int width,
unsigned int height);
TERM_PUBLIC int MP_make_palette(t_sm_palette *);
TERM_PUBLIC void MP_previous_palette(void);
TERM_PUBLIC void MP_set_color(t_colorspec *);
TERM_PUBLIC void MP_filled_polygon(int, gpiPoint *);
TERM_PUBLIC void MP_dashtype(int type, t_dashtype *custom_dash_type);
/* 5 inches wide by 3 inches high (default) */
#define MP_XSIZE 5.0
#define MP_YSIZE 3.0
/* gnuplot units will be one pixel if printing device has this
resolution. Too small resolutions (like 300) can give rough
appearance to curves when user tries to smooth a curve by choosing
high sampling rate. */
#define MP_DPI (2400)
#define MP_XMAX (MP_XSIZE*MP_DPI)
#define MP_YMAX (MP_YSIZE*MP_DPI)
#define MP_HTIC (5*MP_DPI/72) /* nominally 5pt */
#define MP_VTIC (5*MP_DPI/72) /* " 5pt */
#define MP_HCHAR (MP_DPI*53/10/72) /* " 5.3pt */
#define MP_VCHAR (MP_DPI*11/72) /* " 11pt */
#endif /* TERM_PROTO */
#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY
static double MP_xsize = MP_XSIZE;
static double MP_ysize = MP_YSIZE;
/* static double MP_xmax = MP_XMAX;
static double MP_ymax = MP_YMAX;
* unused, for now
*/
static int MP_posx;
static int MP_posy;
static char MP_fontname[MAX_ID_LEN + 1];
static double MP_fontsize;
static double MP_textmag;
static enum JUSTIFY MP_justify = LEFT;
static int MP_ang = 0;
static int MP_char_code = 0;
/* number of nodes in an output line so far */
static int MP_linecount = 1;
/* Number of point types */
#define MP_POINT_TYPES 10
/* Number of line types */
#define MP_LINE_TYPES 8
/* are we in the middle of a MP path? */
static TBOOLEAN MP_inline = FALSE;
static TBOOLEAN MP_inpath = FALSE;
/* colored or dashed lines? */
static TBOOLEAN MP_color = FALSE;
static TBOOLEAN MP_solid = FALSE;
/* compatibility mode*/
/* static TBOOLEAN MP_notex = FALSE; */
#define MP_NO_TEX 0
#define MP_TEX 1
#define MP_LATEX 2
static int MP_tex = MP_TEX;
/* add usepackage instructions for PSNFSS ? */
#define MP_PSNFSS_NONE 0
#define MP_PSNFSS_7 1
#define MP_PSNFSS_8 2
static int MP_psnfss = MP_PSNFSS_NONE;
/* should amstex packages be included? */
static int MP_amstex = 0;
/* add a4paper option to documentclass */
static int MP_a4paper = 0;
/* write a prologues line */
static int MP_prologues = -1;
/* has color changed? */
static int MP_color_changed = 0;
static int MP_dash_changed = 0;
/* has a font change taken place? */
static TBOOLEAN MP_fontchanged = FALSE;
/* The old types */
static int MP_oldline = -2;
/* The old sizes */
static double MP_oldptsize = 1.0;
static double MP_oldpen = 1.0;
/* terminate any path in progress */
static void MP_endline(void);
/* max number of path nodes before a newline */
#define MP_LINEMAX 5
enum MP_id {
MP_OPT_MONOCHROME, MP_OPT_COLOUR,
MP_OPT_SOLID, MP_OPT_DASHED,
MP_OPT_NOTEX, MP_OPT_TEX, MP_OPT_LATEX,
MP_OPT_A4PAPER,
MP_OPT_PSNFSS, MP_OPT_PSNFSS_V7, MP_OPT_NOPSNFSS,
MP_OPT_AMSTEX,
MP_OPT_FONT, MP_OPT_FONTSIZE,
MP_OPT_PROLOGUES, MP_OPT_NOPROLOGUES,
MP_OPT_MAGNIFICATION, MP_OPT_OTHER
};
static struct gen_table MP_opts[] = {
{ "mo$nochrome", MP_OPT_MONOCHROME },
{ "c$olor", MP_OPT_COLOUR },
{ "c$olour", MP_OPT_COLOUR },
{ "s$olid", MP_OPT_SOLID },
{ "da$shed", MP_OPT_DASHED },
{ "n$otex", MP_OPT_NOTEX },
{ "t$ex", MP_OPT_TEX },
{ "la$tex", MP_OPT_LATEX },
{ "a4$paper", MP_OPT_A4PAPER },
{ "am$stex", MP_OPT_AMSTEX },
{ "ps$nfss", MP_OPT_PSNFSS },
{ "psnfss-v$ersion7", MP_OPT_PSNFSS_V7 },
{ "nops$nfss", MP_OPT_NOPSNFSS },
{ "pro$logues", MP_OPT_PROLOGUES },
{ "nopro$logues", MP_OPT_NOPROLOGUES },
{ "ma$gnification", MP_OPT_MAGNIFICATION },
{ "fo$nt", MP_OPT_FONT },
{ NULL, MP_OPT_OTHER }
};
TERM_PUBLIC void
MP_options()
{
/* Annoying hack to handle the case of 'set termoption' after */
/* we have already initialized the terminal. */
if (!almost_equals(c_token-1, "termopt$ion")) {
MP_color = FALSE;
MP_solid = FALSE;
MP_tex = MP_TEX;
MP_a4paper = 0;
MP_amstex = 0;
MP_psnfss = MP_PSNFSS_NONE;
MP_fontsize = 10.0;
MP_textmag = 1.0;
MP_prologues = -1;
strcpy(MP_fontname, "cmr10");
term->flags |= TERM_IS_LATEX;
}
while (!END_OF_COMMAND) {
int option = lookup_table(&MP_opts[0], c_token);
switch (option) {
case MP_OPT_MONOCHROME:
MP_color = FALSE;
c_token++;
break;
case MP_OPT_COLOUR:
MP_color = TRUE;
c_token++;
break;
case MP_OPT_SOLID:
MP_solid = TRUE;
c_token++;
break;
case MP_OPT_DASHED:
MP_solid = FALSE;
c_token++;
break;
case MP_OPT_NOTEX:
MP_tex = MP_NO_TEX;
strcpy(MP_fontname, "pcrr8r");
term->flags &= ~TERM_IS_LATEX;
c_token++;
break;
case MP_OPT_TEX:
MP_tex = MP_TEX;
c_token++;
break;
case MP_OPT_LATEX:
MP_tex = MP_LATEX;
c_token++;
break;
case MP_OPT_AMSTEX:
MP_tex = MP_LATEX; /* only makes sense when using LaTeX */
MP_amstex = 1;
c_token++;
break;
case MP_OPT_A4PAPER:
MP_tex = MP_LATEX; /* only makes sense when using LaTeX */
MP_a4paper = 1;
c_token++;
break;
case MP_OPT_PSNFSS:
MP_tex = MP_LATEX; /* only makes sense when using LaTeX */
MP_psnfss = MP_PSNFSS_8;
c_token++;
break;
case MP_OPT_PSNFSS_V7:
MP_tex = MP_LATEX; /* only makes sense when using LaTeX */
MP_psnfss = MP_PSNFSS_7;
c_token++;
break;
case MP_OPT_NOPSNFSS:
MP_psnfss = MP_PSNFSS_NONE;
c_token++;
break;
case MP_OPT_PROLOGUES:
c_token++;
if (!(END_OF_COMMAND)) {
int dummy_for_prologues;
if (sscanf(gp_input_line + token[c_token].start_index,
"%d", &dummy_for_prologues) == 1) {
MP_prologues = dummy_for_prologues;
}
c_token++;
}
break;
case MP_OPT_NOPROLOGUES:
MP_prologues = -1;
c_token++;
break;
case MP_OPT_MAGNIFICATION:
c_token++;
if (!END_OF_COMMAND) /* global text scaling */
MP_textmag = real_expression();
break;
case MP_OPT_FONT:
c_token++;
case MP_OPT_OTHER:
default:
{
char *s;
if ((s = try_to_get_string())) {
int sep = strcspn(s,",");
if (0 < sep && sep < sizeof(MP_fontname)) {
strncpy(MP_fontname, s, sizeof(MP_fontname));
MP_fontname[sep] = '\0';
}
if (s[sep] == ',')
sscanf(&s[sep+1],"%lf",&MP_fontsize);
free(s);
} else if (option == MP_OPT_FONT) {
int_error(c_token,"expecting font name");
} else if (!END_OF_COMMAND) { /*font size */
MP_fontsize = real_expression();
c_token++;
}
break;
}
}
}
/* minimal error recovery: */
if (MP_fontsize < 5.0)
MP_fontsize = 5.0;
if (MP_fontsize > 99.99)
MP_fontsize = 99.99;
term->v_char = (unsigned int) (MP_DPI * MP_fontsize * MP_textmag * 11 / 720);
if (MP_tex == MP_NO_TEX) { /* Courier is a little wider than cmtt */
term->h_char = (unsigned int) (MP_DPI * MP_fontsize * MP_textmag * 6.0 / 720 + 0.5);
} else {
term->h_char = (unsigned int) (MP_DPI * MP_fontsize * MP_textmag * 5.3 / 720 + 0.5);
}
if (MP_psnfss == MP_PSNFSS_NONE) { /* using the normal font scheme */
sprintf(term_options,
"%s %s %stex%s%s mag %.3f font \"%s,%.2f\" %sprologues(%d)",
MP_color ? "color" : "monochrome",
MP_solid ? "solid" : "dashed",
(MP_tex == MP_NO_TEX) ? "no" : (MP_tex == MP_LATEX) ? "la" : "",
MP_a4paper ? " a4paper" : "",
MP_amstex ? " amstex" : "",
MP_textmag,
MP_fontname, MP_fontsize,
(MP_prologues > -1) ? "" : "no", MP_prologues );
} else { /* using postscript fonts */
sprintf(term_options,
"%s %s %stex%s%s mag %.3f %s %sprologues(%d)",
MP_color ? "color" : "monochrome",
MP_solid ? "solid" : "dashed",
(MP_tex == MP_NO_TEX) ? "no" : (MP_tex == MP_LATEX) ? "la" : "",
MP_a4paper ? " a4paper" : "",
MP_amstex ? " amstex" : "",
MP_textmag,
(MP_psnfss == MP_PSNFSS_7) ? "psnsfss(v7)" : "psnsfss",
(MP_prologues > -1) ? "" : "no", MP_prologues );
};
}
TERM_PUBLIC void
MP_init()
{
time_t now;
time(&now);
MP_posx = MP_posy = 0;
fprintf(gpoutfile, "%%GNUPLOT Metapost output: %s\n", asctime(localtime(&now)));
if (MP_prologues > -1) {
fprintf(gpoutfile, "prologues:=%d;\n", MP_prologues);
}
if (MP_tex == MP_LATEX) {
fputs("\n\
%% Add \\documentclass and \\begin{dcoument} for latex\n\
%% NB you should set the environment variable TEX to the name of your\n\
%% latex executable (normally latex) inorder for metapost to work\n\
%% or run\n\
%% mpost --tex=latex ...\n\
\n\
% BEGPRE\n\
verbatimtex\n", gpoutfile);
if (MP_a4paper) {
fputs("\\documentclass[a4paper]{article}\n", gpoutfile);
} else {
fputs("\\documentclass{article}\n", gpoutfile);
}
switch (MP_psnfss) {
case MP_PSNFSS_7:{
fputs("\\usepackage[latin1]{inputenc}\n\
\\usepackage[T1]{fontenc}\n\
\\usepackage{times,mathptmx}\n\
\\usepackage{helvet}\n\
\\usepackage{courier}\n", gpoutfile);
}
break;
case MP_PSNFSS_8:{
fputs("\\usepackage[latin1]{inputenc}\n\
\\usepackage[T1]{fontenc}\n\
\\usepackage{textcomp}\n\
\\usepackage{mathptmx}\n\
\\usepackage[scaled=.92]{helvet}\n\
\\usepackage{courier}\n\
\\usepackage{latexsym}\n", gpoutfile);
}
break;
}
if (MP_amstex) {
fputs("\\usepackage[intlimits]{amsmath}\n\
\\usepackage{amsfonts}\n", gpoutfile);
};
fputs("\\begin{document}\n\
etex\n% ENDPRE\n", gpoutfile);
}
fputs("\n\
warningcheck:=0;\n\
defaultmpt:=mpt:=4;\n\
th:=.6;\n\
%% Have nice sharp joins on our lines\n\
linecap:=butt;\n\
linejoin:=mitered;\n\
\n\
def scalepen expr n = pickup pencircle scaled (n*th) enddef;\n\
def ptsize expr n = mpt:=n*defaultmpt enddef;\n\
\n", gpoutfile);
fprintf(gpoutfile, "\ntextmag:=%6.3f;\n", MP_textmag);
fputs("\
vardef makepic(expr str) =\n\
if picture str : str scaled textmag\n\
% otherwise a string\n\
else: str infont defaultfont scaled (defaultscale*textmag)\n\
fi\n\
enddef;\n\
\n\
def infontsize(expr str, size) =\n\
infont str scaled (size / fontsize str)\n\
enddef;\n", gpoutfile);
if (MP_tex == MP_NO_TEX) {
fprintf(gpoutfile, "\n\
defaultfont:= \"%s\";\n\
defaultscale := %6.3f/fontsize defaultfont;\n", MP_fontname, MP_fontsize);
} else {
if (MP_tex != MP_LATEX) {
fputs("\n\
%font changes\n\
verbatimtex\n\
\\def\\setfont#1#2{%.\n\
\\font\\gpfont=#1 at #2pt\n\
\\gpfont}\n", gpoutfile);
fprintf(gpoutfile, "\\setfont{%s}{%5.2f}\netex\n",
MP_fontname, MP_fontsize);
}
}
fputs("\n\
color currentcolor; currentcolor:=black;\n\
picture currentdash; currentdash:=dashpattern(on 1);\n\
color fillcolor;\n\
boolean colorlines,dashedlines;\n", gpoutfile);
if (MP_color) {
fputs("colorlines:=true;\n", gpoutfile);
} else {
fputs("colorlines:=false;\n", gpoutfile);
}
if (MP_solid) {
fputs("dashedlines:=false;\n", gpoutfile);
} else {
fputs("dashedlines:=true;\n", gpoutfile);
}
fputs("\n\
def _wc = withpen currentpen withcolor currentcolor dashed currentdash enddef;\n\
def _ac = addto currentpicture enddef;\n\
def _sms = scaled mpt shifted enddef;\n\
% drawing point-types\n\
def gpdraw (expr n, x, y) =\n\
if n<0: _ac contour fullcircle _sms (x,y)\n\
elseif (n=1) or (n=3):\n\
_ac doublepath ptpath[n] _sms (x,y) _wc;\n\
_ac doublepath ptpath[n] rotated 90 _sms (x,y) _wc\n\
elseif n<6: _ac doublepath ptpath[n] _sms (x,y) _wc\n\
else: _ac contour ptpath[n] _sms (x,y) _wc\n\
fi\n\
enddef;\n\
\n\
% the point shapes\n\
path ptpath[];\n\
%diamond\n\
ptpath0 = ptpath6 = (-1/2,0)--(0,-1/2)--(1/2,0)--(0,1/2)--cycle;\n\
% plus sign\n\
ptpath1 = (-1/2,0)--(1/2,0);\n\
% square\n\
ptpath2 = ptpath7 = (-1/2,-1/2)--(1/2,-1/2)--(1/2,1/2)--(-1/2,1/2)--cycle;\n\
% cross\n\
ptpath3 := (-1/2,-1/2)--(1/2,1/2);\n\
% circle:\n\
ptpath4 = ptpath8:= fullcircle;\n\
% triangle\n\
ptpath5 = ptpath9 := (0,1/2)--(-1/2,-1/2)--(1/2,-1/2)--cycle;\n\
\n\
def linetype expr n =\n\
if n > -3 :\n\
currentcolor:= if colorlines : col[n] else: black fi;\n\
fi\n\
currentdash:= if dashedlines : lt[n] else: dashpattern(on 1) fi;\n\
if n = -1 :\n\
drawoptions(withcolor currentcolor withpen (currentpen scaled .5));\n\
else :\n\
drawoptions(_wc);\n\
fi\n\
enddef;\n\
\n\
% dash patterns\n\
picture lt[];\n\
lt[-3]:=dashpattern(off 1 on 0);\n\
lt[-2]:=lt[-1]:=lt0:=dashpattern(on 1);\n\
lt1=dashpattern(on 2 off 2); % dashes\n\
lt2=dashpattern(on 2 off 2 on 0.2 off 2); %dash-dot\n\
lt3=lt1 scaled 1.414;\n\
lt4=lt2 scaled 1.414;\n\
lt5=lt1 scaled 2;\n\
lt6:=lt2 scaled 2;\n\
lt7=dashpattern(on 0.2 off 2); %dots\n\
\n\
color col[],cyan, magenta, yellow;\n\
cyan=blue+green; magenta=red+blue;yellow=green+red;\n\
col[-2]:=col[-1]:=col0:=black;\n\
col1:=red;\n\
col2:=(.2,.2,1); %blue\n\
col3:=(1,.66,0); %orange\n\
col4:=.85*green;\n\
col5:=.9*magenta;\n\
col6:=0.85*cyan;\n\
col7:=.85*yellow;\n\
\n\
%placing text\n\
picture GPtext;\n\
def put_text(expr pic, x, y, r, j) =\n\
GPtext:=makepic(pic);\n\
GPtext:=GPtext shifted\n\
if j = 1: (-(ulcorner GPtext + llcorner GPtext)/2)\n\
elseif j = 2: (-center GPtext)\n\
else: (-(urcorner GPtext + lrcorner GPtext)/2)\n\
fi\n\
rotated r;\n\
addto currentpicture also GPtext shifted (x,y)\n\
enddef;\n", gpoutfile);
}
TERM_PUBLIC void
MP_graphics()
{
/* initialize "remembered" drawing parameters */
MP_oldline = -2;
MP_oldpen = 1.0;
MP_oldptsize = pointsize;
fprintf(gpoutfile, "\nbeginfig(%d);\nw:=%.3fin;h:=%.3fin;\n",
MP_char_code, MP_xsize, MP_ysize);
/* MetaPost can only handle numbers up to 4096. When MP_DPI
* is larger than 819, this is exceeded by (term->xmax). So we
* scale it and all coordinates down by factor of 10.0. And
* compensate by scaling a and b up.
*/
fprintf(gpoutfile, "a:=w/%.1f;b:=h/%.1f;\n",
(term->xmax) / 10.0, (term->ymax) / 10.0);
fprintf(gpoutfile, "scalepen 1; ptsize %.3f;linetype -2;\n", pointsize);
MP_char_code++;
/* reset MP_color_changed */
MP_color_changed = 0;
MP_dash_changed = 0;
}
TERM_PUBLIC void
MP_text()
{
if (MP_inline)
MP_endline();
fputs("endfig;\n", gpoutfile);
}
TERM_PUBLIC void
MP_linetype(int lt)
{
int linetype = lt;
if (linetype >= MP_LINE_TYPES)
linetype %= MP_LINE_TYPES;
if (MP_inline)
MP_endline();
/* reset the color in case it has been changed in MP_set_color() */
if ((MP_color_changed) || (MP_dash_changed)) {
MP_oldline = linetype + 1;
MP_color_changed = 0;
MP_dash_changed = 0;
}
if (MP_oldline != linetype) {
fprintf(gpoutfile, "linetype %d;\n", linetype);
MP_oldline = linetype;
}
}
TERM_PUBLIC void
MP_move(unsigned int x, unsigned int y)
{
if ((x != MP_posx) || (y != MP_posy)) {
if (MP_inline)
MP_endline();
MP_posx = x;
MP_posy = y;
} /* else we seem to be there already */
}
TERM_PUBLIC void
MP_point(unsigned int x, unsigned int y, int pt)
{
int pointtype = pt;
if (MP_inline)
MP_endline();
/* Print the shape defined by 'number'; number < 0 means
to use a dot, otherwise one of the defined points. */
if (pointtype >= MP_POINT_TYPES)
pointtype %= MP_POINT_TYPES;
/* Change %d to %f, divide x,y by 10 */
fprintf(gpoutfile, "gpdraw(%d,%.1fa,%.1fb);\n", pointtype, x / 10.0, y / 10.0);
}
TERM_PUBLIC void
MP_pointsize(double ps)
{
if (ps < 0)
ps = 1;
if (MP_oldptsize != ps) {
if (MP_inline)
MP_endline();
fprintf(gpoutfile, "ptsize %.3f;\n", ps);
MP_oldptsize = ps;
}
}
TERM_PUBLIC void
MP_linewidth(double lw)
{
if (MP_oldpen != lw) {
if (MP_inline)
MP_endline();
fprintf(gpoutfile, "scalepen %.3f;\n", lw);
MP_oldpen = lw;
}
}
TERM_PUBLIC void
MP_vector(unsigned int ux, unsigned int uy)
{
if ((ux == MP_posx) && (uy == MP_posy))
return; /* Zero length line */
if (MP_inline) {
if (MP_linecount++ >= MP_LINEMAX) {
fputs("\n", gpoutfile);
MP_linecount = 1;
}
} else {
MP_inline = TRUE;
fprintf(gpoutfile, "draw (%.1fa,%.1fb)", MP_posx / 10.0, MP_posy / 10.0);
MP_linecount = 2;
}
MP_posx = ux;
MP_posy = uy;
fprintf(gpoutfile, "--(%.1fa,%.1fb)", MP_posx / 10.0, MP_posy / 10.0);
}
static void
MP_endline()
{
MP_inline = FALSE;
fprintf(gpoutfile, ";\n");
}
TERM_PUBLIC void
MP_path(int p)
{
switch (p) {
case 0: /* Start new path */
MP_inpath = TRUE;
break;
case 1: /* Close path */
if (MP_inpath)
fprintf(gpoutfile, "--cycle");
MP_endline();
MP_inpath = FALSE;
break;
}
}
TERM_PUBLIC void
MP_arrow(unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head)
{
MP_move(sx, sy);
if ((head & HEADS_ONLY))
fprintf(gpoutfile, "currentdash:=lt[%d];\n", LT_NODRAW);
if ((head & BOTH_HEADS) == BOTH_HEADS) {
fprintf(gpoutfile, "%s (%.1fa,%.1fb)--(%.1fa,%.1fb);\n",
"drawdblarrow",
sx / 10.0, sy / 10.0, ex / 10.0, ey / 10.0);
} else if ((head & END_HEAD)) {
fprintf(gpoutfile, "%s (%.1fa,%.1fb)--(%.1fa,%.1fb);\n",
"drawarrow",
sx / 10.0, sy / 10.0, ex / 10.0, ey / 10.0);
} else if ((head & BACKHEAD)) {
fprintf(gpoutfile, "%s (%.1fa,%.1fb)--(%.1fa,%.1fb);\n",
"drawarrow",
ex / 10.0, ey / 10.0, sx / 10.0, sy / 10.0);
} else if (!(head & HEADS_ONLY) && ((sx != ex) || (sy != ey))) {
fprintf(gpoutfile, "draw (%.1fa,%.1fb)--(%.1fa,%.1fb);\n",
sx / 10.0, sy / 10.0, ex / 10.0, ey / 10.0);
}
if ((head & HEADS_ONLY))
fprintf(gpoutfile, "currentdash:=lt[%d];\n", MP_oldline);
MP_posx = ex;
MP_posy = ey;
}
TERM_PUBLIC void
MP_put_text(unsigned int x, unsigned int y, const char str[])
{
int i, j = 0;
char *text;
/* ignore empty strings */
if (!str || !*str)
return;
text = gp_strdup(str);
if (MP_inline)
MP_endline();
switch (MP_justify) {
case LEFT:
j = 1;
break;
case CENTRE:
j = 2;
break;
case RIGHT:
j = 3;
break;
}
if (MP_tex == MP_NO_TEX) {
for (i = 0; i < strlen(text); i++)
if (text[i] == '"')
text[i] = '\''; /* Replace " with ' */
if (MP_fontchanged) {
fprintf(gpoutfile, "\
put_text(\"%s\" infontsize(\"%s\",%5.2f), %.1fa, %.1fb, %d, %d);\n",
text, MP_fontname, MP_fontsize,
x / 10.0, y / 10.0, MP_ang, j);
} else {
fprintf(gpoutfile, "put_text(\"%s\", %.1fa, %.1fb, %d, %d);\n",
text, x / 10.0, y / 10.0, MP_ang, j);
}
} else if (MP_fontchanged) {
if (MP_tex != MP_LATEX) {
fprintf(gpoutfile, "\
put_text( btex \\setfont{%s}{%5.2f} %s etex, %.1fa, %.1fb, %d, %d);\n",
MP_fontname, MP_fontsize, text,
x / 10.0, y / 10.0, MP_ang, j);
} else {
fprintf(gpoutfile, "put_text( btex %s etex, %.1fa, %.1fb, %d, %d);\n",
text, x / 10.0, y / 10.0, MP_ang, j);
}
} else {
fprintf(gpoutfile, "put_text( btex %s etex, %.1fa, %.1fb, %d, %d);\n",
text, x / 10.0, y / 10.0, MP_ang, j);
}
free(text);
}
TERM_PUBLIC int
MP_justify_text(enum JUSTIFY mode)
{
MP_justify = mode;
return (TRUE);
}
TERM_PUBLIC int
MP_text_angle(float ang)
{
/* Metapost code does the conversion */
MP_ang = ang;
return (TRUE);
}
TERM_PUBLIC int
MP_set_font(const char *font)
{
if (*font) {
size_t sep = strcspn(font, ",");
if (sep < sizeof(MP_fontname))
strncpy(MP_fontname, font, sizeof(MP_fontname)-1);
sscanf(&(font[sep + 1]), "%lf", &MP_fontsize);
if (MP_fontsize < 5)
MP_fontsize = 5.0;
if (MP_fontsize >= 100)
MP_fontsize = 99.99;
/* */
MP_fontchanged = TRUE;
} else {
MP_fontchanged = FALSE;
}
return TRUE;
}
TERM_PUBLIC void
MP_reset()
{
if (MP_tex == MP_LATEX) {
fputs("% BEGPOST\n",gpoutfile);
fputs("verbatimtex\n",gpoutfile);
fputs(" \\end{document}\n",gpoutfile);
fputs("etex\n",gpoutfile);
fputs("% ENDPOST\n",gpoutfile);
};
fputs("end.\n", gpoutfile);
}
TERM_PUBLIC void
MP_boxfill(
int style,
unsigned int x1, unsigned int y1,
unsigned int wd, unsigned int ht)
{
/* fillpar:
* - solid : 0 - 100% intensity
* - pattern : 0 - n pattern number
*/
int fillpar = style >> 4;
style &= 0xf;
if (MP_inline)
MP_endline();
switch (style) {
case FS_EMPTY: /* fill with background color */
fprintf(gpoutfile, "\
fill (%.1fa,%.1fb)--(%.1fa,%.1fb)--(%.1fa,%.1fb)--(%.1fa,%.1fb)--cycle withcolor background;\n",
x1 / 10.0, y1 / 10.0, (x1 + wd) / 10.0, y1 / 10.0,
(x1 + wd) / 10.0, (y1 + ht) / 10.0, x1 / 10.0,
(y1 + ht) / 10.0);
break;
case FS_PATTERN: /* pattern fill */
case FS_TRANSPARENT_PATTERN:
/* FIXME: not yet implemented, dummy it up as fill density */
fillpar *= 12;
default:
case FS_SOLID: /* solid fill */
case FS_TRANSPARENT_SOLID:
if (fillpar < 100) {
double density = (100-fillpar) * 0.01;
fprintf(gpoutfile,"fillcolor:=currentcolor*%.2f+background*%.2f;\n",
1.0-density, density);
MP_color_changed = 1;
} else
fprintf(gpoutfile,"fillcolor:=currentcolor;\n");
fprintf(gpoutfile, "\
fill (%.1fa,%.1fb)--(%.1fa,%.1fb)--(%.1fa,%.1fb)--(%.1fa,%.1fb)--cycle withpen (pencircle scaled 0pt) withcolor fillcolor;\n",
x1 / 10.0, y1 / 10.0, (x1 + wd) / 10.0, y1 / 10.0,
(x1 + wd) / 10.0, (y1 + ht) / 10.0, x1 / 10.0,
(y1 + ht) / 10.0);
break;
}
}
TERM_PUBLIC int
MP_make_palette(t_sm_palette *palette)
{
/* metapost can do continuous number of colours */
return 0;
}
TERM_PUBLIC void
MP_set_color(t_colorspec *colorspec)
{
double gray = colorspec->value;
rgb_color color;
/* remember that we changed the color, needed to reset color in MP_linetype()*/
/* FIXME: only set this if the color really did change (compare to previous color) */
MP_color_changed = 1;
if (MP_inline)
MP_endline();
if (!MP_color) { /* gray mode */
if (gray < 1e-3) gray = 0;
fprintf(gpoutfile, "currentcolor:=%.3gwhite;\n", gray);
} else { /* color mode */
if (colorspec->type == TC_LT) {
int linecolor = colorspec->lt;
if (linecolor >= MP_LINE_TYPES)
linecolor %= MP_LINE_TYPES;
if (linecolor == -1)
fprintf(gpoutfile, "currentcolor:=black;\n");
else if (linecolor >= 0)
fprintf(gpoutfile, "currentcolor:=col%d;\n",linecolor);
}
if (colorspec->type == TC_FRAC) {
if (sm_palette.colors != 0) /* finite nb of colors explicitly requested */
gray = (gray >= ((double)(sm_palette.colors-1)) / sm_palette.colors) ?
1 : floor(gray * sm_palette.colors) / sm_palette.colors;
rgb1_from_gray( gray, &color );
} else if (colorspec->type == TC_RGB) {
color.r = (double)((colorspec->lt >> 16 ) & 255) / 255.;
color.g = (double)((colorspec->lt >> 8 ) & 255) / 255.;
color.b = (double)(colorspec->lt & 255) / 255.;
} else
return;
if (color.r < 1e-4) color.r = 0;
if (color.g < 1e-4) color.g = 0;
if (color.b < 1e-4) color.b = 0;
fprintf(gpoutfile, "currentcolor:=%.4g*red+%.4g*green+%.4g*blue;\n",
color.r, color.g, color.b);
}
return;
}
TERM_PUBLIC void
MP_filled_polygon(int points, gpiPoint *corners)
{
int i;
int fillpar = corners->style >> 4;
int style = corners->style & 0xf;
if (MP_inline)
MP_endline();
switch (style) {
case FS_EMPTY: /* fill with background color */
fprintf(gpoutfile,"fillcolor:=background;\n");
break;
case FS_PATTERN: /* pattern fill implemented as partial density */
case FS_TRANSPARENT_PATTERN:
fillpar *= 12;
case FS_SOLID: /* solid fill */
case FS_TRANSPARENT_SOLID:
if (fillpar < 100) {
double density = (100-fillpar) * 0.01;
fprintf(gpoutfile,"fillcolor:=currentcolor*%.2f+background*%.2f;\n",
1.0-density, density);
} else {
fprintf(gpoutfile,"fillcolor:=currentcolor;\n");
}
default:
break;
}
fprintf(gpoutfile, "fill ");
for (i = 0; i < points; i++)
fprintf(gpoutfile, "(%.1fa,%.1fb)%s",
corners[i].x / 10.0, corners[i].y / 10.0,
(i < points - 1 && (i + 1) % MP_LINEMAX == 0) ? "\n--" : "--");
fprintf(gpoutfile, "cycle withcolor fillcolor;\n");
}
TERM_PUBLIC void
MP_dashtype (int type, t_dashtype *custom_dash_type)
{
switch (type) {
case DASHTYPE_SOLID:
fprintf(gpoutfile, "%%MP_dashtype%% DASHTYPE_SOLID\n");
break;
case DASHTYPE_AXIS:
fprintf(gpoutfile, "%%MP_dashtype%% DASHTYPE_AXIS\n");
/* Currently handled elsewhere? */
break;
case DASHTYPE_CUSTOM:
fprintf(gpoutfile, "%%MP_dashtype%% DASHTYPE_CUSTOM: ");
if (custom_dash_type) {
int i;
if (custom_dash_type->dstring[0] != '\0')
fprintf(gpoutfile, "\"%s\"; ", custom_dash_type->dstring);
fprintf(gpoutfile, "[");
for (i = 0; i < DASHPATTERN_LENGTH && custom_dash_type->pattern[i] > 0; i++)
fprintf(gpoutfile, i ? ", %.2f" : "%.2f", custom_dash_type->pattern[i]);
fprintf(gpoutfile, "]");
fprintf(gpoutfile, "\n");
MP_dash_changed = 1;
fprintf(gpoutfile, "currentdash:=dashpattern(");
for (i = 0; i < DASHPATTERN_LENGTH && custom_dash_type->pattern[i] > 0; i++)
fprintf(gpoutfile, "%s %.2f ", i%2?"off":"on", custom_dash_type->pattern[i]);
fprintf(gpoutfile, ");\n");
} else {
fprintf(gpoutfile, "\n");
}
break;
default:
fprintf(gpoutfile, "%%MP_dashtype%% type = %i\n", type);
if (type>0)
MP_linetype(type);
break;
}
}
TERM_PUBLIC void
MP_previous_palette()
{
return;
}
#endif /* TERM_BODY */
#ifdef TERM_TABLE
TERM_TABLE_START(mp_driver)
"mp", "MetaPost plotting standard",
MP_XMAX, MP_YMAX, MP_VCHAR, MP_HCHAR,
MP_VTIC, MP_HTIC, MP_options, MP_init, MP_reset,
MP_text, null_scale, MP_graphics, MP_move, MP_vector,
MP_linetype, MP_put_text, MP_text_angle,
MP_justify_text, MP_point, MP_arrow, MP_set_font, MP_pointsize,
TERM_BINARY|TERM_CAN_CLIP|TERM_CAN_DASH|TERM_IS_LATEX, /*flags*/
0, 0, MP_boxfill, MP_linewidth
#ifdef USE_MOUSE
, 0, 0, 0, 0, 0 /* no mouse support for metapost */
#endif
, MP_make_palette,
MP_previous_palette, /* write grestore */
MP_set_color,
MP_filled_polygon,
.dashtype = MP_dashtype,
.path = MP_path
TERM_TABLE_END(mp_driver)
#undef LAST_TERM
#define LAST_TERM mp_driver
#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */
#ifdef TERM_HELP
START_HELP(mp)
"1 mp",
"?commands set terminal mpost",
"?set terminal mp",
"?set term mp",
"?terminal mp",
"?term mp",
"?mp",
"?metapost",
"",
" Note: legacy terminal (not built by default).",
" The `mp` driver produces output intended to be input to the Metapost program.",
" Running Metapost on the file creates EPS files containing the plots. By",
" default, Metapost passes all text through TeX. This has the advantage of",
" allowing essentially any TeX symbols in titles and labels.",
"",
" Syntax:",
" set term mp {color | colour | monochrome}",
" {solid | dashed}",
" {notex | tex | latex}",
" {magnification <magsize>}",
" {psnfss | psnfss-version7 | nopsnfss}",
" {prologues <value>}",
" {a4paper}",
" {amstex}",
" {\"<fontname> {,<fontsize>}\"} ",
"",
" The option `color` causes lines to be drawn in color (on a printer or display",
" that supports it), `monochrome` (or nothing) selects black lines. The option",
" `solid` draws solid lines, while `dashed` (or nothing) selects lines with",
" different patterns of dashes. If `solid` is selected but `color` is not,",
" nearly all lines will be identical. This may occasionally be useful, so it is",
" allowed.",
"",
" The option `notex` bypasses TeX entirely, therefore no TeX code can be used in",
" labels under this option. This is intended for use on old plot files or files",
" that make frequent use of common characters like `$` and `%` that require",
" special handling in TeX.",
"",
" The option `tex` sets the terminal to output its text for TeX to process.",
"",
" The option `latex` sets the terminal to output its text for processing by",
" LaTeX. This allows things like \\frac for fractions which LaTeX knows about",
" but TeX does not. Note that you must set the environment variable TEX to the",
" name of your LaTeX executable (normally latex) if you use this option or use",
" `mpost --tex=<name of LaTeX executable> ...`. Otherwise metapost will try and",
" use TeX to process the text and it won't work.",
"",
" Changing font sizes in TeX has no effect on the size of mathematics, and there",
" is no foolproof way to make such a change, except by globally setting a",
" magnification factor. This is the purpose of the `magnification` option. It",
" must be followed by a scaling factor. All text (NOT the graphs) will be scaled",
" by this factor. Use this if you have math that you want at some size other",
" than the default 10pt. Unfortunately, all math will be the same size, but see",
" the discussion below on editing the MP output. `mag` will also work under",
" `notex` but there seems no point in using it as the font size option (below)",
" works as well.",
"",
" The option `psnfss` uses postscript fonts in combination with LaTeX. Since",
" this option only makes sense, if LaTeX is being used, the `latex` option is selected",
" automatically. This option includes the following packages for LaTeX:",
" inputenc(latin1), fontenc(T1), mathptmx, helvet(scaled=09.2), courier, latexsym ",
" and textcomp.",
"",
" The option `psnfss-version7` uses also postscript fonts in LaTeX (option `latex`",
" is also automatically selected), but uses the following packages with LaTeX:",
" inputenc(latin1), fontenc(T1), times, mathptmx, helvet and courier.",
"",
" The option `nopsnfss` is the default and uses the standard font (cmr10 if not",
" otherwise specified).",
"",
" The option `prologues` takes a value as an additional argument and adds the line",
" `prologues:=<value>` to the metapost file. If a value of `2` is specified metapost",
" uses postscript fonts to generate the eps-file, so that the result can be viewed",
" using e.g. ghostscript. Normally the output of metapost uses TeX fonts and therefore",
" has to be included in a (La)TeX file before you can look at it.",
"",
" The option `noprologues` is the default. No additional line specifying the prologue",
" will be added.",
"",
" The option `a4paper` adds a `[a4paper]` to the documentclass. Normally letter paper",
" is used (default). Since this option is only used in case of LaTeX, the `latex` option",
" is selected automatically.",
"",
" The option `amstex` automatically selects the `latex` option and includes the following",
" LaTeX packages: amsfonts, amsmath(intlimits). By default these packages are not",
" included.",
"",
" A name in quotes selects the font that will be used when no explicit font is",
" given in a `set label` or `set title`. A name recognized by TeX (a TFM file",
" exists) must be used. The default is \"cmr10\" unless `notex` is selected,",
" then it is \"pcrr8r\" (Courier). Even under `notex`, a TFM file is needed by",
" Metapost. The file `pcrr8r.tfm` is the name given to Courier in LaTeX's psnfss",
" package. If you change the font from the `notex` default, choose a font that",
" matches the ASCII encoding at least in the range 32-126. `cmtt10` almost",
" works, but it has a nonblank character in position 32 (space).",
"",
" The size can be any number between 5.0 and 99.99. If it is omitted, 10.0 is",
" used. It is advisable to use `magstep` sizes: 10 times an integer or",
" half-integer power of 1.2, rounded to two decimals, because those are the most",
" available sizes of fonts in TeX systems.",
"",
" All the options are optional. If font information is given, it must be at the",
" end, with size (if present) last. The size is needed to select a size for the",
" font, even if the font name includes size information. For example,",
" `set term mp \"cmtt12\"` selects cmtt12 shrunk to the default size 10. This",
" is probably not what you want or you would have used cmtt10.",
"",
" The following common ascii characters need special treatment in TeX:",
" $, &, #, %, _; |, <, >; ^, ~, \\, {, and }",
" The five characters $, #, &, _, and % can simply be escaped, e.g., `\\$`.",
" The three characters <, >, and | can be wrapped in math mode, e.g., `$<$`.",
" The remainder require some TeX work-arounds. Any good book on TeX will give",
" some guidance.",
"",
" If you type your labels inside double quotes, backslashes in TeX code need to",
" be escaped (doubled). Using single quotes will avoid having to do this, but",
" then you cannot use `\\n` for line breaks. As of this writing, version 3.7 of",
" gnuplot processes titles given in a `plot` command differently than in other",
" places, and backslashes in TeX commands need to be doubled regardless of the",
" style of quotes.",
"",
" Metapost pictures are typically used in TeX documents. Metapost deals with",
" fonts pretty much the same way TeX does, which is different from most other",
" document preparation programs. If the picture is included in a LaTeX document",
" using the graphics package, or in a plainTeX document via epsf.tex, and then",
" converted to PostScript with dvips (or other dvi-to-ps converter), the text in",
" the plot will usually be handled correctly. However, the text may not appear",
" if you send the Metapost output as-is to a PostScript interpreter.",
"",
"2 Metapost Instructions",
"?commands set terminal mp detailed",
"?set terminal mp detailed",
"?set term mp detailed",
"?mp detailed",
"?metapost detailed",
"",
" - Set your terminal to Metapost, e.g.:",
" set terminal mp mono \"cmtt12\" 12",
"",
" - Select an output-file, e.g.:",
" set output \"figure.mp\"",
"",
" - Create your pictures. Each plot (or multiplot group) will generate a",
" separate Metapost beginfig...endfig group. Its default size will be 5 by 3",
" inches. You can change the size by saying `set size 0.5,0.5` or whatever",
" fraction of the default size you want to have.",
"",
" - Quit gnuplot.",
"",
" - Generate EPS files by running Metapost on the output of gnuplot:",
" mpost figure.mp OR mp figure.mp",
" The name of the Metapost program depends on the system, typically `mpost` for",
" a Unix machine and `mp` on many others. Metapost will generate one EPS file",
" for each picture.",
"",
" - To include your pictures in your document you can use the graphics package",
" in LaTeX or epsf.tex in plainTeX:",
" \\usepackage{graphics} % LaTeX",
" \\input epsf.tex % plainTeX",
" If you use a driver other than dvips for converting TeX DVI output to PS, you",
" may need to add the following line in your LaTeX document:",
" \\DeclareGraphicsRule{*}{eps}{*}{}",
" Each picture you made is in a separate file. The first picture is in, e.g.,",
" figure.0, the second in figure.1, and so on.... To place the third picture in",
" your document, for example, all you have to do is:",
" \\includegraphics{figure.2} % LaTeX",
" \\epsfbox{figure.2} % plainTeX",
"",
" The advantage, if any, of the mp terminal over a postscript terminal is",
" editable output. Considerable effort went into making this output as clean as",
" possible. For those knowledgeable in the Metapost language, the default line",
" types and colors can be changed by editing the arrays `lt[]` and `col[]`.",
" The choice of solid vs dashed lines, and color vs black lines can be change by",
" changing the values assigned to the booleans `dashedlines` and `colorlines`.",
" If the default `tex` option was in effect, global changes to the text of",
" labels can be achieved by editing the `vebatimtex...etex` block. In",
" particular, a LaTeX preamble can be added if desired, and then LaTeX's",
" built-in size changing commands can be used for maximum flexibility. Be sure",
" to set the appropriate MP configuration variable to force Metapost to run",
" LaTeX instead of plainTeX."
END_HELP(mp)
#endif /* TERM_HELP */
|