diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-09 00:45:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-09 00:45:48 +0000 |
commit | 5dc602d16c5be2fd035b254ca23484a90aebd6dc (patch) | |
tree | 72efb15fba318cc2096a8cc6999ed3fa0bff317d /Master/texmf-dist/doc/texdraw | |
parent | b4fc5f639874db951177ec539299d20908adb654 (diff) |
doc 5
git-svn-id: svn://tug.org/texlive/trunk@81 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/texdraw')
23 files changed, 10301 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/texdraw/getopt.c b/Master/texmf-dist/doc/texdraw/getopt.c new file mode 100644 index 00000000000..36ebf5c5b03 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/getopt.c @@ -0,0 +1,762 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu + before changing it! + + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. + Ditto for AIX 3.2 and <stdlib.h>. */ +#ifndef _NO_PROTO +#define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#if !defined (__STDC__) || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include <stdio.h> + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +#include <stdlib.h> +#endif /* GNU C library. */ + +/* This is for other GNU distributions with internationalized messages. + The GNU C Library itself does not yet support such messages. */ +#if HAVE_LIBINTL_H +# include <libintl.h> +#else +# define gettext(msgid) (msgid) +#endif + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg = NULL; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* XXX 1003.2 says this must be 1 before any call. */ +int optind = 0; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return EOF with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +#include <string.h> +#define my_index strchr +#else + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +char *getenv (); + +static char * +my_index (str, chr) + const char *str; + int chr; +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} + +/* If using GCC, we can safely declare strlen this way. + If not using GCC, it is ok not to declare it. */ +#ifdef __GNUC__ +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +#if !defined (__STDC__) || !__STDC__ +/* gcc with -traditional declares the built-in strlen to return int, + and has done so at least since version 2.4.5. -- rms. */ +extern int strlen (const char *); +#endif /* not __STDC__ */ +#endif /* __GNUC__ */ + +#endif /* not __GNU_LIBRARY__ */ + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +static void +exchange (argv) + char **argv; +{ + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; + + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Initialize the internal data when the first call is made. */ + +static const char * +_getopt_initialize (optstring) + const char *optstring; +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + first_nonopt = last_nonopt = optind = 1; + + nextchar = NULL; + + posixly_correct = getenv ("POSIXLY_CORRECT"); + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + + return optstring; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns `EOF'. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; +{ + optarg = NULL; + + if (optind == 0) + { + optstring = _getopt_initialize (optstring); + optind = 1; /* Don't scan ARGV[0], the program name. */ + } + + if (nextchar == NULL || *nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc + && (argv[optind][0] != '-' || argv[optind][1] == '\0')) + optind++; + last_nonopt = optind; + } + + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return EOF; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if ((argv[optind][0] != '-' || argv[optind][1] == '\0')) + { + if (ordering == REQUIRE_ORDER) + return EOF; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound; + int option_index; + + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if (nameend - nextchar == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, gettext ("%s: option `%s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (opterr) + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + gettext ("%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + gettext ("%s: option `%c%s' doesn't allow an argument\n"), + argv[0], argv[optind - 1][0], pfound->name); + + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, + gettext ("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) + { + if (opterr) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, gettext ("%s: unrecognized option `--%s'\n"), + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, gettext ("%s: unrecognized option `%c%s'\n"), + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (opterr) + { + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, gettext ("%s: illegal option -- %c\n"), + argv[0], c); + else + fprintf (stderr, gettext ("%s: invalid option -- %c\n"), + argv[0], c); + } + optopt = c; + return '?'; + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, + gettext ("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#endif /* _LIBC or not __GNU_LIBRARY__. */ + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == EOF) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/Master/texmf-dist/doc/texdraw/getopt.h b/Master/texmf-dist/doc/texdraw/getopt.h new file mode 100644 index 00000000000..952f4830d3d --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/getopt.h @@ -0,0 +1,129 @@ +/* Declarations for getopt. + Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _GETOPT_H +#define _GETOPT_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +#if defined (__STDC__) && __STDC__ + const char *name; +#else + char *name; +#endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +#if defined (__STDC__) && __STDC__ +#ifdef __GNU_LIBRARY__ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int argc, char *const *argv, const char *shortopts); +#else /* not __GNU_LIBRARY__ */ +extern int getopt (); +#endif /* __GNU_LIBRARY__ */ +extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +extern int getopt_long_only (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); +#else /* not __STDC__ */ +extern int getopt (); +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _GETOPT_H */ diff --git a/Master/texmf-dist/doc/texdraw/texdraw.cps b/Master/texmf-dist/doc/texdraw/texdraw.cps new file mode 100644 index 00000000000..ea48e456f9e --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw.cps @@ -0,0 +1,109 @@ +\initial {A} +\entry {accessing \TeX{}draw}{3, 23} +\entry {angle of a vector}{35} +\entry {arcs}{12, 32} +\entry {arrowhead parameters}{8} +\entry {arrows}{7} +\initial {B} +\entry {Bezier curves}{14} +\initial {C} +\entry {circles}{12} +\entry {command syntax}{5} +\entry {coordinate parsing}{35} +\entry {coordinate specification}{6} +\entry {coordinate, symbolic}{18} +\entry {coordinates}{6} +\entry {cosine of a vector direction}{35} +\entry {current position}{7, 21, 35} +\entry {current position in PostScript}{31} +\entry {curves}{14} +\initial {D} +\entry {dashed lines}{8} +\entry {direction of a line}{35} +\entry {distribution}{1} +\entry {dotted lines}{8} +\entry {drawing segments}{17} +\entry {\code {dvi2ps} printer driver}{23} +\entry {\code {dvialw} printer driver}{23} +\entry {\code {dvilaser} printer driver}{23} +\entry {\code {dvips} printer driver}{1, 23, 28} +\entry {\code {dvipsone} printer driver}{23} +\entry {\code {dvitops} printer driver}{23} +\entry {\code {dviwindo} printer driver}{23} +\initial {E} +\entry {ellipses}{12} +\entry {Encapsulated PostScript File}{28} +\entry {errors while using \TeX{}draw}{25} +\entry {example, arrow curve}{36} +\entry {example, block diagram}{39} +\entry {example, circle and ellipse}{44} +\entry {example, graph}{42} +\initial {F} +\entry {fill operations, interaction with drawing segments}{17} +\entry {filled circles}{12} +\entry {filling regions}{15, 31} +\initial {G} +\entry {\code {graphics} package}{1, 3, 23, 28} +\entry {graphics placement}{28} +\entry {gray levels for lines}{8} +\initial {I} +\entry {implementation}{26} +\entry {initial current position}{21} +\entry {invoking \TeX{}draw}{3, 23} +\initial {L} +\entry {La\TeX{}}{1, 3, 23} +\entry {length of a vector}{35} +\entry {line cap}{31} +\entry {line join}{31} +\entry {line width}{8} +\entry {lines}{7, 32} +\entry {listing of commands}{47} +\initial {M} +\entry {moves}{7, 32} +\initial {O} +\entry {\code {oztex} printer driver}{23} +\initial {P} +\entry {painting regions}{15} +\entry {paths}{15, 17, 31} +\entry {\code {pctexps} printer driver}{23} +\entry {\code {pctexwin} printer driver}{23} +\entry {placement of graphics and text}{28} +\entry {plain \TeX{}}{3} +\entry {position specification}{6} +\entry {positions, saving}{18} +\entry {PostScript commands}{31} +\entry {PostScript printer drivers}{23, 28} +\entry {printer drivers}{23, 28} +\entry {problems while using \TeX{}draw}{25} +\entry {\code {psprint} driver}{23} +\initial {R} +\entry {relative positioning}{8} +\entry {relative scaling}{19} +\entry {resolution}{27} +\entry {rotated text}{10, 23, 27, 28} +\initial {S} +\entry {saving positions}{18} +\entry {scaling}{26} +\entry {scaling coordinates}{19} +\entry {segment scale}{19} +\entry {segments}{17} +\entry {sine of a vector direction}{35} +\entry {size of the drawing}{21} +\entry {stroking lines}{17, 31} +\entry {symbolic coordinate}{18} +\entry {syntax of commands}{5} +\initial {T} +\entry {\code {texdraw} package}{3, 23, 28} +\entry {text commands}{10} +\entry {text placement}{28} +\entry {text rotation}{10, 23, 27, 28} +\entry {\code {textures} printer driver}{23} +\initial {U} +\entry {unit scale}{19} +\initial {V} +\entry {vectors}{7} +\entry {vertical text}{10} +\initial {W} +\entry {width of lines}{8} +\initial {X} +\entry {\code {xdvi} driver}{23} diff --git a/Master/texmf-dist/doc/texdraw/texdraw.fns b/Master/texmf-dist/doc/texdraw/texdraw.fns new file mode 100644 index 00000000000..3ec2274f466 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw.fns @@ -0,0 +1,74 @@ +\initial {{\tt\indexbackslash }} +\entry {\code {{\tt\indexbackslash }arc}}{13} +\entry {\code {{\tt\indexbackslash }arrowheadsize}}{9} +\entry {\code {{\tt\indexbackslash }arrowheadtype}}{9} +\entry {\code {{\tt\indexbackslash }avec}}{8} +\entry {\code {{\tt\indexbackslash }begin{\tt\char'173}texdraw{\tt\char'175}}}{5} +\entry {\code {{\tt\indexbackslash }bsegment}}{17} +\entry {\code {{\tt\indexbackslash }btexdraw}}{5} +\entry {\code {{\tt\indexbackslash }centertexdraw}}{5} +\entry {\code {{\tt\indexbackslash }clvec}}{14} +\entry {\code {{\tt\indexbackslash }cossin}}{35} +\entry {\code {{\tt\indexbackslash }currentpos}}{35} +\entry {\code {{\tt\indexbackslash }drawbb}}{21} +\entry {\code {{\tt\indexbackslash }drawdim}}{7} +\entry {\code {{\tt\indexbackslash }end{\tt\char'173}texdraw{\tt\char'175}}}{5} +\entry {\code {{\tt\indexbackslash }esegment}}{17} +\entry {\code {{\tt\indexbackslash }etexdraw}}{5} +\entry {\code {{\tt\indexbackslash }everytexdraw}}{5} +\entry {\code {{\tt\indexbackslash }fcir}}{13} +\entry {\code {{\tt\indexbackslash }fellip}}{13} +\entry {\code {{\tt\indexbackslash }getpos}}{35} +\entry {\code {{\tt\indexbackslash }htext}}{10} +\entry {\code {{\tt\indexbackslash }ifill}}{15} +\entry {\code {{\tt\indexbackslash }lcir}}{12} +\entry {\code {{\tt\indexbackslash }lellip}}{13} +\entry {\code {{\tt\indexbackslash }lfill}}{15} +\entry {\code {{\tt\indexbackslash }linewd}}{8} +\entry {\code {{\tt\indexbackslash }lvec}}{8} +\entry {\code {{\tt\indexbackslash }move}}{8} +\entry {\code {{\tt\indexbackslash }PSarc}}{32} +\entry {\code {{\tt\indexbackslash }PSarcn}}{32} +\entry {\code {{\tt\indexbackslash }PSclosepath}}{31} +\entry {\code {{\tt\indexbackslash }PSfill}}{31} +\entry {\code {{\tt\indexbackslash }PSlineto}}{32} +\entry {\code {{\tt\indexbackslash }PSmoveto}}{32} +\entry {\code {{\tt\indexbackslash }PSnewpath}}{31} +\entry {\code {{\tt\indexbackslash }PSsetlinecap}}{31} +\entry {\code {{\tt\indexbackslash }PSsetlinejoin}}{31} +\entry {\code {{\tt\indexbackslash }PSstroke}}{31} +\entry {\code {{\tt\indexbackslash }ravec}}{8} +\entry {\code {{\tt\indexbackslash }realadd}}{36} +\entry {\code {{\tt\indexbackslash }realdiv}}{36} +\entry {\code {{\tt\indexbackslash }realmult}}{36} +\entry {\code {{\tt\indexbackslash }relsegscale}}{20} +\entry {\code {{\tt\indexbackslash }relunitscale}}{20} +\entry {\code {{\tt\indexbackslash }rlvec}}{8} +\entry {\code {{\tt\indexbackslash }rmove}}{8} +\entry {\code {{\tt\indexbackslash }rtext}}{10} +\entry {\code {{\tt\indexbackslash }savecurrpos}}{18} +\entry {\code {{\tt\indexbackslash }savepos}}{18} +\entry {\code {{\tt\indexbackslash }setgray}}{8} +\entry {\code {{\tt\indexbackslash }setsegscale}}{20} +\entry {\code {{\tt\indexbackslash }setunitscale}}{19} +\entry {\code {{\tt\indexbackslash }textref}}{11} +\entry {\code {{\tt\indexbackslash }vectlen}}{35} +\entry {\code {{\tt\indexbackslash }vtext}}{10} +\entry {\code {{\tt\indexbackslash }writeps}}{32} +\initial {A} +\entry {\code {arc}}{32} +\entry {\code {arcn}}{32} +\initial {C} +\entry {\code {closepath}}{31} +\initial {F} +\entry {\code {fill}}{31} +\initial {L} +\entry {\code {lineto}}{32} +\initial {M} +\entry {\code {moveto}}{32} +\initial {N} +\entry {\code {newpath}}{31} +\initial {S} +\entry {\code {setlinecap}}{31} +\entry {\code {setlinejoin}}{31} +\entry {\code {stroke}}{31} diff --git a/Master/texmf-dist/doc/texdraw/texdraw.pdf b/Master/texmf-dist/doc/texdraw/texdraw.pdf Binary files differnew file mode 100644 index 00000000000..52fc2263f72 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw.pdf diff --git a/Master/texmf-dist/doc/texdraw/texdraw.texi b/Master/texmf-dist/doc/texdraw/texdraw.texi new file mode 100644 index 00000000000..05573b650e7 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw.texi @@ -0,0 +1,2957 @@ +% -*-texinfo-*- + +% TeXdraw texinfo file +% Edition 2.0 + +% $Id: texdraw.texi,v 2.5 1995/12/19 texdraw-V2R0 $ + +% To produce a TeX version of this manual, you must have the following +% files accessible by TeX. +% texdraw.texi - this file, the TeXdraw manual, part of the TeXdraw +% distribution +% texdraw.tex - the TeXdraw macros, part of the TeXdraw distribution +% txdtools.tex - extra macros for TeXdraw, part of the TeXdraw +% distribution +% texinfo.tex - texinfo manual macros (distributed by FSF, for instance +% with the GNUemacs editor). This version of the manual has +% been tested with version 2.145 of texinfo.tex. The file +% texinfo.tex is available by anonymous ftp as +% pub/gnu/texinfo-3.6.tar.Z on prep.ai.mit.edu. +% +\input texdraw % bring in TeXdraw before texinfo changes "\" to "@" +\input txdtools + +\input texinfo @c -*-texinfo-*- +@comment %**start of header +@setfilename texdraw +@settitle @TeX{}draw +@comment %**end of header + +@ifinfo +This file documents @TeX{}draw, a system for producing PostScript drawings +from @TeX{}. + +Copyright @copyright{} 1993-95 Peter Kabal + +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries a copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. +@end ifinfo + +@setchapternewpage odd +@titlepage +@title @TeX{}draw +@subtitle PostScript Drawings from @TeX{} +@subtitle Edition 2.0 +@subtitle December 1995 + +@author Peter Kabal + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1993-95 Peter Kabal + +@sp 2 +This is edition 2.0 of the documentation for the @TeX{}draw macros for +the @TeX{} typesetting program. +@sp 2 + +Peter Kabal @* +Department of Electrical Engineering @* +McGill University @* +3480 University @* +Montreal, Quebec @* +Canada {} H3A@thinspace 2A7 + +@code{kabal@@TSP.EE.McGill.CA} + +@sp 2 +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +@end titlepage + + +@ifinfo +@node Top, Introduction, (dir), (dir) +@top TeXdraw + +@TeX{}draw is a collection of macros that allow drawings to be created +from @emph{within} @TeX{}. + +This is edition 2.0 of the @TeX{}draw documentation. +@end ifinfo + +@menu +* Introduction:: +* TeXdraw Commands:: +* Drawing Segments and Scaling:: +* Using TeXdraw with LaTeX:: +* More Details:: +* PostScript Commands:: +* TeXdraw Toolbox:: +* Examples:: +* Command Listing:: + +Indices +* Concept Index:: +* Command Index:: + + --- The Detailed Node Listing --- + +Introduction + +* Distribution:: + +TeXdraw Commands + +* Accessing TeXdraw:: +* Command syntax:: +* TeXdraw coordinates:: +* Coordinate specification:: +* Line vectors:: +* TeX text:: +* Circles and arcs:: +* Bezier curves:: +* Fill commands:: + +Drawing Segments and Scaling + +* Drawing segments:: +* Drawing paths:: +* Saving positions:: +* Scaling coordinates:: +* Drawing size:: +* Initial current position:: + +Using TeXdraw with LaTeX + +* PostScript printer drivers:: + +More Details + +* Errors while using TeXdraw:: +* Extending TeXdraw:: +* How TeXdraw merges graphics and text:: + +Extending TeXdraw + +* Scaling:: +* Resolution:: +* Text placement:: +* Intermediate PostScript file:: + +PostScript Commands + +TeXdraw Toolbox + +* Coordinate parsing:: +* Real arithmetic:: +* Arrow curve:: + +Examples + +* Block diagram:: +* Filter response graph:: +* Geometric construction:: + +Command Listing + +Command Index + +Concept Index +@end menu + + +@node Introduction, TeXdraw Commands, Top, Top +@chapter Introduction + +@TeX{} is a powerful typesetting program which allows for complex text +layouts but by itself lacks a general graphics capability. However, +when coupled with an appropriate printer driver program, external +graphics files can be inserted into the printed document. In this mode, +@TeX{} is instructed to leave space for a drawing. The drawing is +inserted by the printer driver program. The @TeX{}draw macros described +here generate the external graphics file from within @TeX{} and generate +the instructions to the the print driver program to position the +graphics at the appropriate position on the page. + +@TeX{}draw consists of a set of @TeX{} macros that create line drawings +and other figures. The drawing primitives include solid lines, +patterned lines, Bezier curves, circles and arrows. Other commands +allow for the filling of a region with a gray level. The drawing +commands generate PostScript code. This limits @TeX{}draw to systems +which use PostScript printers. @TeX{}draw also provides commands to +position @TeX{} text, including mathematics, on the drawing. The final +drawing, with text and graphics, can be positioned on the page like any +other @TeX{} box. + +@cindex @code{dvips} printer driver +@cindex La@TeX{} +@cindex @code{graphics} package +The basic @TeX{}draw macros for @TeX{} use the @code{\special} syntax +recognized by the printer driver program @code{dvips}. However, when +invoked as a La@TeX{}2e package, the @TeX{}draw macros can be used with +any of the PostScript printer driver programs supported by the standard +@code{graphics} package for La@TeX{}2e. + +The basic @TeX{}draw macros provide only simple drawing commands. +However, @TeX{}draw provides a drawing segment environment which allows +parameter changes and coordinate scaling changes to be kept local to the +drawing segment. This facility, together with @TeX{}'s macro +capabilities allows one to modularize drawing units and extend +@TeX{}draw by building more complex graphics entities from simpler +elements. + +@menu +* Distribution:: +@end menu + +@node Distribution, , , Introduction +@section Distribution information +@cindex distribution + +The @TeX{}draw routines are provided free of charge without warranty of +any kind. Note that the @TeX{}draw routines are copyrighted. They may +be distributed freely provided that the recipients also acquire the +right to distribute them freely. The notices to this effect must be +preserved when the source files are distributed. + + +@node TeXdraw Commands, Drawing Segments and Scaling, Introduction, Top +@chapter Using the @TeX{}draw Commands + +The main @TeX{}draw macros (commands) are defined in the file +@file{texdraw.tex}. These macros may be used directly in @TeX{}. The +file @file{texdraw.sty} provides an interface for use with La@TeX{}2e. +The following sections describe the basic commands for @TeX{}draw. + +@menu +* Accessing TeXdraw:: +* Command syntax:: +* TeXdraw coordinates:: +* Coordinate specification:: +* Line vectors:: +* TeX text:: +* Circles and arcs:: +* Bezier curves:: +* Fill commands:: +@end menu + +@node Accessing TeXdraw, Command syntax, , TeXdraw Commands +@section Accessing @TeX{}draw +@cindex accessing @TeX{}draw +@cindex invoking @TeX{}draw + +@cindex plain @TeX{} +@cindex La@TeX{} +The form of the user command to run the @TeX{} program depends on which +version of @TeX{} is being used, and which other macro packages are +preloaded as format files. Typically, installations have at least two +versions of @TeX{} --- plain @TeX{} which includes basic typesetting +macros (usually invoked as @file{tex}) and La@TeX{}2e which includes the +La@TeX{}2e typesetting macros (usually invoked as @file{latex}). An +older version of La@TeX{}, version 2.09, may also be available. The +@TeX{}draw macros can be used with plain @TeX{} and with either version +of La@TeX{}. + +For use with plain @TeX{}, the user must read in the @TeX{}draw macros +from the file @file{texdraw.tex}. +@example +@group +\input texdraw % Read in the TeXdraw macros + ... +\btexdraw + ... % TeXdraw commands to generate a drawing +\etexdraw +@end group +@end example + +For use with La@TeX{} version 2.09, the user reads in the @TeX{}draw +macros from the file @file{texdraw.tex} and optionally defines the +@code{\begin@{texdraw@}} / @code{\end@{texdraw@}} environment. +@example +@group +\documentstyle[11pt]@{article@} % Article style with the 11pt size options +... +\input texdraw % Read in the TeXdraw macros +\newenvironment@{texdraw@}@{\leavevmode\btexdraw@}@{\etexdraw@} + ... +\begin@{texdraw@} + ... % TeXdraw commands to generate a drawing +\end@{texdraw@} +... +\end@{document@} +@end group +@end example + +@cindex @code{texdraw} package +@cindex @code{graphics} package +For use with La@TeX{}2e, the user must load the @code{texdraw} package +(file @file{texdraw.sty}). This package file defines the +@code{\begin@{texdraw@}} / @code{\end@{texdraw@}} environment, brings in +the standard @code{graphics} package and reads in the file +@file{texdraw.tex} containing the definitions of the @TeX{}draw macros. +@example +@group +\documentclass[11pt]@{article@} % Article class with the 11pt size option +\usepackage@{texdraw@} % TeXdraw commands + +\begin@{document@} + ... +\begin@{texdraw@} + ... % TeXdraw commands to generate a drawing +\end@{texdraw@} + ... +\end@{document@} +@end group +@end example + +As the @TeX{}draw commands are processed by @TeX{}, an intermediate +PostScript file is generated. The intermediate PostScript has a name of +the form @file{@var{name}.ps1}. The name part is derived from the name +of the main @TeX{} file being processed. If more than one drawing is +produced, the digit in the file name extension is +incremented.@footnote{After the ninth PostScript file, the name of the +intermediate PostScript file takes the form @file{@var{name}.p10}, with +the number increasing from 10 with each file.} + +The @TeX{}draw commands to produce a drawing are inserted between +@code{\btexdraw} and @code{\etexdraw} commands, or for La@TeX{}, between +@code{\begin@{texdraw@}} and @code{\end@{texdraw@}} commands. This +results in a @TeX{} box of appropriate size containing the drawing +generated by the @TeX{}draw commands. The @TeX{}draw box can be +positioned in a document like any other @TeX{} box. + +The @code{\centertexdraw@{...@}} macro centers the box generated by +@TeX{}draw. The vertical space taken up is equal to the vertical size +of the drawing. The @code{\centertexdraw} macro is normally used in +vertical mode (between paragraphs). A @code{\par} command (a blank line +will do also) before a @code{\centertexdraw} command will terminate +horizontal mode and return to vertical mode. For La@TeX{}, a structured +equivalent to the @code{\centertexdraw@{...@}} command is shown below. +@example +@group +\begin@{center@} +\begin@{texdraw@} + ... +\end@{texdraw@} +\end@{center@} +@end group +@end example + +The @code{\everytexdraw} command can be used to define a set of +@TeX{}draw commands that will be executed at the beginning of every +@TeX{}draw drawing. It is invoked as @code{\everytexdraw@{ ...@}}, +with the desired @TeX{}draw commands as arguments. + +@table @code +@findex \btexdraw +@item \btexdraw +Start a @TeX{}draw drawing. The drawing is terminated with an +@code{\etexdraw} command. +@findex \etexdraw +@item \etexdraw +End a @TeX{}draw drawing started with a @code{\btexdraw} command. The +resulting @TeX{}draw drawing is placed in a box with height equal to the +height of the drawing and width equal to the width of the drawing. The +depth of the box is zero. +@findex \begin@{texdraw@} +@item \begin@{texdraw@} +Start a @TeX{}draw drawing. The drawing is terminated with an +@code{\end@{texdraw@}} command. This command is for use with La@TeX{}. +@findex \end@{texdraw@} +@item \end@{texdraw@} +End a @TeX{}draw drawing started with a @code{\begin@{texdraw@}} +command. The resulting @TeX{}draw drawing is placed in a box with +height equal to the height of the drawing and width equal to the width +of the drawing. The depth of the box is zero. This command is for use +with La@TeX{}. +@findex \centertexdraw +@item \centertexdraw@{ ... @} +Center a @TeX{}draw box horizontally. The argument contains @TeX{}draw +commands. The resulting box has the horizontal size @code{\hsize} and +height equal to the height of the drawing. +@findex \everytexdraw +@item \everytexdraw@{ ... @} +Specify @TeX{}draw commands to be executed at the beginning of every +@TeX{}draw drawing. +@end table + +@node Command syntax, TeXdraw coordinates, Accessing TeXdraw, TeXdraw Commands +@section Command syntax +@cindex command syntax +@cindex syntax of commands + +Generally @TeX{}draw commands that take a single argument need a +terminating blank or newline after the argument. Arguments that are +self-delimiting, such as coordinates within parentheses and text within +braces, do not need the terminating blank. However, even when not +needed by the defining syntax of the command, blanks following command +arguments are allowed and ignored within the @TeX{}draw environment. + +On entering the @TeX{}draw environment, @TeX{} is in internal vertical +mode (vertical mode inside a @code{\vbox}). In this mode, spaces can be +placed freely between commands. However, any other extraneous input +that generates output that is not part of the @TeX{}draw environment is +disallowed. + +Blank lines are interpreted as paragraph breaks, equivalent to a +@code{\par} command. The @TeX{}draw macro @code{\centertexdraw} is +defined with the @code{\long} attribute to allow @code{\par} commands +and blank lines to be interspersed between @TeX{}draw commands. The +@code{\btexdraw} and @code{\etexdraw} commands also allow @code{\par} +command and blank lines to be included. + +@node TeXdraw coordinates, Coordinate specification, Command syntax, TeXdraw Commands +@section @TeX{}draw coordinates +@cindex coordinates + +The @TeX{}draw coordinate system has increasing @var{x} to the right and +increasing @var{y} upward. The coordinates (without the unit) are +floating point numbers. Integer values can be written without a decimal +point. The size of the drawing is determined by the maximum excursions +of the coordinates specified in @TeX{}draw commands. +@tex +\bigskip +\centertexdraw{ + \avec (0 0.8) \textref h:C v:B \htext (0 0.9){\sl y} + \move (0 0) \avec (0.8 0) \textref h:L v:C \htext(0.9 0){\sl x} + \move (0 1.0)} +@end tex + +Consider the following example of @TeX{}draw commands to draw a simple +figure. +@example +@group +\centertexdraw@{ + \drawdim cm \linewd 0.02 + \move(2 2) \lvec(3 3) \lvec(2 4) \lvec(1 3) \lvec(2 2) + \textref h:C v:C \htext(2 3)@{$\sum \rho_n$@} +@} +@end group +@end example +@tex +\bigskip +\centertexdraw{ + \drawdim{cm} \linewd 0.02 + \move(2 2) \lvec(3 3) \lvec(2 4) \lvec(1 3) \lvec(2 2) + \textref h:C v:C \htext(2 3){$\sum \rho_n$} +} +@end tex +This drawing uses units of centimetres, with a line width of 0.02 cm. +The @var{x} coordinate ranges between 1 and 3 while the @var{y} +coordinate ranges between 2 and 4. When included into a document, the +size of the drawing is 2 cm by 2 cm. The drawing is placed in a @TeX{} +box, with the lower lefthand corner of the box corresponding to +@TeX{}draw coordinate @code{(1 2)} and the upper righthand corner at +@code{(3 4)}. The @code{\centertexdraw} command centers the drawing +horizontally. The @code{\textref} command controls the centering of the +text. The text in this drawing is centered (both horizontally and +vertically) at the coordinate @code{(2 3)}. + +@node Coordinate specification, Line vectors, TeXdraw coordinates, TeXdraw Commands +@section Coordinate specification +@cindex coordinate specification +@cindex position specification + +Coordinates are specified within parentheses, with blanks (but no comma) +between the values. Leading blanks and trailing blanks are permitted +within the parentheses. The coordinates refer to units, which are +specified by the @code{\drawdim} command. The default is inches, but +any valid @TeX{} dimension unit can be specified. Symbolic +specification of saved coordinate values will be discused later +(@pxref{Saving positions}). + +@table @code +@findex \drawdim +@item \drawdim @var{dim} +Set the units to @var{dim}. The argument @var{dim} can be any valid +@TeX{} dimension unit. The units are used to interpret coordinate +values. Examples of valid units: @code{cm}, @code{mm}, @code{in}, +@code{pt}, and @code{bp}. +@end table + +Examples of coordinate and scaling specifications: +@table @code +@item \drawdim @{cm@} \move(2 2) +Set the units to centimetres, move to a position 2 cm to the right and 2 +cm up from the origin of the drawing coordinate system. +@item \drawdim bp +Set the units to big points. +@item \lvec ( 2.2 +5.5) \lvec(2.3 -2) \lvec(2.2 5.4 ) +Examples of acceptable coordinate specifications. +@end table + +@node Line vectors, TeX text, Coordinate specification, TeXdraw Commands +@section Line vectors +@cindex lines +@cindex vectors +@cindex arrows +@cindex moves +@cindex current position + +@TeX{}draw implements moves, line vectors and arrow vectors. There are +both absolute and relative motion versions of these vector commands. +@TeX{}draw maintains a current position. Lines are drawn from the +current position to a new coordinate, with the new coordinate becoming +the new current position. An explicit move can be used to establish a +new current position. The position @code{(0 0)} is used if there is no +move to an initial current position. + +The @code{\move} and @code{\rmove} commands establish a new current +position without drawing a line. The @code{\lvec} and @code{\rlvec} +commands draw a line from the current position to a new position, which +then becomes the new current position. The @code{\avec} and +@code{\ravec} commands draw a line with an arrowhead from the current +position to a new coordinate, which then becomes the new current +position. The tip of the arrow is at the new current position. The +direction of the arrow follows the direction of the line. Since this +direction is undefined for zero length vectors, these are not allowed +for @code{\avec} or @code{\ravec}. Zero length arrow vectors will +generate a PostScript print error: @code{undefinedresult}. For any +non-zero length vector, the full size arrowhead is drawn, even if that +arrowhead is longer than the line length. + +The absolute motion versions of these commands specify the coordinate of +the final position. + +@table @code +@findex \move +@item \move (@var{x} @var{y}) +Move to coordinate @code{(@var{x} @var{y})}. The new current position +is @code{(@var{x} @var{y})}. +@findex \lvec +@item \lvec (@var{x} @var{y}) +Draw a line from the current position to coordinate @code{(@var{x} +@var{y})}. The new current position is @code{(@var{x} @var{y})}. +@findex \avec +@item \avec (@var{x} @var{y}) +Draw a line with an arrowhead from the current position to +@code{(@var{x} @var{y})}. The new current position is @code{(@var{x} +@var{y})}. The arrowhead is aligned with the line, with the tip at +@code{(@var{x} @var{y})}. +@end table + +@cindex relative positioning +The relative motion versions of these commands interpret the coordinates +as displacements relative to the current position. Given the +displacements @code{(@var{dx} @var{dy})} as a parameter, each of the +relative motion commands moves @var{dx} units in the @var{x} direction +and @var{dy} units in the @var{y} direction. + +@table @code +@findex \rmove +@item \rmove (@var{dx} @var{dy}) +Move from the current position, @var{dx} units in the @var{x} direction +and @var{dy} units in the @var{y} direction. The final position becomes +the new current position. +@findex \rlvec +@item \rlvec (@var{dx} @var{dy}) +Draw a line from the current position, @var{dx} units in the @var{x} +direction and @var{dy} units in the @var{y} direction. The final +position becomes the new current position. +@findex \ravec +@item \ravec (@var{dx} @var{dy}) +Draw a line with an arrowhead from the current position, @var{dx} units +in the @var{x} direction and @var{y} units in the @var{y} direction. +The final position becomes the new current position. The arrowhead is +aligned with the line, with the tip at the new current position. +@end table + +Lines can be customized with commands to change the line width, line +pattern and line gray level rendition. In addition, commands for +changing the type and size of the arrowhead are available. + +@cindex line width +@cindex width of lines +@cindex dashed lines +@cindex dotted lines +@cindex gray levels for lines +@cindex arrowhead parameters +@table @code +@findex \linewd +@item \linewd @var{width} +Set the line width to @var{width} units. Initially @var{width} is 0.01 +inches (corresponding to 3 pixels at 300 pixels to the inch). +@item \lpatt (@var{pattern}) +Set lines to have the pattern @code{(@var{pattern})}. A pattern is a +sequence of on/off lengths separated by blanks and enclosed in parentheses. +The lengths alternately specify the length of a dash and the length of a +gap between dashes. Each length is interpreted using the current +scaling and drawing units. The pattern is used cyclically. The empty +pattern signifies a solid line. The initial line pattern is a solid +line, corresponding to the empty pattern @code{\lpatt ()}. +@findex \setgray +@item \setgray @var{level} +Set the gray level of lines. Gray levels are real values from 0 (black) +through intermediate values (gray) to 1 (white). The initial gray level +is 0 corresponding to black. +@findex \arrowheadtype +@item \arrowheadtype t:@var{type} +Set the arrowhead type to @var{type}, where @var{type} is one of +@code{F}, @code{T}, @code{W}, @code{V}, or @code{H}. There are two +kinds of arrowheads. The first kind is a triangle. There are 3 +variants: type @code{T} is an empty triangle, type @code{F} is a filled +triangle (using the current gray level for lines), type @code{W} is a +triangle filled with white. The second kind of arrowhead is an open +ended Vee. There are 2 variants: type @code{V} has the stem continue to +the tip, type @code{H} has the stem stop at the base of the arrowhead. +The initial arrowhead type is @code{T}. +@findex \arrowheadsize +@item \arrowheadsize l:@var{length} w:@var{width} +Set the arrowhead size to be @var{length} units long and @var{width} +units wide. The width is measured across the ``base'' of the arrowhead. +The initial arrowhead size has a @var{length} of 0.16 inches and a +@var{width} of 0.08 inches. +@end table + +Note that the lines which outline the arrowhead will be drawn with the +same line pattern used for the stem. Normally, arrow vectors are drawn +with the line pattern set for a solid line. Note that the fill level +used for the @code{F} variant of the arrowhead uses the same gray level +as used for lines. The difference between the @code{T} variant and the +@code{W} variant only shows up if the arrowhead is placed over non-white +areas of the drawing. The @code{W} variant obliterates the area under +the arrowhead. + +Examples of line parameter and arrowhead settings are shown in the +following code. +@example +@group +\centertexdraw@{ + \drawdim in + \linewd 0.03 \setgray 0.6 \arrowheadtype t:F \avec(0 0.5) + \linewd 0.01 \setgray 0 \arrowheadtype t:V \avec(0.5 0.5) + \linewd 0.015 \lpatt(0.067 0.1) \lvec (1 0) + \linewd 0.02 \lpatt() \arrowheadtype t:T \avec(1.5 0.5) + \arrowheadtype t:H \avec(2.0 0.5) + \setgray 0.4 \arrowheadtype t:W \avec(3.0 0) +@} +@end group +@end example +@tex +\bigskip +\centertexdraw{ + \drawdim in + \linewd 0.03 \setgray 0.6 \arrowheadtype t:F \avec(0.5 0.5) + \linewd 0.01 \setgray 0 \arrowheadtype t:V \avec(1.0 0.5) + \linewd 0.015 \lpatt(0.067 0.1) \lvec (1.5 0) + \linewd 0.02 \lpatt() \arrowheadtype t:T \avec(2.0 0.5) + \arrowheadtype t:H \avec(2.5 0.5) + \setgray 0.4 \arrowheadtype t:W \avec(3.0 0) + \textref h:R v:T \htext (0.35 0.50){\tt t:F} + \textref h:R v:T \htext (1.0 0.43){\tt t:V} + \textref h:R v:T \htext (1.82 0.50){\tt t:T} + \textref h:R v:T \htext (2.5 0.43){\tt t:H} + \textref h:R v:B \htext (2.8 0){\tt t:W} +} +@end tex + +@node TeX text, Circles and arcs, Line vectors, TeXdraw Commands +@section @TeX{} text +@cindex text commands + +Text may be superimposed on the drawing. The text argument of the +@code{\htext} command is in horizontal mode. This text can be ordinary +text, math mode expressions, or even more complicated boxes consisting +of tables and the like. The resulting @TeX{} text is placed in a box. +The reference point of the box can be chosen to be one of nine +locations: horizontally left, center or right; vertically top, center or +bottom. The @code{\htext} command takes one of two forms. + +@table @code +@findex \htext +@item \htext (@var{x} @var{y})@{@var{text}@} +@itemx \htext @{@var{text}@} +The first form of this command places the @TeX{} text @var{text} +horizontally with the text reference point at the coordinate +@code{(@var{x} @var{y})}. The new current position is @code{(@var{x} +@var{y})}. The second form of this command places the @TeX{} text +@var{text} horizontally with the text reference point at the current +position. The text reference point is set with the @code{\textref} +command. +@end table + +@cindex vertical text +@cindex rotated text +@cindex text rotation +Text can be placed vertically using the @code{\vtext} command. The text +argument is in horizontal mode. The @TeX{} text is placed in a box and +then rotated counterclockwise. The reference point is the point in the +box, @emph{before} rotation of the text. Not all PostScript printer +drivers support vertical text. + +@table @code +@findex \vtext +@item \vtext (x y)@{@var{text}@} +@itemx \vtext @{@var{text}@} +The first form of this command places the @TeX{} text @var{text} +vertically with the text reference point at the coordinate +@code{(@var{x} @var{y})}. The new current position is @code{(@var{x} +@var{y})}. The second form of this command places the @TeX{} text +@var{text} vertically with the text reference point at the current +position. In both cases, the @TeX{} text is placed in a box and the box +is rotated counterclockwise by 90 degrees about the text reference +point. The text reference point is set with the @code{\textref} +command. +@end table + +@cindex rotated text +@cindex text rotation +Text can be placed at an arbitrary angle using the @code{\rtext} +command. The text argument is in horizontal mode. The @TeX{} text is +placed in a box and then rotated counterclockwise. The reference point +is the point in the box, @emph{before} rotation of the text. Not all +PostScript printer drivers support rotated text. + +@table @code +@findex \rtext +@item \rtext td:@var{angle} (x y)@{@var{text}@} +@itemx \rtext td:@var{angle} @{@var{text}@} +The first form of this command places the @TeX{} text @var{text} at an +angle with the text reference point at the coordinate @code{(@var{x} +@var{y})}. The new current position is @code{(@var{x} @var{y})}. The +second form of this command places the @TeX{} text @var{text} at an +angle with the text reference point at the current position. In both +cases, the @TeX{} text is placed in a box and the box is rotated +counterclockwise by @var{angle} degrees about the text reference point. +The text reference point is set with the @code{\textref} command. +@end table + +The reference point for subsequent @TeX{} text in a @code{\htext}, +@code{\vtext} or @code{\rtext} command is set with the @code{\textref} +command. + +@table @code +@findex \textref +@item \textref h:@var{h-ref} v:@var{v-ref} +Set the text reference point for subsequent text commands. The +horizontal reference point @var{h-ref} is one of @code{L}, @code{C} or +@code{R} (left, center or right). The vertical reference point +@var{v-ref} is one of @code{T}, @code{C} or @code{B} (top, center or +bottom). For rotated text, the reference point is determined before +rotation. The initial text reference point corresponds to +@code{\textref h:L v:B}. +@end table +@noindent + +@tex +\centertexdraw{ + \def\bdot {\bsegment + \fcir f:0 r:0.02 + \esegment} + \def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 +0.06){#1} + \esegment} + \def\Btext #1{\bsegment + \textref h:C v:T \htext (0 -0.06){#1} + \esegment} + \def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.08 0){#1} + \esegment} + \def\Rtext #1{\bsegment + \textref h:L v:C \htext (+0.08 0){#1} + \esegment} + \move (-1.5 0) + \bsegment + \move (+1.55 +0.45) \move (-1.55 -0.45) \move (0 0) + \Ttext{Horizontal Text} + \bdot \Btext{\tt h:C v:C} + \move (-0.9 0) \bdot \Ltext{\tt h:L v:C} + \move (+0.9 0) \bdot \Rtext{\tt h:R v:C} + \move (0 +0.3) \bdot \Ttext{\tt h:C v:T} + \move (0 -0.3) \bdot \Btext{\tt h:C v:B} + \move (-0.9 -0.3) \bdot \Ltext{\tt h:L v:B} + \lvec (-0.9 +0.3) \bdot \Ltext{\tt h:L v:T} + \lvec (+0.9 +0.3) \bdot \Rtext{\tt h:R v:T} + \lvec (+0.9 -0.3) \bdot \Rtext{\tt h:R v:B} + \lvec (-0.9 -0.3) + \esegment + \def\atext {\rtext td:45 } + \def\ATtext #1{\bsegment + \setsegscale 0.707 + \textref h:C v:B \atext (-0.06 +0.06){#1} + \esegment} + \def\ABtext #1{\bsegment + \setsegscale 0.707 + \textref h:C v:T \atext (+0.060 -0.06){#1} + \esegment} + \def\ALtext #1{\bsegment + \setsegscale 0.707 + \textref h:R v:C \atext (-0.08 -0.08){#1} + \esegment} + \def\ARtext #1{\bsegment + \setsegscale 0.707 + \textref h:L v:C \atext (+0.08 +0.08){#1} + \esegment} + \move (+1.5 0) + \bsegment + \move (+1.33 +1.33) \move (-1.33 -1.33) \move (0 0) + \setsegscale 0.707 + \ATtext{Rotated Text} + \bdot \ABtext{\tt h:C v:C} + \move (-0.9 -0.9) \bdot \ALtext{\tt h:L v:C} + \move (+0.9 +0.9) \bdot \ARtext{\tt h:R v:C} + \move (-0.3 +0.3) \bdot \ATtext{\tt h:C v:T} + \move (+0.3 -0.3) \bdot \ABtext{\tt h:C v:B} + \move (-0.6 -1.2) \bdot \ALtext{\tt h:L v:B} + \lvec (-1.2 -0.6) \bdot \ALtext{\tt h:L v:T} + \lvec (+0.6 +1.2) \bdot \ARtext{\tt h:R v:T} + \lvec (+1.2 +0.6) \bdot \ARtext{\tt h:R v:B} + \lvec (-0.6 -1.2) + \esegment +} +@end tex + +The font used to render the text is determined as for any other @TeX{} +text. Normally the font used outside of @TeX{}draw is in effect. If +desired, other fonts can be specified as part of the text. Any font +changes within a @TeX{}draw text command remain local to that command. + +Only the coordinate of the text reference point in a @code{\htext}, +@code{\vtext} or @code{\rtext} command is used in calculating the size +of the drawing. This means that text itself can spill outside of the +drawing area determined by @TeX{}draw. The area of the drawing can be +increased to include the text by issuing additional @code{\move} +commands. + +@example +@group +\centertexdraw@{ + \avec(-0.75 -0.25) \textref h:R v:C \htext@{H-text@} + \move(0 0) \avec(-0.75 +0.25) \textref h:R v:B \htext@{H-text@} + \move(0 0) \avec(0 +0.5) \textref h:L v:T \vtext@{V-text@} + \move(0 0) \avec(+0.75 +0.25) \textref h:L v:B \htext@{H-text@} + \move(0 0) \avec(+0.75 -0.25) \textref h:L v:C \htext@{H-text@} +@} +@end group +@end example +@iftex +Superimposed on this example is a shaded region showing the limits of +the @TeX{}draw box as determined by the coordinates specified. +@tex +\bigskip +\centertexdraw{ + \move(-0.75 -0.25) \lvec (-0.75 +0.5) \lvec (+0.75 +0.5) + \lvec(+0.75 -0.25) \ifill f:0.9 % fill the region + \move(0 0) + \avec(-0.75 -0.25) \textref h:R v:C \htext{H-text} + \move(0 0) \avec(-0.75 +0.25) \textref h:R v:B \htext{H-text} + \move(0 0) \avec(0 +0.5) \textref h:L v:T \vtext{V-text} + \move(0 0) \avec(+0.75 +0.25) \textref h:L v:B \htext{H-text} + \move(0 0) \avec(+0.75 -0.25) \textref h:L v:C \htext{H-text} + \move (-1.15 -0.3) \move (+1.15 +0.92) % increase the size of the drawing +} +@end tex +@end iftex + +@node Circles and arcs, Bezier curves, TeX text, TeXdraw Commands +@section Circles, ellipses and arcs +@cindex circles +@cindex filled circles +@cindex ellipses +@cindex arcs + +@TeX{}draw supplies commands to generate circles, ellipses and arcs. +There are two forms of the circle command. The @code{\lcir} command +draws a circle of given radius. The @code{\fcir} command draws a filled +circle. In the latter case, the circle is filled by a specified gray +level. For the filled circle, the line defining the circumference of +the circle is not drawn. Note that the gray level area filled in by the +@code{\fcir} command is opaque, even if the fill is chosen to be white. +For either form of the circle command, the drawing size is increased if +necessary to contain the circle. + +The @code{\lellip} command generates an ellipse specified by the radius +of the ellipse in the @var{x} direction and the radius of the ellipse in +the @var{y} direction. The ellipse is symmetrical about horizontal and +vertical lines drawn through the current point. The @code{\fellip} +command draws a filled ellipse. In the latter case, the ellipse is +filled by a specified gray level. For the filled ellipse, the line +defining the boundary of the ellipse is not drawn. For either form of +the ellipse command, the drawing size is increased if necessary to +contain the ellipse. + + +The @code{\larc} command generates a counterclockwise arc specified by a +start angle in degrees and an end angle in degrees. The center of the +arc is the current position. Only the arc is drawn, not the line +joining the center to the beginning of the arc. Note that the +@code{\larc} command does not affect the size of the drawing. + +@table @code +@findex \lcir +@item \lcir r:@var{radius} +Draw a circle with center at the current position. The radius is +specified by @var{radius}. This command draws a line along the +circumference of the circle. The drawing size is increased if necessary +to contain the circle. +@findex \fcir +@item \fcir f:@var{level} r:@var{radius} +Draw a filled circle with center at the current position. The radius is +specified by @var{radius}. The circle is painted with the gray level +specified by @var{level}. A gray level of 1 corresponds to white, with +decreasing values getting darker. The level 0 is full black. This +command does not draw a line along the circumference. The drawing size +is increased if necessary to contain the circle. +@findex \lellip +@item \lellip rx:@var{x-radius} ry:@var{y-radius} +Draw an ellipse with center at the current position. The radius in the +@var{x} direction is specified by @var{x-radius}. The radius in the +@var{y} direction is specified by @var{y-radius}. The drawing size is +increased if necessary to contain the ellipse. +@findex \fellip +@item \fellip f:@var{level} rx:@var{x-radius} ry:@var{y-radius} +Draw a filled ellipse with center at the current position. The radius +in the @var{x} direction is specified by @var{x-radius}. The radius in +the @var{y} direction is specified by @var{y-radius}. The ellipse is +painted with the gray level specified by @var{level}. A gray level of 1 +corresponds to white, with decreasing values getting darker. The level +0 is full black. This command does not draw a line along the boundary +of the ellipse. The drawing size is increased if necessary to contain +the ellipse. +@findex \arc +@item \larc r:@var{radius} sd:@var{start-angle} ed:@var{end-angle} +Draw a counterclockwise arc. The center of the arc is at the current +position. The radius is specified by @var{radius}. The start and end +angles (in degrees) are specified by @var{start-angle} and +@var{end-angle}. This command does not affect the limits (size) of the +drawing. +@end table + +As an example, the following commands draw a filled circle, and +superimpose an arc. +@example +@group +\centertexdraw@{ + \linewd 0.02 + \fcir f:0.7 r:1 + \larc r:1 sd:45 ed:135 + \lvec (+0.707 +0.707) \move (0 0) \lvec (-0.707 +0.707) +@} +@end group +@end example +@tex +\bigskip +\centertexdraw{ + \linewd 0.02 + \fcir f:0.7 r:1 + \larc r:1 sd:45 ed:135 + \lvec ( 0.707 0.707) \move (0 0) \lvec (-0.707 +0.707) +} +@end tex + +Note that for the arc command, the resulting figure can spill outside of +the @TeX{}draw box as determined by the maximum excursions of the +coordinates. Extra moves can be used to compensate for the size of the +arc. + +@node Bezier curves, Fill commands, Circles and arcs, TeXdraw Commands +@section Bezier curves +@cindex Bezier curves +@cindex curves + +Bezier curves in @TeX{}draw use 4 reference coordinates, two as the end +points and two others to control the shape of the curve. Let the 4 +points be @code{(@var{x0} @var{y0})}, @code{(@var{x1} @var{y1})}, +@code{(@var{x2} @var{y2})} and @code{(@var{x3} @var{y3})}. The curve +starts out tangent to the line joining the first two points and ends up +tangent to the line joining the second two points. The control points +``pull'' at the curve to control the curvature. The amount of pull +increases with the distance of the control point from the endpoint. + +@tex +As the parameter $\mu$ varies from 0 to 1, the coordinates of the Bezier +curve are given by a pair of parametric cubic equations, +$$ +\def\x #1{\hbox{\sl x#1}} +\def\y #1{\hbox{\sl y#1}} +\eqalign{ + \x{}(\mu) &= (1-\mu)^3 \x0 + 3\mu(1-\mu)^2 \x1 + 3\mu^2(1-\mu) \x2 + \mu^3 \x3 \cr + \y{}(\mu) &= (1-\mu)^3 \y0 + 3\mu(1-\mu)^2 \y1 + 3\mu^2(1-\mu) \y2 + \mu^3 \y3\ . \cr} +$$ +@end tex +@ifinfo +As the parameter u varies from 0 to 1, the coordinates of the Bezier +curve are given by a pair of parametric cubic equations, + +@noindent +x(u) = (1-u)^3 x0 + 3u (1-u)^2 x1 + 3u^2 (1-u) x2 + u^3 x3 +@noindent +y(u) = (1-u)^3 y0 + 3u (1-u)^2 y1 + 3u^2 (1-u) y2 + u^3 y3 . + +@end ifinfo + + +@table @code +@findex \clvec +@item \clvec (@var{x1} @var{y1})(@var{x2} @var{y2})(@var{x3} @var{y3}) +Draw a Bezier curve from the current position to the coordinate +@code{(@var{x3} @var{y3})} which becomes the new current position. The +coordinates @code{(@var{x1} @var{y1})} and @code{(@var{x2} @var{y2})} +serve as control points for the curve. Only the last coordinate given +is used to update the size of the drawing. +@end table +@noindent +Note that only 3 coordinate pairs are specified. The other point is the +current position before the @code{\clvec} command is executed. Only the +last coordinate specified in the @code{\clvec} command is used to +determine the extent of the drawing. While the Bezier curve passes +through the old current position and the new current position, in +general the curve will not reach the intermediate control points. The +curve is always entirely enclosed by the convex quadrilateral defined by +the two end points and the two control points. Note that the curve may +pass outside the limits of the drawing as determined by the end point of +the curve. + +A simple Bezier curve is produced by the following example. +@example +@group +\btexdraw + \move (0 0) + \clvec (0 1)(1 0)(1 1) +\etexdraw +@end group +@end example + +@iftex +This example is the rightmost of the following Bezier curves. The +drawings also show the end points and the control points for each curve. +@tex +\bigskip +\centertexdraw{ + \def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.08 0){#1} + \esegment} + \def\Rtext #1{\bsegment + \textref h:L v:C \htext (+0.08 0){#1} + \esegment} + \def\bdot {\fcir f:0 r:0.02 } + \def\Ldot #1{\bdot \Ltext{#1}} + \def\Rdot #1{\bdot \Rtext{#1}} + \move (-2 0) + \bsegment + \lpatt (0.033) + \move (0 0) \Ldot{0} \lvec (0 1) \Ldot{1} + \lvec (1 1) \Rdot{2} \lvec (1 0) \Rdot{3} + \lpatt () + \move (0 0) \clvec (0 1)(1 1)(1 0) + \esegment + \move (0 0) + \bsegment + \lpatt (0.033) + \move (0 0) \Ldot{0} \lvec (0.5 0.8) \Ldot{1} + \lvec (1.5 0.8) \Rdot{2} \lvec (1 0) \Rdot{3} + \lpatt () + \move (0 0) \clvec (0.5 1)(1.5 1)(1 0) + \esegment + \move ( 2 0) + \bsegment + \lpatt (0.033) + \move (0 0) \Ldot{0} \lvec (0 1) \Ldot{1} + \lvec (1 0) \Rdot{2} \lvec (1 1) \Rdot{3} + \lpatt () + \move (0 0) \clvec (0 1)(1 0)(1 1) + \esegment +} +@end tex +@end iftex + +@node Fill commands, , Bezier curves, TeXdraw Commands +@section Fill commands +@cindex filling regions +@cindex painting regions +@cindex paths + +PostScript deals with paths consisting of line segments. The paths can +be closed and the interior of the closed region filled. From +@TeX{}draw, paths start with a @code{\move} or @code{\rmove} command and +continue with @code{\lvec}, @code{\rlvec} or @code{\clvec} commands. +The @TeX{}draw fill commands close the path and fill the interior of the +closed region. Closing the path means that effectively another +@code{\lvec} line is drawn from the last point specified to the initial +point. @TeX{}draw provides two forms of the fill command. The +@code{\ifill} fills the interior of the region with the given gray +level. The lines defining the path are not drawn. The @code{\lfill} +command fills the region defined by the closed path and draws a line +along the enclosing path. Note for both forms of the fill command, the +gray level used for filling is opaque, even if the gray level is chosen +to be white. + +@table @code +@findex \lfill +@item \lfill f:@var{level} +Close the current path, draw the line around the path using the current +grey level for lines and paint the interior of the region with specified +gray level @var{level}. Gray levels are real values from 0 (black) +through intermediate values (grays) to 1 (white). +@findex \ifill +@item \ifill f:@var{level} +Close the current path and paint the interior of the region with gray +level @var{level}. The line around the path is not drawn. Gray levels +are real values from 0 (black) through intermediate values (grays) to 1 +(white). +@end table + +The following example draws a ``flag'' with the interior filled in. The +path around the boundary is given in a clockwise order to define a +closed path. We could take advantage of the fact that the fill command +will close an open path to eliminate one of the @code{\lvec} commands. +@example +@group +\centertexdraw@{ +\move (0.5 0) +\lvec (0 0.5) \clvec (0.5 0.85)(1 0.65)(1.5 1) +\lvec (2 0.5) \clvec (1.5 0.15)(1 0.35)(0.5 0) +\lfill f:0.8 +@} +@end group +@end example +@tex +\bigskip +\centertexdraw{ +\move (0.5 0) +\lvec (0 0.5) \clvec (0.5 0.85)(1 0.65)(1.5 1) +\lvec (2 0.5) \clvec (1.5 0.15)(1 0.35)(0.5 0) +\lfill f:0.8 +} +@end tex + +In @TeX{}draw, the @code{\move} command always terminates any previous +paths and starts a new path. Commands that change line parameters +(e.g@. @code{\setgray} or @code{\lpatt}) also terminate paths and start +new paths. The circle, ellipse and arc commands do not affect the +definition of the current path. The @code{\avec} command is not +appropriate for defining a path to be filled. It ends a subpath at its +tail and begins a new subpath at its tip. Filling a region defined by a +path with subpaths is more complicated in that each subpath is closed +before filling. + + +@node Drawing Segments and Scaling, Using TeXdraw with LaTeX, TeXdraw Commands, Top +@chapter Drawing Segments and Scaling + +@TeX{}draw provides individually scaled segments which can be used to +create relocatable drawing modules. + +@menu +* Drawing segments:: +* Drawing paths:: +* Saving positions:: +* Scaling coordinates:: +* Drawing size:: +* Initial current position:: +@end menu + +@node Drawing segments, Drawing paths, , Drawing Segments and Scaling +@section Drawing segments +@cindex segments +@cindex drawing segments + +A @TeX{}draw drawing segment allows for local modifications of +parameters and relative positioning. A @TeX{}draw segment is delimited +by a @code{\bsegment} command and an @code{\esegment} command. Inside +the segment, the initial current position is @code{(0 0)}. Any changes +to parameters such as the gray level and the line width, remain local to +the segment. Segments are implemented in @TeX{} using a +@code{\begingroup} and @code{\endgroup}. Segments can be nested. + +@table @code +@findex \bsegment +@item \bsegment +Start a drawing segment. The coordinate system is shifted such that the +current position corresponds to the coordinate @code{(0 0)}. Changes to +scaling, position and line parameters stay local to the drawing segment. +@findex \esegment +@item \esegment +End a drawing segment. The current position in effect before the +corresponding @code{\bsegment} command is restored. The scaling and +line parameter values revert to those in effect before the corresponding +@code{\bsegment} command was invoked. +@end table + +@node Drawing paths, Saving positions, Drawing segments, Drawing Segments and Scaling +@section Drawing paths +@cindex fill operations, interaction with drawing segments +@cindex paths +@cindex stroking lines +Certain subtle interactions occur between drawing segments and fill +operations. In PostScript, lines are drawn by first defining a path, +then later stroking the path to draw the line. In @TeX{}draw, this +stroking occurs when the line is terminated, say by a @code{\move} +command. PostScript paths are interrupted by, but continue after a +drawing segment. This means that a path started before a segment may +not be stroked (drawn) until after the segment ends. Consider the +following example. +@example +@group +\move (0 0) +\lvec (1 1) +\bsegment + \move (-0.25 -0.25) + \fcir f:0.8 r:0.5 +\esegment +\move (0 0) +@end group +@end example +A PostScript path is started at @code{(0 0)} and continues with a line +to @code{(1 1)}. This path is interrupted by the segment. The filled +circle is drawn next. After the segment, the path continues and is not +stroked until the @code{\move (0 0)} command after the end of the +segment. This means that the line appears on top of the filled region. + +If the fill operation is to cover the line, the path must be stroked +before the fill operation. From @TeX{}draw, the move commands +@code{\move} and @code{\rmove}, and the end @TeX{}draw command +@code{\etexdraw} terminate a path and cause it to be stroked. Within a +segment, the end segment command @code{\esegment} also terminates and +strokes a path. In the example above, the line can be stroked by +inserting a move command (such as a @code{\rmove (0 0)} which does not +affect the position), before the start of the segment. + +@node Saving positions, Scaling coordinates, Drawing paths, Drawing Segments and Scaling +@section Saving positions +@cindex saving positions +@cindex positions, saving +@cindex coordinate, symbolic +@cindex symbolic coordinate + +The @code{\savecurrpos} command saves the current position. The saved +position is an absolute position, not one relative to a segment. The +position saving mechanism is global; the position can be saved within a +nested segment and then used outside of the segment. The @var{x} and +@var{y} coordinates of the position are saved separately as named +coordinates. The names are of the form @code{*@var{name}}, with the +leading @code{*} being obligatory. A companion command, +@code{\savepos}, saves a given coordinate (relative to the current +segment) as an absolute symbolic position. + +@table @code +@findex \savecurrpos +@item \savecurrpos (*@var{px} *@var{py}) +Save the current position as the absolute position referenced by +@code{(*@var{px} *@var{py})}. +@findex \savepos +@item \savepos (@var{x} @var{y})(*@var{px} *@var{py}) +Save the coordinate position @code{(@var{x} @var{y})} as the absolute +position referenced by @code{(*@var{px} *@var{py})}. The coordinate +@code{(@var{x} @var{y})} is interpreted in the normal fashion as a +coordinate relative to the current segment, using the current scaling +factors and drawing unit. +@end table + +The symbolic names used to specify a saved position can consist of any +characters that are not special to @TeX{}, but must start with a +@code{*} character. The symbolic names can be used as the @var{x} +and/or @var{y} coordinate in any command that needs a coordinate. +Symbolic coordinates are not normally used with relative motion commands +such as @code{\rlvec} or @code{\rmove}. If used with relative motion, +the corresponding displacement is equal to the symbolic coordinate +value. + +On exit from a segment, the position and graphics state on entry is +restored. Any changes to line types, scaling and position are +discarded. However, it is sometimes useful alter the position on exit +from a segment. The @code{\savepos} command allows for the saving of a +position within the segment. This position can be restored after the +@code{\esegment} with a @code{\move} command using the saved symbolic +position. This approach can be used to build modules which operate in a +manner analogous to the basic relative motion line vector commands. + +The following example defines a macro which draws a box 0.75 inches wide +by 0.5 inches high containing centered text. On leaving the macro the +position will be set at a point on the righthand side of the box. +@example +@group +\def\tbox #1@{\bsegment + \lvec (0 +0.25) \lvec (0.75 +0.25) + \lvec (0.75 -0.25) \lvec (0 -0.25) \lvec (0 0) + \textref h:C v:C \htext (0.375 0)@{#1@} + \savepos (0.75 0)(*ex *ey) + \esegment + \move (*ex *ey)@} +@end group +@end example +With this definition, we can treat @code{\tbox} in the same way as the +basic vector commands, stringing them together to form a block diagram +as in this example. +@example +@group +\centertexdraw@{ + \ravec (1 0) \tbox@{$H(z)$@} \ravec (1 0) +@} +@end group +@end example +@tex +\def\tbox #1{\bsegment + \lvec (0 +0.25) \lvec (0.75 +0.25) + \lvec (0.75 -0.25) \lvec (0 -0.25) \lvec (0 0) + \textref h:C v:C \htext (0.375 0){#1} + \savepos (0.75 0)(*ex *ey) + \esegment + \move (*ex *ey)} +\bigskip +\centertexdraw{ + \ravec (1 0) \tbox{$H(z)$} \ravec (1 0) +} +@end tex + +@node Scaling coordinates, Drawing size, Saving positions, Drawing Segments and Scaling +@section Scaling coordinates +@cindex scaling coordinates +@cindex relative scaling +@cindex segment scale +@cindex unit scale + +There are two scale factors available, the unit scale factor and the +segment scale factor. The overall scale factor is the product of these +two. There are absolute and relative versions of commands to change +these scale factors. + +The unit scale factor is normally used to affect global scale changes. +Changes to the unit scale factor remains local to a segment, but +propagate to inferior segments. The default value is unity. + +The segment scale factor is used for local scale changes. It remains +local to a segment. The segment scale factor is reset to unity on entry +into each segment. This means that changes to the segment scale factor +do not propagate to inferior segments. + +@table @code +@findex \setunitscale +@item \setunitscale @var{scale} +Set the unit scaling to @var{scale}. The argument @var{scale} is a real +number which is used to scale coordinate values. The overall scaling +factor is the product of the unit scale factor and the segment scale +factor. +@findex \relunitscale +@item \relunitscale @var{value} +Adjust the unit scale factor by multiplying by @var{value}. This has +the effect of multiplying the overall scale factor by the same factor. +The overall scaling factor is the product of the unit scale factor and +the segment scale factor. +@findex \setsegscale +@item \setsegscale @var{scale} +Set the segment scale factor. The argument @var{scale} is a real number +which is used to scale coordinate values. The overall scale factor is +the product of the unit scale factor and the segment scale factor. +@findex \relsegscale +@item \relsegscale @var{value} +Adjust the segment scale factor by multiplying by @var{value}. This has +the effect of multiplying the current overall scale factor by the same +factor. The overall scaling factor is the product of the unit scale +factor and the segment scale factor. +@end table + +In addition to the unit scale factor and the segment scale factor, the +scaling can be controlled by the choice of drawing units with the +command @code{\drawdim} (@pxref{Coordinate specification}). + +@table @code +@item \drawdim cm \setunitscale 2.54 +Set the units to centimetres scaled by 2.54. Together these commands +are effectively the same as @code{\drawdim in}. +@end table + +The segment scale can be used to allow scale changes in segments so that +values are in more convenient units. For example suppose dimensions in +a segment are multiples of one third of an inch. The segment scale can +be set once to make 1 drawing unit equal 0.3333 inches. From that point +on, coordinates can be specified with integer values. + +The following example defines a macro to draw a rectangular box which is +twice as wide as it is high. The width is specified as an argument. +@example +@group +\def\mybox #1@{\bsegment + \setsegscale #1 + \lvec (0 +0.25) \lvec (1 +0.25) \lvec (1 -0.25) + \lvec (0 -0.25) \lvec (0 0) + \esegment@} +@end group +@end example + +@node Drawing size, Initial current position, Scaling coordinates, Drawing Segments and Scaling +@section Drawing size +@cindex size of the drawing + +The effective size of the drawing is determined by the maximum +excursions of the coordinates supplied to @TeX{}draw commands. The +minimum and maximum scaled @var{x} and @var{y} coordinates are tallied. +Note that @code{\move} commands contribute to the determination of the +calculated size of the drawing, even though they do not generate visible +lines. The circle and ellipse commands add a compensation for the radii +of circles and ellipses. The final @TeX{}draw drawing is placed in a +@TeX{} box with lower lefthand corner corresponding to +@code{(}@var{x}-min @var{y}-min@code{)} and upper righthand corner at +@code{(}@var{x}-max @var{y}-max@code{)}. + +Text generated by @code{\htext}, @code{\vtext} or @code{\rtext} can +spill outside the box as determined above. Only the text reference +point is guaranteed to be in the drawing box. Arcs can also spill +outside the drawing box. Note also that the widths of lines, and the +sizes of arrowheads do not affect the size of the drawing. The +calculated size of the drawing will never be larger than the actual size +of the drawing. In extreme cases in which text or lines extend far +outside the drawing, extra @code{\move} commands should be used to +establish the size of the drawing so that the @TeX{}draw box includes +all of the drawing. + +@TeX{}draw provides the @code{\drawbb} command to draw a box which +indicates the effective size of the drawing. Whenever @code{\drawbb} is +invoked, a ruled box is drawn around the drawing as it has been sized up +to that point. Normally @code{\drawbb} is invoked just before the end +of a drawing to indicate the effective size of the final drawing. + +@table @code +@findex \drawbb +@item \drawbb +Draw a ruled box around the effective size of a drawing produced by +@TeX{}draw commands. +@end table + +@node Initial current position, , Drawing size, Drawing Segments and Scaling +@section Initial current position +@cindex current position +@cindex initial current position + +The first operation in a drawing should be a move to establish the +current position. The current position can be established explicitly +through a @code{\move} command or a text positioning command such as +@code{\htext} with a coordinate. However, if an attempt is made to use +a drawing command which needs a current position and none has been +established, @TeX{}draw implicitly sets the initial current position to +@code{(0 0)}. The size of the @TeX{}draw figure is normally determined +from the sequence of coordinates specified, but will include the +implicit initial position in case another initial position has not been +explicitly specified. + +@node Using TeXdraw with LaTeX, More Details, Drawing Segments and Scaling, Top +@chapter Using @TeX{}draw with La@TeX{} +@cindex accessing @TeX{}draw +@cindex invoking @TeX{}draw +@cindex La@TeX{} +@cindex @code{texdraw} package + +The La@TeX{} typesetting system uses a structured approach to declaring +typesetting environments. For La@TeX{}2e, the @code{texdraw} package +defines the @code{texdraw} environment. The @TeX{}draw environment is +started with a @code{\begin@{texdraw@}} command and terminated with an +@code{\end@{texdraw@}} command. All of the basic @TeX{}draw commands +can be used within the @code{texdraw} environment. + +As an example, a La@TeX{}2e variant of an earlier example can be +constructed as follows. +@example +@group +\documentclass@{article@} +\usepackage@{texdraw@} + ... +\begin@{document@} + ... +\newcommand@{\tbox@}[1]@{% + \bsegment + \lvec (0 +0.25) \lvec (0.75 +0.25) + \lvec (0.75 -0.25) \lvec (0 -0.25) \lvec (0 0) + \textref h:C v:C \htext (0.375 0)@{#1@} + \savepos (0.75 0)(*ex *ey) + \esegment + \move (*ex *ey)@} +\begin@{center@} +\begin@{texdraw@} + \ravec (1 0) \tbox@{$H(z)$@} \ravec (1 0) +\end@{texdraw@} +\end@{center@} + ... +\end@{document@} +@end group +@end example + +This example illustrates the use of the La@TeX{} command +@code{\newcommand} as an alternative to the plain @TeX{} command +@code{\def}. Instead of the basic @TeX{}draw command +@code{\centertexdraw}, a nested combination of the La@TeX{} centering +environment and the @TeX{}draw environment is used. + +@menu +* PostScript printer drivers:: +@end menu + +@node PostScript printer drivers, , , Using TeXdraw with LaTeX +@section PostScript printer drivers +@cindex printer drivers +@cindex PostScript printer drivers + +@cindex @code{graphics} package +The @code{texdraw} package uses the printer driver interface provided by +the standard La@TeX{}2e @code{graphics} package. Any options to the +@code{texdraw} package are passed to the @code{graphics} package. +Specifically, the name of the PostScript driver to be used can be +specified as an option to the @code{texdraw} package. With no explicit +printer driver option, the default printer driver associated with the +@code{graphics} package is used. + +@cindex @code{dvips} printer driver +@cindex @code{xdvi} driver +@cindex @code{dvi2ps} printer driver +@cindex @code{dvialw} printer driver +@cindex @code{dvilaser} printer driver +@cindex @code{dvipsone} printer driver +@cindex @code{dviwindo} printer driver +@cindex @code{dvitops} printer driver +@cindex @code{oztex} printer driver +@cindex @code{psprint} driver +@cindex @code{textures} printer driver +@cindex @code{pctexps} printer driver +@cindex @code{pctexwin} printer driver +@cindex rotated text +@cindex text rotation +The @code{texdraw} package can be used with any of the printer drivers +supported by the @code{graphics} package that allow for the importation +of PostScript graphics files, viz., @code{dvips}, @code{xdvi}, +@code{dvi2ps}, @code{dvialw}, @code{dvilaser}, @code{dvipsone}, +@code{dviwindo}, @code{dvitops}, @code{oztex}, @code{psprint}, +@code{textures}, @code{pctexps}, and @code{pctexwin}. Not all of these +drivers support the text rotation needed for the @TeX{}draw commands +@code{\vtext} and @code{\rtext}. Of the drivers listed above, only the +following support support text rotation: @code{dvips}, @code{xdvi}, +@code{dvi2ps}, @code{dvitops}, @code{textures}, and @code{pctexps}. + + +@node More Details, PostScript Commands, Using TeXdraw with LaTeX, Top +@chapter More Details + +The first part of this chapter offers some suggestions for strategies to +isolate errors in @TeX{} and @TeX{}draw input. The second part of this +chapter discusses implementational issues. An awareness of these issues +is useful if @TeX{}draw is to be extended. + +@menu +* Errors while using TeXdraw:: +* Extending TeXdraw:: +* How TeXdraw merges graphics and text:: +@end menu + +@node Errors while using TeXdraw, Extending TeXdraw, , More Details +@section Errors while using @TeX{}draw +@cindex problems while using @TeX{}draw +@cindex errors while using @TeX{}draw + +@TeX{} input is notoriously difficult to debug. If @TeX{} reports +errors, so much the better. If the cause is not immediately obvious, +consider using a binary search strategy, removing sections of code with +the premature insertion of the @code{\bye} (or @code{\end@{document@}} +for La@TeX{}) command (with the appropriate closing of any open groups +and the like). Other strategies include the insertion of +@code{\message@{I am here@}} at appropriate places. Try using +@code{\tracingmacros=1}. Many problems turn out to be due to an +incorrect number of macro arguments or incorrectly delimited macro +arguments. The @code{\tracingmacros=1} option writes the macro +arguments and macro expansions to the @TeX{} log file. + +Certain errors may not manifest themselves until well after the +offending command. For instance, if a closing parenthesis is missing +from a @TeX{}draw coordinate, @TeX{} continues searching for the +parenthesis. If one is found, perhaps many lines later, the @TeX{}draw +error message @code{invalid coordinate} will be printed at this later +point. + +All input in the @TeX{}draw environment should be intended for +interpretation by @TeX{}draw commands. @TeX{}draw places text inside a +zero size box (the text itself extends outside the box). Extraneous +input manifests itself as a non-zero size @TeX{}draw text box. This +causes the @TeX{}draw text and the PostScript graphics to be displaced +from one another. An error message is issued if a non-zero width +@TeX{}draw text box is detected. If this error message appears, look +for unintended character sequences amongst the commands to @TeX{}draw. + +Several @TeX{}draw commands pass their arguments ``raw'' to the +PostScript file. That means that invalid arguments can generate +PostScript errors when the document is printed. For instance the +argument of the @code{\setgray} command is passed straight through to +the PostScript file. If this argument is non-numeric, a PostScript +error results. Not all PostScript printers report errors back to the +user. The print may just stop prematurely. One approach to debugging +is to use a PostScript previewer on a workstation. That way, one can +determine at which point in the drawing the PostScript error occurs. + +@node Extending TeXdraw, How TeXdraw merges graphics and text, Errors while using TeXdraw, More Details +@section Extending @TeX{}draw +@cindex implementation + +@TeX{}draw is implemented using a combination of @TeX{} commands and +PostScript code. This section discusses some of the implementational +issues as they relate to extending @TeX{}draw. + +@TeX{}draw as implemented, offers a basic set of drawing features. +These are adequate for certain tasks such as producing block diagrams. +There are different approaches to extending @TeX{}draw to include other +functions. In some cases, the desired functionality can be achieved by +writing a @TeX{} macro which builds on top of the existing @TeX{}draw +commands. As these extensions become more complex, the limitations of +@TeX{} for computations become increasingly evident. In other cases, +access to different features of PostScript is desired. The appropriate +approach would be to write new PostScript procedures which can be +accessed by @TeX{} macros. + +Included with @TeX{}draw is a set of macros for directly accessing +PostScript functions. These are described in an appendix +(@pxref{PostScript Commands}). + +@TeX{}draw also comes with a toolbox of routines for handling much of +the user interface, converting between different coordinate +representations and the like. The macros for coordinate decoding and +for computations involving coordinates are described in an appendix +(@pxref{TeXdraw Toolbox, , @TeX{}draw Toolbox}). + +@menu +* Scaling:: +* Resolution:: +* Text placement:: +* Intermediate PostScript file:: +@end menu + +@node Scaling, Resolution, , Extending TeXdraw +@subsection Scaling +@cindex scaling + +The scaling commands provided in @TeX{}draw are designed to affect only +the coordinate values specified in commands. For instance, changing the +@code{\setunitscale} value changes the interpretation of the coordinate +in an @code{\avec (@var{x} @var{y})} command, but does not change the +line width or arrowhead sizes in effect. None of the @TeX{}draw scaling +commands affect the size of @TeX{} text produced by, for instance, the +@code{\htext} command. Scale changes will however affect the +positioning of text for subsequent commands. + +The line parameters are changed only if the corresponding commands to +change them are issued. If the @code{\linewd} command is given, the +current coordinate scaling is used to determine the line width. To +achieve a behaviour more like a global scaling, whenever the scale +factor is changed, the line parameters should be set again. + +@node Resolution, Text placement, Scaling, Extending TeXdraw +@subsection Resolution +@cindex resolution + +@TeX{}draw scales coordinates before passing them to PostScript. +Keeping track of the coordinate scaling is necessary, in any event, to +allow @TeX{}draw to compute the maximum excursions of the coordinates. +@TeX{}draw uses pixel units in its PostScript code. One pixel unit is +equal to 1/300 of an inch. @TeX{}draw issues PostScript commands with +integer valued pixel coordinates. This sets the positioning resolution +for @TeX{}draw. The passing of integer valued coordinates which +correspond to the device resolution keeps lines aligned with the device +grid; parallel lines of the same width will be rendered with the same +width. + +The position saving mechanism in @TeX{}draw (@pxref{Saving positions}) +associates the pixel coordinates of a position with the specified name. + +@TeX{}draw uses the limited real number representation provided by +@TeX{}. These operations are based on the representation of dimensions +as real-valued numbers of points. Internally in @TeX{}, dimensions are +stored 32-bit values, normalized so that 1 pt corresponds to the scaled +point (sp) value of 65536. Dimensions with magnitudes between 0.000015 +pt and 32767 pt can be represented. This is also the dynamic range of +the @TeX{}draw pixel coordinates passed to PostScript. @TeX{}draw must +convert from user supplied coordinates using the scaling factor (which +itself consists of two components, the unit scale and the segment scale) +and a pixel conversion factor. The use of limited precision real +numbers in these computations can cause accumulation of error when +relative scaling is used repeatedly. + +@node Text placement, Intermediate PostScript file, Resolution, Extending TeXdraw +@subsection Text placement + +While in the @TeX{}draw environment, @TeX{} text is placed in a @TeX{} +box while PostScript code is written to the intermediate file. At the +end of the @TeX{}draw environment, the size of the drawing is +determined. A @TeX{} box of this size is created. The @TeX{} +@code{\special} mechanism is used to instruct the PostScript driver +program to position the PostScript drawing from the intermediate file in +this area. Next, the text generated by @TeX{}draw is positioned and +placed in the box. Note that when the document is printed, the +PostScript drawing is placed on the page before the @TeX{} text; @TeX{} +text will appear on top of graphics. + +@cindex rotated text +@cindex text rotation +The rotation of text is carried out with in-line PostScript code which +does not appear in the intermediate PostScript file. This code is sent +to the PostScript driver with a @code{\special} command. This +PostScript code is embedded in the dvi (device independent) file that +@TeX{} produces. + +@node Intermediate PostScript file, , Text placement, Extending TeXdraw +@subsection The intermediate PostScript file +@cindex Encapsulated PostScript File + +The intermediate PostScript file consists of a header, a body and a +trailer following Encapsulated PostScript File (EPSF) standards. The +header sets up PostScript definitions and default parameter values. The +trailer includes the @code{BoundingBox} information which gives the +coordinates in default PostScript units (72 per inch) for the lower +lefthand corner and the upper righthand corner of the drawing. The body +of the intermediate PostScript file contains the PostScript commands +generated by @TeX{}draw. + +Many moves in @TeX{}draw serve only to position text or to reset saved +positions. @TeX{}draw buffers move commands in order to be able to +collapse runs of moves. Only the last move of a run of moves is +actually written to the PostScript file. However the intermediate moves +still affect the size of the drawing. The expunging of moves means that +the PostScript file @code{BoundingBox} information may indicate a drawing size +larger than the PostScript commands themselves would warrant. + +Drawing segments in @TeX{}draw show up in the PostScript file as saves +and restores of the PostScript graphics state. Segment starts are +buffered and only written out if necessary. This way ``empty'' segments +do not generate output to the PostScript file. These empty segments +arise if a segment contains only moves and text commands. The moves +inside the segment are not needed since they are local to the segment, +and the text commands do not generate output to the PostScript file. + +If @TeX{}draw is used only for moves and text, no intermediate +PostScript file will be created. + +@node How TeXdraw merges graphics and text, , Extending TeXdraw, More Details +@section How @TeX{}draw merges graphics and text +@cindex graphics placement +@cindex text placement +@cindex placement of graphics and text + +@TeX{}draw creates a box which is the same size as the graphic. The +printer driver will place the PostScript graphic into this space. Any +@TeX{} text generated by the @TeX{}draw commands will be superimposed on +this graphic. + +@cindex @code{texdraw} package +@cindex @code{graphics} package +The La@TeX{}2e front-end for @TeX{}draw is enabled by including the +@code{texdraw} package. The @code{texdraw} package automatically +invokes the standard @code{graphics} package distributed with +La@TeX{}2e. The @code{graphics} package has support for a number of +different printer drivers, including a number for PostScript printers. +Any options to the @code{texdraw} package are passed on to the +@code{graphics} package. Such an option can be used to select a driver +other than the default one. + +@cindex PostScript printer drivers +@cindex printer drivers +@cindex @code{dvips} printer driver +@cindex rotated text +@cindex text rotation +Within the @code{graphics} package, the driver option is used to select +definitions for the low-level macros which generate the @code{\special} +commands needed to request insertion of a graphics file and to rotate +text.@footnote{Not all PostScript drivers support text rotation.} +@TeX{}draw uses the user-level macros defined by the @code{graphics} +package (@pxref{PostScript printer drivers}). When not used with the +La@TeX{}2e front-end, @TeX{}draw defines versions of these macros that +are suitable for use with the @code{dvips} printer driver. + +@node PostScript Commands, TeXdraw Toolbox, More Details, Top +@appendix PostScript Commands +@cindex PostScript commands + +This appendix describes a set of macros for accessing some of the +PostScript builtin functions. Each of these macros issues a single +PostScript command. The extra services provided by @TeX{}draw are the +interpretation of coordinates in user units relative to the current +drawing segment and the writing of a pending @TeX{}draw move to the +PostScript file. This last operation establishes the current point in +PostScript. The user of these commands should be familiar with the +concepts of path construction and filling in PostScript. Further +details on the PostScript functions used can found in the +@cite{PostScript Language Reference Manual, Second Edition}, Adobe +Systems, Addison-Wesley, 1990. + +These macros are distributed in file @file{txdps.tex}. + +The @code{\PSsetlinecap} and @code{\PSsetlinejoin} commands control the +way line ends and line joins are rendered. The default values set by +@TeX{}draw (round caps and round join) are appropriate for most +drawings. Changes to these parameters apply to the current and +subsequent paths. + +@cindex line cap +@cindex line join +@table @code +@findex setlinecap +@findex \PSsetlinecap +@item \PSsetlinecap @var{type} +Set the line cap parameter. The value @code{0} gives a butt cap; +@code{1} gives a round cap; and @code{2} gives a projecting square cap. +The initial value is corresponds to a round cap. +@findex setlinejoin +@findex \PSsetlinejoin +@item \PSsetlinejoin @var{type} +Set the line join parameter. The value @code{0} gives a miter join; +@code{1} gives a round join; and @code{2} gives a bevel join. The +initial value corresponds to a round join. +@end table + +@cindex stroking lines +@cindex filling regions +@cindex paths +@cindex current position in PostScript +PostScript paths and fill operations can be controlled by a number of +functions. By design, @TeX{}draw always maintains a defined PostScript +current point. Some of the following macros cause the PostScript +current point to become undefined. The PostScript current point must be +set again (say with a @code{\PSmoveto} command) before invoking basic +@TeX{}draw commands. +@table @code +@findex stroke +@findex \PSstroke +@item \PSstroke +Stroke a PostScript path. The current path is stroked with the current +gray level (set with @code{\setgray}) and the current line pattern (set +with @code{\lpatt}). The PostScript current point becomes undefined. +@findex newpath +@findex \PSnewpath +@item \PSnewpath +Establish a new path. The PostScript current point becomes undefined. +@findex closepath +@findex \PSclosepath +@item \PSclosepath +Close a subpath. A new subpath is started. +@findex fill +@findex \PSfill +@item \PSfill +Fill a region defined by a path. Each subpath is closed and the +enclosed regions painted with the current gray level. The PostScript +current point becomes undefined. The gray level can be set with the +@TeX{}draw command @code{\setgray}. +@end table + +The following line commands interpret coordinates relative to the +current @TeX{}draw scaling and drawing segment. The specified +coordinate affects the drawing size as determined by @TeX{}draw. +@cindex lines +@cindex moves +@table @code +@findex lineto +@findex \PSlineto +@item \PSlineto (@var{x} @var{y}) +Add a line segment to the current path. This command is identical to +the @TeX{}draw command @code{\lvec}. The PostScript current point must +be defined before this command is issued. +@findex moveto +@findex \PSmoveto +@item \PSmoveto (@var{x} @var{y}) +Move to the coordinate specified by @code{(@var{x} @var{y})}. The +PostScript current point becomes defined. +@end table + +The following macros provide access to the general arc commands in +PostScript. The coordinates are interpreted relative to the current +@TeX{}draw scaling and drawing segment. The specified coordinate +affects the drawing size as determined by @TeX{}draw. +@cindex arcs +@table @code +@findex arc +@findex \PSarc +@item \PSarc r:@var{radius} sd:@var{start-angle} ed:@var{end-angle} (@var{x} @var{y}) +Draw a counterclockwise arc. The center of the arc is at the given +position. The radius is specified by @var{radius}. The start and end +angles (in degrees) are specified by @var{start-angle} and +@var{end-angle}. If the PostScript current point is defined, this +command also draws the line from the current point to the beginning of +the arc. The line and arc become part of the current path. The current +point becomes defined. +@findex arcn +@findex \PSarcn +@item \PSarcn r:@var{radius} sd:@var{start-angle} ed:@var{end-angle} (@var{x} @var{y}) +Draw a clockwise arc. The center of the arc is at the given position. +The radius is specified by @var{radius}. The start and end angles (in +degrees) are specified by @var{start-angle} and @var{end-angle}. If the +PostScript current point is defined, this command also draws the line +from the current point to the beginning of the arc. The line and arc +become part of the current path. The current point becomes defined. +@end table + +The macro @code{\writeps} provides the general facility to write +arbitrary PostScript commands to the PostScript file. This macro is +used by the preceding commands and by the @TeX{}draw commands +themselves. This facility has to be used with care since changes in +position or scaling resulting from the PostScript commands are not known +to @TeX{}draw. +@table @code +@findex \writeps +@item \writeps @{@var{<ps-commands>}@} +Write PostScript commands to the intermediate PostScript file. Before +the commands are inserted, any pending @TeX{}draw move is written to the +PostScript file. The PostScript scaling gives 300 units/inch. +@end table + + +@node TeXdraw Toolbox, Examples, PostScript Commands, Top +@appendix @TeX{}draw Toolbox + +This appendix describes some of the macros supplied with @TeX{}draw +which can be used to define additional commands for creating drawings. +The macros described here work in the user specified coordinate system. +Some of these toolbox macros are used by the @TeX{}draw commands +themselves, others are supplied in an auxiliary file +@file{txdtools.tex}. + +@menu +* Coordinate parsing:: +* Real arithmetic:: +* Arrow curve:: +@end menu + +@node Coordinate parsing, Real arithmetic, , TeXdraw Toolbox +@appendixsec Coordinate parsing + +The coordinate parsing macro @code{\getpos} is useful for creating new +commands. This macro takes care of stripping leading and trailing +blanks from coordinates specified between parentheses. In addition, +symbolic coordinates are translated to the corresponding relative +coordinate using the segment offset and scaling in effect. + +The macro @code{\currentpos} returns the relative coordinates of the +current position. The returned values are relative to the current +segment and the current scaling. The macro @code{\cossin} returns the +real-valued cosine and sine of the direction of the line joining two +points. The macro @code{\vectlen} returns the length of a vector. The +results appear as the value of user supplied macro names. + +@cindex coordinate parsing +@cindex current position +@cindex angle of a vector +@cindex direction of a line +@cindex cosine of a vector direction +@cindex sine of a vector direction +@cindex length of a vector +@table @code +@findex \getpos +@item \getpos (@var{x} @var{y})\@var{mx}\@var{my} +Decode coordinate values. The coordinates specified by @code{(@var{x} +@var{y})} are decoded. Symbolic coordinates are translated to the +corresponding relative coordinate using the current segment offset and +scaling. The resulting character strings representing the real-valued +coordinates are assigned to the macros specified by @code{\@var{mx}} and +@code{\@var{my}}. +@findex \currentpos +@item \currentpos \@var{mx}\@var{my} +Return the coordinates of the current position. The coordinates are +relative to the current segment offset and scaling. The resulting +character strings representing the real-valued coordinates are assigned +to the macros specified by @code{\@var{mx}} and @code{\@var{my}}. +@findex \cossin +@item \cossin (@var{x1} @var{y1})(@var{x2} @var{y2})\@var{cosa}\@var{sina} +Return the cosine and sine of the direction of a vector joining two +points. The cosine and sine of the angle of the vector which goes from +@code{(@var{x1} @var{y1})} to @code{(@var{x2} @var{y2})}. The character +strings representing these real-valued quantities are assigned to the +macros specified by @code{\@var{cosa}} and @code{\@var{sina}}. +@findex \vectlen +@item \vectlen (@var{x1} @var{y1})(@var{x2} @var{y2})\@var{len} +Return the length of a vector joining two points. The length of the +vector is relative to the current scaling. The character string +representing the real-valued length is assigned to the macro specified +by @code{\@var{len}}. +@end table + +@node Real arithmetic, Arrow curve, Coordinate parsing, TeXdraw Toolbox +@appendixsec Real arithmetic + +The @TeX{}draw toolbox supplies macros to perform real arithmetic on +coordinate values. The result appears as the value of a user supplied +macro name. +@table @code +@findex \realadd +@item \realadd @{@var{value1}@} @{@var{value2}@} \@var{sum} +Add two real quantities, assigning the resultant character string +representing the sum to the macro @code{\@var{sum}}. +@findex \realmult +@item \realmult @{@var{value1}@} @{@var{value2}@} \@var{prod} +Multiply two real quantities, assigning the resultant character string +representing the product to the macro @code{\@var{prod}}. +@findex \realdiv +@item \realdiv @{@var{value1}@} @{@var{value2}@} \@var{result} +Divide two real quantities, assigning the resultant character string +representing the result of @var{value1}/@var{value2} to the macro +@code{\@var{result}}. +@end table + +@node Arrow curve, , Real arithmetic, TeXdraw Toolbox +@appendixsec Arrow curve +@cindex example, arrow curve + +This example illustrates the use of the @TeX{}draw toolbox routines to +do computations with the coordinates. The problem will be tackled in +two parts. First, we will produce a macro to place an arrowhead on a +Bezier curve. Then given this macro, we will produce a macro which can +draw a ``wiggly'' line from the current position to a given coordinate. + +@tex +\bigskip +\def\cavec (#1 #2)(#3 #4)(#5 #6){ + \clvec (#1 #2)(#3 #4)(#5 #6) + \cossin (#3 #4)(#5 #6)\cosa\sina + \rmove (0 0) % stroke the Bezier curve + \bsegment + \drawdim in \setsegscale 0.05 + \move ({-\cosa} -\sina) \avec (0 0) + \esegment} + +\def\caw (#1 #2){ + \currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + +% The nominal wiggly curve is (0 0) (1+dx dy) (-dx -dy) (1 0) +% Find the rotated offset (dx dy) -> (du dv) + \rotatecoord (0.4 0.1)\cosa\sina \du\dv + +% calculate the length of the vector + \vectlen ({\xa} \ya)(#1 #2)\len + +% draw the curve in normalized units + \bsegment + \setsegscale {\len} + \realadd \cosa \du \tmpa \realadd \sina \dv \tmpb + \cavec ({\tmpa} \tmpb)({-\du} -\dv)({\cosa} \sina) + \esegment + + \move (#1 #2)} + +% rotate a coordinate (x y) +% arguments: (x y) cosa sina x' y' +% x' = cosa * x - sina * y; y' = sina * x + cosa * y +\def\rotatecoord (#1 #2)#3#4#5#6{ + \getpos (#1 #2)\xarg\yarg + \realmult \xarg {#3} \tmpa \realmult \yarg {#4} \tmpb + \realadd \tmpa {-\tmpb} #5 + \realmult \xarg {#4} \tmpa \realmult \yarg {#3} \tmpb + \realadd \tmpa \tmpb #6} + +\centertexdraw{ + \arrowheadtype t:W + \move (0 0) + \cavec (1.4 0.1)(-0.4 -0.1)(1 0) + \move (1 0) \caw (1 1) \htext{tip at \tt (1 1)} + \move (1 0) \caw (2 1) \htext{tip at \tt (2 1)} + \move (1 0) \caw (2 0) \htext{tip at \tt (2 0)} + \move (0 1.13) \move (0 -0.04) +} +@end tex + +The first macro, @code{\cavec}, uses the @code{\cossin} command to +determine the the cosine and sine of the angle of the line joining the +second control point to the end point of the Bezier curve. Recall that +the Bezier curve is tangent to this line at the end point. After +drawing the Bezier curve, the scaling is set locally to absolute units +of 0.05 inches. We go back down the line from the end point by 0.05 +inches and draw an arrow vector to the end point from there. This arrow +vector is mostly arrowhead, with little or no tail. + +@example +@group +\def\cavec (#1 #2)(#3 #4)(#5 #6)@{ + \clvec (#1 #2)(#3 #4)(#5 #6) + \cossin (#3 #4)(#5 #6)\cosa\sina + \rmove (0 0) + \bsegment + \drawdim in \setsegscale 0.05 + \move (@{-\cosa@} -\sina) \avec (0 0) + \esegment@} +@end group +@end example + +Note the use of macros as arguments to a @code{\move} command. Minus +signs are put in front of the macros. However, the value of the macro +@code{\cosa} or @code{\sina} could be negative. Fortunately, @TeX{} +accepts two minus signs in a row and interprets the result as positive. +Note that the @code{\rmove (0 0)} command before the beginning of the +segment ensures that the Bezier curve is stroked before the arrowhead is +drawn. + +The second macro @code{\caw} builds on @code{\cavec}. The goal is to +produce a wiggly vector that can be used as a pointer in a drawing. +Consider the following symmetrical normalized Bezier curve. +@example +\centertexdraw@{ \move (0 0) \cavec (1.4 0.1)(-0.4 -0.1)(1 0) @} +@end example + +This curve has the appropriate wiggle. Now we want to be able to draw +this curve, appropriately scaled and rotated. The macro @code{\caw} +needs to do computations on the coordinates. First, @code{\caw} uses +the macros @code{\getpos} and @code{\currentpos} to get the positions of +the end and start of the curve. Next, the length of the vector is +calculated using the macro @code{\vectlen}. A local macro +@code{\rotatecoord} is used to rotate a coordinate pair about the +origin, using the cosine and sine of the rotation angle. The vector +length is used to scale the normalized curve. The remaining code draws +the rotated, normalized curve. + +@example +\def\caw (#1 #2)@{ + \currentpos \xa\ya + \cossin (@{\xa@} \ya)(#1 #2)\cosa\sina + +% The nominal wiggly curve is (0 0) (1+dx dy) (-dx -dy) (1 0) +% Find the rotated offset (dx dy) -> (du dv) + \rotatecoord (0.4 0.1)\cosa\sina \du\dv + +% calculate the length of the vector + \vectlen (@{\xa@} \ya)(#1 #2)\len + +% draw the curve in normalized units + \bsegment + \setsegscale @{\len@} + \realadd \cosa \du \tmpa \realadd \sina \dv \tmpb + \cavec (@{\tmpa@} \tmpb)(@{-\du@} -\dv)(@{\cosa@} \sina) + \esegment + \move (#1 #2)@} + +% rotate a coordinate (x y) +% arguments: (x y) cosa sina x' y' +% x' = cosa * x - sina * y; y' = sina * x + cosa * y +\def\rotatecoord (#1 #2)#3#4#5#6@{ + \getpos (#1 #2)\xarg\yarg + \realmult \xarg @{#3@} \tmpa \realmult \yarg @{#4@} \tmpb + \realadd \tmpa @{-\tmpb@} #5 + \realmult \xarg @{#4@} \tmpa \realmult \yarg @{#3@} \tmpb + \realadd \tmpa \tmpb #6@} +@end example + +Finally, the new macro can be used as follows. +@example +\centertexdraw@{ + \arrowheadtype t:W + \move (0 0) + \cavec (1.4 0.1)(-0.4 -0.1)(1 0) + \move (1 0) \caw (1 1) \htext@{tip at \tt (1 1)@} + \move (1 0) \caw (2 1) \htext@{tip at \tt (2 1)@} + \move (1 0) \caw (2 0) \htext@{tip at \tt (2 0)@} + +@} +@end example + +Note that the Bezier curve in the macro @code{\cavec} lies below the +arrowhead. The example then draws an arrowhead of type @code{W} to +erase the part of the line below the arrowhead. + +@node Examples, Command Listing, TeXdraw Toolbox, Top +@appendix Examples +@cindex example, block diagram + +This appendix shows examples of the use of @TeX{}draw. + +@menu +* Block diagram:: +* Filter response graph:: +* Geometric construction:: +@end menu + +@node Block diagram, Filter response graph, , Examples +@appendixsec Block diagram of a lattice filter + +The block diagram of a lattice filter uses a library of extended +commands built from the basic @TeX{}draw commands. + +@tex +\bigskip +\bigskip +\def\delay {\bsegment + \setsegscale 0.3 + \lvec (0 +0.5) \lvec (1 +0.5) \lvec (1 -0.5) + \lvec (0 -0.5) \lvec (0 0) + \textref h:C v:C \htext (0.5 0){$z^{-1}$} + \savepos (1 0)(*ex *ey) + \esegment + \move (*ex *ey)} +\def\bdot {\fcir f:0 r:0.02 } +\def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 +0.06){#1} + \esegment} +\def\Btext #1{\bsegment + \textref h:C v:T \htext (0 -0.06){#1} + \esegment} +\def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.06 0){#1} + \esegment} +\def\Rtext #1{\bsegment + \textref h:L v:C \htext (+0.06 0){#1} + \esegment} +\def\cradius {0.08} +\def\pluss {\bsegment + \setsegscale {\cradius} + \move (-0.5 0) \lvec (+0.5 0) + \move (0 -0.5) \lvec (0 +0.5) + \esegment} +\def\pcir {\lcir r:{\cradius} \pluss} +\def\puttext (#1 #2)#3{\bsegment + \setsegscale {\cradius} + \textref h:C v:C \htext (#1 #2){#3} + \esegment} +\def\putwnw #1{\puttext (-1.7 +1.2){#1}} +\def\putwsw #1{\puttext (-1.7 -1.2){#1}} +\def\putn #1{\puttext ( 0 +2 ){#1}} +\def\puts #1{\puttext ( 0 -2 ){#1}} +\def\avectoc (#1 #2){\currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + \savepos (#1 #2)(*tx *ty) + \bsegment + \move (*tx *ty) + \setsegscale {\cradius} + \rmove ({-\cosa} -\sina) + \savecurrpos (*ex *ey) + \esegment + \avec (*ex *ey) + \move (#1 #2)} +\def\avecfrc (#1 #2){\currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + \bsegment + \setsegscale {\cradius} + \move ({\cosa} \sina) + \savecurrpos (*ex *ey) + \esegment + \move (*ex *ey) + \avec (#1 #2)} + +\centertexdraw{ +\drawdim in +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\pl {$\scriptscriptstyle +$} \def\mn {$\scriptscriptstyle -$} + +\move (0 +0.63) \move (0 -0.60) \move (0 0) % compensate for the text size + +% Input to the first stage +\bsegment + \Ltext{$x(n)$} + \lvec (0.3 0) \bdot \lvec (0.3 +0.4) + \move (0.3 0) \lvec (0.3 -0.4) + \savepos (0.3 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% first lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw{\pl} \puts{\mn} + \avecfrc (2.1 +0.4) + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw{\pl} \putn{\mn} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext {$f_0(n)$} + \move (2.0 +0.42) \Ttext {$f_1(n)$} + \move (0.1 -0.4) \Btext {$b_0(n)$} + \move (2.0 -0.4) \Btext {$b_1(n)$} + \textref h:L v:B \htext (1.15 +0.2){$K_1$} + \textref h:L v:T \htext (1.15 -0.2){$K_1$} + \savepos (2.1 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% center section +\bsegment + \textref h:C v:C + \htext (0.3 +0.4){$\cdots$} + \htext (0.3 -0.4){$\cdots$} + \savepos (0.6 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% last lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw{\pl} \puts{\mn} + \avecfrc (2.3 +0.4) \Rtext{$e(n)$} + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw{\pl} \putn{\mn} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext {$f_{P-1}(n)$} + \move (2.0 +0.42) \Ttext {$f_P(n)$} + \move (0.1 -0.4) \Btext {$b_{P-1}(n)$} + \move (2.0 -0.4) \Btext {$b_P(n)$} + \textref h:L v:B \htext (1.15 +0.2){$K_P$} + \textref h:L v:T \htext (1.15 -0.2){$K_P$} +\esegment +} +\bigskip +@end tex + +The block diagram uses a ``delay'' block. This is defined as a segment +which leaves the current position at the end of this block. A second +macro, @code{\bdot}, draws a ``big'' dot which is used to mark junctions +of lines. The @code{\Ttext} command centers text above a given point. +The offset to position the text is local to a segment, resulting in no +change to the current point. Similar macros to position text below a +point (@code{\Btext}), to the left of a point (@code{\Ltext}) and to the +right of a point (@code{\Rtext}) are used in the final drawing. +@example +\def\delay @{\bsegment + \setsegscale 0.3 + \lvec (0 +0.5) \lvec (1 +0.5) \lvec (1 -0.5) + \lvec (0 -0.5) \lvec (0 0) + \textref h:C v:C \htext (0.5 0)@{$z^@{-1@}$@} + \savepos (1 0)(*ex *ey) + \esegment + \move (*ex *ey)@} +\def\bdot @{\fcir f:0 r:0.02 @} +\def\Ttext #1@{\bsegment + \textref h:C v:B \htext (0 +0.06)@{#1@} + \esegment@} +@end example + +Several of the block diagram elements scale with the size of the summing +nodes. The radius of the circles for the summing nodes is defined as +the macro @code{\cradius}. The summing nodes will have enclosed plus +signs, appropriately scaled. The plus sign is drawn by the macro +@code{\pluss}. The macro @code{\pcir} draws both the circle and the +plus sign. The incoming lines to a summing node will be labelled with +plus or minus signs (characters this time), placed at the appropriate +position with respect to the center of the summing node. These +positions are given in terms of compass directions. The macro +@code{\putwnw} places text west by north-west relative to the center of +the summing node. +@example +\def\cradius @{0.08@} +\def\pluss @{\bsegment + \setsegscale @{\cradius@} + \move (-0.5 0) \lvec (+0.5 0) + \move (0 -0.5) \lvec (0 +0.5) + \esegment@} +\def\pcir @{\lcir r:@{\cradius@} \pluss@} +\def\puttext (#1 #2)#3@{\bsegment + \setsegscale @{\cradius@} + \textref h:C v:C \htext (#1 #2)@{#3@} + \esegment@} +\def\putwnw #1@{\puttext (-1.7 +1.2)@{#1@}@} +@end example + +The block diagram has vectors arriving and departing from the summing +nodes (circles). One could calculate the points of intersection of the +lines with the circles, and then enter the values into the @TeX{}draw +code. However, in this example, we implement an automated procedure. +Two macros are needed, an arrow vector to a circle (@code{\avectoc}) and +an arrow vector leaving from a circle (@code{\avecfrc}). The macros +will calculate the point of intersection with the circle and start or +end the vector at the intersection point. + +The arrow macros use scaling and relative positioning inside of a +drawing segment. In the case of the macro @code{\avectoc}, a move is +made to the final point (center of the circle), then within a drawing +segment, a scaled move is made back towards the initial point to +determine the intersection point with the circle. + +@example +\def\avectoc (#1 #2)@{\currentpos \xa\ya + \cossin (@{\xa@} \ya)(#1 #2)\cosa\sina + \savepos (#1 #2)(*tx *ty) + \bsegment + \move (*tx *ty) + \setsegscale @{\cradius@} + \rmove (@{-\cosa@} -\sina) + \savecurrpos (*ex *ey) + \esegment + \avec (*ex *ey) + \move (#1 #2)@} +\def\avecfrc (#1 #2)@{\currentpos \xa\ya + \cossin (@{\xa@} \ya)(#1 #2)\cosa\sina + \bsegment + \setsegscale @{\cradius@} + \move (@{\cosa@} \sina) + \savecurrpos (*ex *ey) + \esegment + \move (*ex *ey) + \avec (#1 #2)@} +@end example + +Having defined these macros, we are ready to draw the block diagram. +The first and last sections of the lattice filter are very similar, +differing mainly in the text labels. With more effort, code could be +shared between the commands used to draw these blocks. +@example +\centertexdraw@{ +\drawdim in +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\pl @{$\scriptscriptstyle +$@} \def\mn @{$\scriptscriptstyle -$@} + +\move (0 +0.63) \move (0 -0.60) \move (0 0) % compensate for the text size + +% Input to the first stage +\bsegment + \Ltext@{$x(n)$@} + \lvec (0.3 0) \bdot \lvec (0.3 +0.4) \move (0.3 0) \lvec (0.3 -0.4) + \savepos (0.3 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% first lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw@{\pl@} \puts@{\mn@} + \avecfrc (2.1 +0.4) + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw@{\pl@} \putn@{\mn@} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext @{$f_0(n)$@} + \move (2.0 +0.42) \Ttext @{$f_1(n)$@} + \move (0.1 -0.4) \Btext @{$b_0(n)$@} + \move (2.0 -0.4) \Btext @{$b_1(n)$@} + \textref h:L v:B \htext (1.15 +0.2)@{$K_1$@} + \textref h:L v:T \htext (1.15 -0.2)@{$K_1$@} + \savepos (2.1 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% center section +\bsegment + \textref h:C v:C \htext (0.3 +0.4)@{$\cdots$@} + \htext (0.3 -0.4)@{$\cdots$@} + \savepos (0.6 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% last lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw@{\pl@} \puts@{\mn@} + \avecfrc (2.3 +0.4) \Rtext@{$e(n)$@} + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw@{\pl@} \putn@{\mn@} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext @{$f_@{P-1@}(n)$@} + \move (2.0 +0.42) \Ttext @{$f_P(n)$@} + \move (0.1 -0.4) \Btext @{$b_@{P-1@}(n)$@} + \move (2.0 -0.4) \Btext @{$b_P(n)$@} + \textref h:L v:B \htext (1.15 +0.2)@{$K_P$@} + \textref h:L v:T \htext (1.15 -0.2)@{$K_P$@} +\esegment +@} +@end example + +The macros used in this example are similar to the block diagram macros +defined in the file @file{blockdiagram.tex}. + +@node Filter response graph, Geometric construction, Block diagram, Examples +@appendixsec Filter response graph +@cindex example, graph + +This example shows the response of a canonical filter. @TeX{}draw is +not well suited for general purpose graphing --- it has no coordinate +translation facility nor does it have separate @var{x} and @var{y} +scaling. Nonetheless, for certain simple graphs, @TeX{}draw is +adequate. + +@tex +\bigskip +\centertexdraw{ +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\ds {\displaystyle} +\def\ticklab (#1 #2)#3{\move(#1 #2) + \bsegment + \lvec (0 0.05) + \textref h:C v:T \htext (0 -0.05){#3} + \esegment} +\def\Rtext #1{\bsegment + \textref h:L v:C \htext ( 0.08 0){#1} + \esegment} + +\move (2.4 -0.32) % move to set the size + +\move (0 0) +% Axes +\avec (0 1.4) +\move (0 0) \avec (2.2 0) \Rtext{$\omega$} +\ticklab (0 0) {0} +\ticklab (0.8 0) {$\ds {\pi \over 2N} $} +\ticklab (1.2 0) {$\omega_s$} +\ticklab (1.6 0) {$\ds {\pi \over N} $} + +\linewd 0.025 +\move (0 1) +\lvec (0.4 1) +\lvec (0.44 0.998) +\lvec (0.48 0.988) +\lvec (0.52 0.973) +\lvec (0.56 0.951) +\lvec (0.60 0.923) +\lvec (0.64 0.891) +\lvec (0.68 0.852) +\lvec (0.72 0.809) +\lvec (0.76 0.760) +\lvec (0.80 0.707) +\lvec (0.84 0.649) +\lvec (0.88 0.587) +\lvec (0.92 0.522) +\lvec (0.96 0.454) +\lvec (1.00 0.382) +\lvec (1.04 0.309) +\lvec (1.08 0.233) +\lvec (1.12 0.156) +\lvec (1.16 0.078) +\lvec (1.20 0) +\lvec (1.9 0) +} +\bigskip +@end tex + +In this example, macro @code{\ticklab} places a labelled axis tick at a +given position. The data is specified in a straightforward manner, +having been scaled beforehand to give the desired aspect ratio for the +graph. + +@example +\centertexdraw@{ +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\ds @{\displaystyle@} +\def\ticklab (#1 #2)#3@{\move(#1 #2) + \bsegment + \lvec (0 0.05) + \textref h:C v:T \htext (0 -0.05)@{#3@} + \esegment@} +\def\Rtext #1@{\bsegment + \textref h:L v:C \htext (+0.08 0)@{#1@} + \esegment@} + +\move (2.4 -0.3) % move to set the size + +\move (0 0) +% Axes +\avec (0 +1.4) +\move (0 0) \avec (2.2 0) \Rtext@{$\omega$@} +\ticklab (0 0) @{0@} +\ticklab (0.8 0) @{$\ds @{\pi \over 2N@} $@} +\ticklab (1.2 0) @{$\omega_s$@} +\ticklab (1.6 0) @{$\ds @{\pi \over N@} $@} + +\linewd 0.025 +\move (0 1) +\lvec (0.4 1) +\lvec (0.44 0.998) +\lvec (0.48 0.988) +\lvec (0.52 0.973) +\lvec (0.56 0.951) + ... +\lvec (1.08 0.233) +\lvec (1.12 0.156) +\lvec (1.16 0.078) +\lvec (1.20 0) +\lvec (1.9 0) +@} +@end example + +@node Geometric construction, , Filter response graph, Examples +@appendixsec Geometric construction +@cindex example, circle and ellipse + +This example shows a geometric construction which places an ellipse +tangent to an enclosing circle. The size of the ellipse is determined +from geometric considerations. Macros are used to modularize the code. +The example alters the unit scale factor. This allows the drawing to be +carried out in units normalized to the radius of the circle. + +@tex +\bigskip +\centertexdraw{ +\arrowheadtype t:V \arrowheadsize l:0.08 w:0.04 +\linewd 0.01 +\setunitscale 1.5 % circle will have radius 1.5 inches + +\def\Btext #1{\bsegment + \textref h:C v:T \htext (0 -0.04){#1} + \esegment} +\def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 0.04){#1} + \esegment} +\def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.04 0){#1} + \esegment} +\def\bdot {\fcir f:0 r:0.0133 } +\def\vtick {\bsegment + \move (0 -0.05) \lvec (0 0.05) + \esegment} +\def\htick {\bsegment + \move (-0.05 0) \lvec ( 0.05 0) + \esegment} +\def\Hlen #1#2{\bsegment + \vtick \avec ({#1} 0) \vtick \avec (0 0) + \relsegscale 0.5 + \move ({#1} 0) \Ttext {#2} + \esegment} +\def\Vlen #1#2{\bsegment + \htick \avec (0 {#1}) \htick \avec (0 0) + \relsegscale 0.5 + \move (0 {#1}) \Ltext {#2} + \esegment} + +\lcir r:1 % circle +\move (-1.05 0) \lvec ( 1.05 0) % axes +\move (0 -1.05) \lvec (0 1.05) + +\move (0 0) \lvec (0.707 0.707) \bdot +\rmove (0.02 0.02) \textref h:L v:B \htext {X} +\move (0.707 -0.707) \bdot +\textref h:R v:T \htext(-0.02 -0.02){O} + +\move (0.5 0) % center of ellipse +\bsegment + \lellip rx:0.435 ry:0.804 + \bdot \Btext {$\beta_2$} + \move (0 0.15) \Hlen {0.435}{$|\beta_1{+}\beta_3|$} + \move (-0.7 0) \Vlen {0.804}{$|\beta_1{-}\beta_3|$} +\esegment +} +\bigskip +@end tex +@example +\centertexdraw@{ +\arrowheadtype t:V \arrowheadsize l:0.08 w:0.04 +\linewd 0.01 +\setunitscale 1.5 % circle will have radius 1.5 inches + +\def\Btext #1@{\bsegment + \textref h:C v:T \htext (0 -0.04)@{#1@} + \esegment@} +\def\Ttext #1@{\bsegment + \textref h:C v:B \htext (0 +0.04)@{#1@} + \esegment@} +\def\Ltext #1@{\bsegment + \textref h:R v:C \htext (-0.04 0)@{#1@} + \esegment@} +\def\bdot @{\fcir f:0 r:0.0133 @} +\def\vtick @{\bsegment + \move (0 -0.05) \lvec (0 +0.05) + \esegment@} +\def\htick @{\bsegment + \move (-0.05 0) \lvec (+0.05 0) + \esegment@} +\def\Hlen #1#2@{\bsegment + \vtick \avec (@{#1@} 0) \vtick \avec (0 0) + \relsegscale 0.5 + \move (@{#1@} 0) \Ttext @{#2@} + \esegment@} +\def\Vlen #1#2@{\bsegment + \htick \avec (0 @{#1@}) \htick \avec (0 0) + \relsegscale 0.5 + \move (0 @{#1@}) \Ltext @{#2@} + \esegment@} + +\lcir r:1 % circle +\move (-1.05 0) \lvec ( 1.05 0) % axes +\move (0 -1.05) \lvec (0 1.05) + +\move (0 0) \lvec (0.707 0.707) \bdot +\rmove (0.02 0.02) \textref h:L v:B \htext @{X@} +\move (0.707 -0.707) \bdot +\textref h:R v:T \htext(-0.02 -0.02)@{O@} + +\move (0.5 0) % center of ellipse +\bsegment + \lellip rx:0.435 ry:0.804 + \bdot \Btext @{$\beta_2$@} + \move (0 0.15) \Hlen @{0.435@}@{$|\beta_1@{+@}\beta_3|$@} + \move (-0.7 0) \Vlen @{0.804@}@{$|\beta_1@{-@}\beta_3|$@} +\esegment +@} +@end example + + +@node Command Listing, Command Index, Examples, Top +@appendix Alphabetic listing of commands +@cindex listing of commands + +@table @code + +@item \arrowheadsize l:@var{length} w:@var{width} +Set the arrowhead size to be @var{length} units long and @var{width} +units wide. The width is measured across the ``base'' of the arrowhead. +The initial arrowhead size has a @var{length} of 0.16 inches and a +@var{width} of 0.08 inches. + +@item \arrowheadtype t:@var{type} +Set the arrowhead type to @var{type}, where @var{type} is one of +@code{F}, @code{T}, @code{W}, @code{V}, or @code{H}. There are two +kinds of arrowheads. The first kind is a triangle. There are 3 +variants: type @code{T} is an empty triangle, type @code{F} is a filled +triangle (using the current gray level for lines), type @code{W} is a +triangle filled with white. The second kind of arrowhead is an open +ended Vee. There are 2 variants: type @code{V} has the stem continue to +the tip, type @code{H} has the stem stop at the base of the arrowhead. +The initial arrowhead type is @code{T}. + +@item \avec (@var{x} @var{y}) +Draw a line with an arrowhead from the current position to +@code{(@var{x} @var{y})}. The new current position is @code{(@var{x} +@var{y})}. The arrowhead is aligned with the line, with the tip at +@code{(@var{x} @var{y})}. + +@item \begin@{texdraw@} +Start a @TeX{}draw drawing. The drawing is terminated with an +@code{\end@{texdraw@}} command. This command is for use with La@TeX{}. + +@item \bsegment +Start a drawing segment. The coordinate system is shifted such that the +current position corresponds to the coordinate @code{(0 0)}. Changes to +scaling, position and line parameters stay local to the drawing segment. + +@item \btexdraw +Start a @TeX{}draw drawing. The drawing is terminated with an +@code{\etexdraw} command. + +@item \centertexdraw @{ ... @} +Center a @TeX{}draw box. The argument contains @TeX{}draw commands. +The resulting box has the horizontal size @code{\hsize} and height equal +to the height of the drawing. + +@item \clvec (@var{x1} @var{y1})(@var{x2} @var{y2})(@var{x3} @var{y3}) +Draw a Bezier curve from the current position to the coordinate +@code{(@var{x3} @var{y3})} which becomes the new current position. The +coordinates @code{(@var{x1} @var{y1})} and @code{(@var{x2} @var{y2})} +serve as control points for the curve. Only the last coordinate given +is used to update the size of the drawing. + +@item \drawbb +Draw a ruled box around the effective size of a drawing produced by +@TeX{}draw commands. + +@item \drawdim @var{dim} +Set the units to @var{dim}. The argument @var{dim} can be any valid +@TeX{} dimension unit. The units are used to interpret coordinate +values. Examples of valid units: @code{cm}, @code{mm}, @code{in}, +@code{pt}, and @code{bp}. + +@item \end@{texdraw@} +End a @TeX{}draw drawing started with a @code{\begin@{texdraw@}} +command. The resulting @TeX{}draw drawing is placed in a box with +height equal to the height of the drawing and width equal to the width +of the drawing. The depth of the box is zero. This command is for use +with La@TeX{}. + +@item \esegment +End a drawing segment. The current position in effect before the +corresponding @code{\bsegment} command is restored. The scaling and +line parameter values revert to those in effect before the corresponding +@code{\bsegment} was invoked. + +@item \etexdraw +End a @TeX{}draw drawing started with a @code{\btexdraw} command. The +resulting @TeX{}draw drawing is placed in a box with height equal to the +height of the drawing and width equal to the width of the drawing. The +depth of the box is zero. + +@item \everytexdraw @{ ... @} +Specify @TeX{}draw commands to be executed at the beginning of every +@TeX{}draw drawing. + +@item \fcir f:@var{level} r:@var{radius} +Draw a filled circle with center at the current position. The radius is +specified by @var{radius}. The circle is painted with the gray level +specified by @var{level}. A gray level of 1 corresponds to white, with +decreasing values getting darker. The level 0 is full black. This +command does not draw a line along the circumference. The drawing size +is increased if necessary to contain the circle. + +@item \fellip f:@var{level} rx:@var{x-radius} ry:@var{y-radius} +Draw a filled ellipse with center at the current position. The radius +in the @var{x} direction is specified by @var{x-radius}. The radius in +the @var{y} direction is specified by @var{y-radius}. The ellipse is +painted with the gray level specified by @var{level}. A gray level of 1 +corresponds to white, with decreasing values getting darker. The level +0 is full black. This command does not draw a line along the boundary +of the ellipse. The drawing size is increased if necessary to contain +the ellipse. + +@item \htext (@var{x} @var{y})@{@var{text}@} +@itemx \htext @{@var{text}@} +The first form of this command places the @TeX{} text @var{text} +horizontally with the text reference point at the coordinate +@code{(@var{x} @var{y})}. The new current position is @code{(@var{x} +@var{y})}. The second form of this command places the @TeX{} text +@var{text} horizontally with the text reference point at the current +position. The text reference point is set with the @code{\textref} +command. + +@item \ifill f:@var{level} +Close the current path and paint the interior of the region with gray +level @var{level}. The line around the path is not drawn. Gray levels +are real values from 0 (black) through intermediate values (grays) to 1 +(white). + +@item \larc r:@var{radius} sd:@var{start-angle} ed:@var{end-angle} +Draw a counterclockwise arc. The center of the arc is at the current +position. The radius is specified by @var{radius}. The start and end +angles (in degrees) are specified by @var{start-angle} and +@var{end-angle}. This command does not affect the limits (size) of the +drawing. + +@item \lcir r:@var{radius} +Draw a circle with center at the current position. The radius is +specified by @var{radius}. This command draws a line along the +circumference of the circle. The drawing size is increased if necessary +to contain the circle. + +@item \lellip rx:@var{x-radius} ry:@var{y-radius} +Draw an ellipse with center at the current position. The radius in the +@var{x} direction is specified by @var{x-radius}. The radius in the +@var{y} direction is specified by @var{y-radius}. The drawing size is +increased if necessary to contain the ellipse. + +@item \lfill f:@var{level} + +Close the current path, draw the line around the path using the current +grey level for lines and paint the interior of the region with specified +gray level @var{level}. Gray levels are real values from 0 (black) +through intermediate values (grays) to 1 (white). + +@item \linewd @var{width} +Set the line width to @var{width} units. Initially @var{width} is 0.01 +inches (corresponding to 3 pixels at 300 pixels to the inch). + +@item \lpatt (@var{pattern}) +Set lines to have the pattern @code{(@var{pattern})}. A pattern is a +sequence of on/off lengths separated by blanks and enclosed in parentheses. +The lengths alternately specify the length of a dash and the length of a +gap between dashes. Each length is interpreted using the current +scaling and drawing units. The pattern is used cyclically. The empty +pattern signifies a solid line. The initial line pattern is a solid +line, corresponding to the empty pattern @code{\lpatt ()}. + +@item \lvec (@var{x} @var{y}) +Draw a line from the current position to coordinate @code{(@var{x} +@var{y})}. The new current position is @code{(@var{x} @var{y})}. + +@item \move (@var{x} @var{y}) +Move to coordinate @code{(@var{x} @var{y})}. The new current position +is @code{(@var{x} @var{y})}. + +@item \ravec (@var{dx} @var{dy}) +Draw a line with an arrowhead from the current position, @var{dx} units +in the @var{x} direction and @var{y} units in the @var{y} direction. +The final position becomes the new current position. The arrowhead is +aligned with the line, with the tip at the new current position. + +@item \relsegscale @var{value} +Adjust the segment scale factor by multiplying by @var{value}. This has +the effect of multiplying the current overall scale factor by the same +factor. The overall scaling factor is the product of the unit scale +factor and the segment scale factor. + +@item \relunitscale @var{value} +Adjust the unit scale factor by multiplying by @var{value}. This has +the effect of multiplying the overall scale factor by the same factor. +The overall scaling factor is the product of the unit scale factor and +the segment scale factor. + +@item \rlvec (@var{dx} @var{dy}) +Draw a line from the current position, @var{dx} units in the @var{x} +direction and @var{dy} units in the @var{y} direction. The final +position becomes the new current position. + +@item \rmove (@var{dx} @var{dy}) +Move from the current position, @var{dx} units in the @var{x} direction +and @var{dy} units in the @var{y} direction. The final position becomes +the new current position. + +@item \rtext td:@var{angle} (x y)@{@var{text}@} +@itemx \rtext td:@var{angle} @{@var{text}@} +The first form of this command places the @TeX{} text @var{text} at an +angle with the text reference point at the coordinate @code{(@var{x} +@var{y})}. The new current position is @code{(@var{x} @var{y})}. The +second form of this command places the @TeX{} text @var{text} at an +angle with the text reference point at the current position. In both +cases, the @TeX{} text is placed in a box and the box is rotated +counterclockwise by @var{angle} degrees about the text reference point. +The text reference point is set with the @code{\textref} command. + +@item \savecurrpos (*@var{px} *@var{py}) +Save the current position as the absolute position referenced by +@code{(*@var{px} *@var{py})}. + +@item \savepos (@var{x} @var{y})(*@var{px} *@var{py}) +Save the coordinate position @code{(@var{x} @var{y})} as the absolute +position referenced by @code{(*@var{px} *@var{py})}. The coordinate +@code{(@var{x} @var{y})} is interpreted in the normal fashion as a +coordinate relative to the current segment, using the current scaling +factors and drawing unit. + +@item \setgray @var{level} +Set the gray level of lines. Gray levels are real values from 0 (black) +through intermediate values (gray) to 1 (white). The initial gray level +is 0 corresponding to black. + +@item \setsegscale @var{scale} +Set the segment scale factor. The argument @var{scale} is a real number +which is used to scale coordinate values. The overall scale factor is +the product of the unit scale factor and the segment scale factor. + +@item \setunitscale @var{scale} +Set the unit scaling to @var{scale}. The argument @var{scale} is a real +number which is used to scale coordinate values. The overall scaling +factor is the product of the unit scale factor and the segment scale +factor. + +@item \texdrawbox @{ ... @} +Create a @TeX{}draw box. The argument contains @TeX{}draw commands. +This macro returns a @TeX{} box with height equal to the height of the +drawing and width equal to the width of the drawing. The depth of the +box is zero. + +@item \textref h:@var{h-ref} v:@var{v-ref} +Set the text reference point for subsequent text commands. The +horizontal reference point @var{h-ref} is one of @code{L}, @code{C} or +@code{R} (left, center or right). The vertical reference point +@var{v-ref} is one of @code{T}, @code{C} or @code{B} (top, center or +bottom). For rotated text, the reference point is determined before +rotation. The initial text reference point corresponds to +@code{\textref h:L v:B}. + +@item \vtext (x y)@{@var{text}@} +@itemx \vtext @{@var{text}@} +The first form of this command places the @TeX{} text @var{text} +vertically with the text reference point at the coordinate +@code{(@var{x} @var{y})}. The new current position is @code{(@var{x} +@var{y})}. The second form of this command places the @TeX{} text +@var{text} vertically with the text reference point at the current +position. In both cases, the @TeX{} text is placed in a box and the box +is rotated counterclockwise by 90 degrees about the text reference +point. The text reference point is set with the @code{\textref} +command. + +@end table + +@node Command Index, Concept Index, Command Listing, Top +@unnumbered Command Index +@printindex fn + +@node Concept Index, , Command Index, Top +@unnumbered Concept Index +@printindex cp + +@page +@contents +@bye diff --git a/Master/texmf-dist/doc/texdraw/texdraw_1.html b/Master/texmf-dist/doc/texdraw/texdraw_1.html new file mode 100644 index 00000000000..0865cde28b5 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_1.html @@ -0,0 +1,82 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - 1. Introduction</TITLE> +</HEAD> +<BODY> +Go to the first, previous, <A HREF="texdraw_2.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC1" HREF="texdraw_toc.html#TOC1">1. Introduction</A></H1> + +<P> +TeX is a powerful typesetting program which allows for complex text +layouts but by itself lacks a general graphics capability. However, +when coupled with an appropriate printer driver program, external +graphics files can be inserted into the printed document. In this mode, +TeX is instructed to leave space for a drawing. The drawing is +inserted by the printer driver program. The TeXdraw macros described +here generate the external graphics file from within TeX and generate +the instructions to the the print driver program to position the +graphics at the appropriate position on the page. + + +<P> +TeXdraw consists of a set of TeX macros that create line drawings +and other figures. The drawing primitives include solid lines, +patterned lines, Bezier curves, circles and arrows. Other commands +allow for the filling of a region with a gray level. The drawing +commands generate PostScript code. This limits TeXdraw to systems +which use PostScript printers. TeXdraw also provides commands to +position TeX text, including mathematics, on the drawing. The final +drawing, with text and graphics, can be positioned on the page like any +other TeX box. + + +<P> +<A NAME="IDX1"></A> +<A NAME="IDX2"></A> +<A NAME="IDX3"></A> +The basic TeXdraw macros for TeX use the <CODE>\special</CODE> syntax +recognized by the printer driver program <CODE>dvips</CODE>. However, when +invoked as a LaTeX2e package, the TeXdraw macros can be used with +any of the PostScript printer driver programs supported by the standard +<CODE>graphics</CODE> package for LaTeX2e. + + +<P> +The basic TeXdraw macros provide only simple drawing commands. +However, TeXdraw provides a drawing segment environment which allows +parameter changes and coordinate scaling changes to be kept local to the +drawing segment. This facility, together with TeX's macro +capabilities allows one to modularize drawing units and extend +TeXdraw by building more complex graphics entities from simpler +elements. + + + +<UL> +<LI><A HREF="texdraw_1.html#SEC2">Distribution</A> +</UL> + + + +<H2><A NAME="SEC2" HREF="texdraw_toc.html#TOC2">1.1 Distribution information</A></H2> +<P> +<A NAME="IDX4"></A> + + +<P> +The TeXdraw routines are provided free of charge without warranty of +any kind. Note that the TeXdraw routines are copyrighted. They may +be distributed freely provided that the recipients also acquire the +right to distribute them freely. The notices to this effect must be +preserved when the source files are distributed. + + +<P><HR><P> +Go to the first, previous, <A HREF="texdraw_2.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_10.html b/Master/texmf-dist/doc/texdraw/texdraw_10.html new file mode 100644 index 00000000000..faa705634dd --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_10.html @@ -0,0 +1,126 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - Command Index</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_9.html">previous</A>, <A HREF="texdraw_11.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC40" HREF="texdraw_toc.html#TOC40">Command Index</A></H1> +<P> +Jump to: +<A HREF="#findex_\">\</A> +- +<A HREF="#findex_a">a</A> +- +<A HREF="#findex_c">c</A> +- +<A HREF="#findex_f">f</A> +- +<A HREF="#findex_l">l</A> +- +<A HREF="#findex_m">m</A> +- +<A HREF="#findex_n">n</A> +- +<A HREF="#findex_s">s</A> +<P> +<H2><A NAME="findex_\">\</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX63">\arc</A> +<LI><A HREF="texdraw_2.html#IDX44">\arrowheadsize</A> +<LI><A HREF="texdraw_2.html#IDX43">\arrowheadtype</A> +<LI><A HREF="texdraw_2.html#IDX30">\avec</A> +<LI><A HREF="texdraw_2.html#IDX13">\begin{texdraw}</A> +<LI><A HREF="texdraw_3.html#IDX74">\bsegment</A> +<LI><A HREF="texdraw_2.html#IDX11">\btexdraw</A> +<LI><A HREF="texdraw_2.html#IDX15">\centertexdraw</A> +<LI><A HREF="texdraw_2.html#IDX66">\clvec</A> +<LI><A HREF="texdraw_7.html#IDX177">\cossin</A> +<LI><A HREF="texdraw_7.html#IDX176">\currentpos</A> +<LI><A HREF="texdraw_3.html#IDX94">\drawbb</A> +<LI><A HREF="texdraw_2.html#IDX22">\drawdim</A> +<LI><A HREF="texdraw_2.html#IDX14">\end{texdraw}</A> +<LI><A HREF="texdraw_3.html#IDX75">\esegment</A> +<LI><A HREF="texdraw_2.html#IDX12">\etexdraw</A> +<LI><A HREF="texdraw_2.html#IDX16">\everytexdraw</A> +<LI><A HREF="texdraw_2.html#IDX60">\fcir</A> +<LI><A HREF="texdraw_2.html#IDX62">\fellip</A> +<LI><A HREF="texdraw_7.html#IDX175">\getpos</A> +<LI><A HREF="texdraw_2.html#IDX46">\htext</A> +<LI><A HREF="texdraw_2.html#IDX71">\ifill</A> +<LI><A HREF="texdraw_2.html#IDX59">\lcir</A> +<LI><A HREF="texdraw_2.html#IDX61">\lellip</A> +<LI><A HREF="texdraw_2.html#IDX70">\lfill</A> +<LI><A HREF="texdraw_2.html#IDX41">\linewd</A> +<LI><A HREF="texdraw_2.html#IDX29">\lvec</A> +<LI><A HREF="texdraw_2.html#IDX28">\move</A> +<LI><A HREF="texdraw_6.html#IDX164">\PSarc</A> +<LI><A HREF="texdraw_6.html#IDX166">\PSarcn</A> +<LI><A HREF="texdraw_6.html#IDX153">\PSclosepath</A> +<LI><A HREF="texdraw_6.html#IDX155">\PSfill</A> +<LI><A HREF="texdraw_6.html#IDX159">\PSlineto</A> +<LI><A HREF="texdraw_6.html#IDX161">\PSmoveto</A> +<LI><A HREF="texdraw_6.html#IDX151">\PSnewpath</A> +<LI><A HREF="texdraw_6.html#IDX141">\PSsetlinecap</A> +<LI><A HREF="texdraw_6.html#IDX143">\PSsetlinejoin</A> +<LI><A HREF="texdraw_6.html#IDX149">\PSstroke</A> +<LI><A HREF="texdraw_2.html#IDX34">\ravec</A> +<LI><A HREF="texdraw_7.html#IDX179">\realadd</A> +<LI><A HREF="texdraw_7.html#IDX181">\realdiv</A> +<LI><A HREF="texdraw_7.html#IDX180">\realmult</A> +<LI><A HREF="texdraw_3.html#IDX92">\relsegscale</A> +<LI><A HREF="texdraw_3.html#IDX90">\relunitscale</A> +<LI><A HREF="texdraw_2.html#IDX33">\rlvec</A> +<LI><A HREF="texdraw_2.html#IDX32">\rmove</A> +<LI><A HREF="texdraw_2.html#IDX53">\rtext</A> +<LI><A HREF="texdraw_3.html#IDX83">\savecurrpos</A> +<LI><A HREF="texdraw_3.html#IDX84">\savepos</A> +<LI><A HREF="texdraw_2.html#IDX42">\setgray</A> +<LI><A HREF="texdraw_3.html#IDX91">\setsegscale</A> +<LI><A HREF="texdraw_3.html#IDX89">\setunitscale</A> +<LI><A HREF="texdraw_2.html#IDX54">\textref</A> +<LI><A HREF="texdraw_7.html#IDX178">\vectlen</A> +<LI><A HREF="texdraw_2.html#IDX50">\vtext</A> +<LI><A HREF="texdraw_6.html#IDX167">\writeps</A> +</DIR> +<H2><A NAME="findex_a">a</A></H2> +<DIR> +<LI><A HREF="texdraw_6.html#IDX163">arc</A> +<LI><A HREF="texdraw_6.html#IDX165">arcn</A> +</DIR> +<H2><A NAME="findex_c">c</A></H2> +<DIR> +<LI><A HREF="texdraw_6.html#IDX152">closepath</A> +</DIR> +<H2><A NAME="findex_f">f</A></H2> +<DIR> +<LI><A HREF="texdraw_6.html#IDX154">fill</A> +</DIR> +<H2><A NAME="findex_l">l</A></H2> +<DIR> +<LI><A HREF="texdraw_6.html#IDX158">lineto</A> +</DIR> +<H2><A NAME="findex_m">m</A></H2> +<DIR> +<LI><A HREF="texdraw_6.html#IDX160">moveto</A> +</DIR> +<H2><A NAME="findex_n">n</A></H2> +<DIR> +<LI><A HREF="texdraw_6.html#IDX150">newpath</A> +</DIR> +<H2><A NAME="findex_s">s</A></H2> +<DIR> +<LI><A HREF="texdraw_6.html#IDX140">setlinecap</A> +<LI><A HREF="texdraw_6.html#IDX142">setlinejoin</A> +<LI><A HREF="texdraw_6.html#IDX148">stroke</A> +</DIR> + + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_9.html">previous</A>, <A HREF="texdraw_11.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_11.html b/Master/texmf-dist/doc/texdraw/texdraw_11.html new file mode 100644 index 00000000000..cafff98a536 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_11.html @@ -0,0 +1,205 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - Concept Index</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_10.html">previous</A>, next, last section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC41" HREF="texdraw_toc.html#TOC41">Concept Index</A></H1> +<P> +Jump to: +<A HREF="#cindex_a">a</A> +- +<A HREF="#cindex_b">b</A> +- +<A HREF="#cindex_c">c</A> +- +<A HREF="#cindex_d">d</A> +- +<A HREF="#cindex_e">e</A> +- +<A HREF="#cindex_f">f</A> +- +<A HREF="#cindex_g">g</A> +- +<A HREF="#cindex_i">i</A> +- +<A HREF="#cindex_l">l</A> +- +<A HREF="#cindex_m">m</A> +- +<A HREF="#cindex_o">o</A> +- +<A HREF="#cindex_p">p</A> +- +<A HREF="#cindex_r">r</A> +- +<A HREF="#cindex_s">s</A> +- +<A HREF="#cindex_t">t</A> +- +<A HREF="#cindex_u">u</A> +- +<A HREF="#cindex_v">v</A> +- +<A HREF="#cindex_w">w</A> +- +<A HREF="#cindex_x">x</A> +<P> +<H2><A NAME="cindex_a">a</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX5">accessing TeXdraw</A>, <A HREF="texdraw_4.html#IDX97">accessing TeXdraw</A> +<LI><A HREF="texdraw_7.html#IDX170">angle of a vector</A> +<LI><A HREF="texdraw_2.html#IDX58">arcs</A>, <A HREF="texdraw_6.html#IDX162">arcs</A> +<LI><A HREF="texdraw_2.html#IDX40">arrowhead parameters</A> +<LI><A HREF="texdraw_2.html#IDX25">arrows</A> +</DIR> +<H2><A NAME="cindex_b">b</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX64">Bezier curves</A> +</DIR> +<H2><A NAME="cindex_c">c</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX55">circles</A> +<LI><A HREF="texdraw_2.html#IDX17">command syntax</A> +<LI><A HREF="texdraw_7.html#IDX168">coordinate parsing</A> +<LI><A HREF="texdraw_2.html#IDX20">coordinate specification</A> +<LI><A HREF="texdraw_3.html#IDX81">coordinate, symbolic</A> +<LI><A HREF="texdraw_2.html#IDX19">coordinates</A> +<LI><A HREF="texdraw_7.html#IDX172">cosine of a vector direction</A> +<LI><A HREF="texdraw_2.html#IDX27">current position</A>, <A HREF="texdraw_3.html#IDX95">current position</A>, <A HREF="texdraw_7.html#IDX169">current position</A> +<LI><A HREF="texdraw_6.html#IDX147">current position in PostScript</A> +<LI><A HREF="texdraw_2.html#IDX65">curves</A> +</DIR> +<H2><A NAME="cindex_d">d</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX37">dashed lines</A> +<LI><A HREF="texdraw_7.html#IDX171">direction of a line</A> +<LI><A HREF="texdraw_1.html#IDX4">distribution</A> +<LI><A HREF="texdraw_2.html#IDX38">dotted lines</A> +<LI><A HREF="texdraw_3.html#IDX73">drawing segments</A> +<LI><A HREF="texdraw_4.html#IDX106"><CODE>dvi2ps</CODE> printer driver</A> +<LI><A HREF="texdraw_4.html#IDX107"><CODE>dvialw</CODE> printer driver</A> +<LI><A HREF="texdraw_4.html#IDX108"><CODE>dvilaser</CODE> printer driver</A> +<LI><A HREF="texdraw_1.html#IDX1"><CODE>dvips</CODE> printer driver</A>, <A HREF="texdraw_4.html#IDX104"><CODE>dvips</CODE> printer driver</A>, <A HREF="texdraw_5.html#IDX134"><CODE>dvips</CODE> printer driver</A> +<LI><A HREF="texdraw_4.html#IDX109"><CODE>dvipsone</CODE> printer driver</A> +<LI><A HREF="texdraw_4.html#IDX111"><CODE>dvitops</CODE> printer driver</A> +<LI><A HREF="texdraw_4.html#IDX110"><CODE>dviwindo</CODE> printer driver</A> +</DIR> +<H2><A NAME="cindex_e">e</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX57">ellipses</A> +<LI><A HREF="texdraw_5.html#IDX126">Encapsulated PostScript File</A> +<LI><A HREF="texdraw_5.html#IDX120">errors while using TeXdraw</A> +<LI><A HREF="texdraw_7.html#IDX182">example, arrow curve</A> +<LI><A HREF="texdraw_8.html#IDX183">example, block diagram</A> +<LI><A HREF="texdraw_8.html#IDX185">example, circle and ellipse</A> +<LI><A HREF="texdraw_8.html#IDX184">example, graph</A> +</DIR> +<H2><A NAME="cindex_f">f</A></H2> +<DIR> +<LI><A HREF="texdraw_3.html#IDX76">fill operations, interaction with drawing segments</A> +<LI><A HREF="texdraw_2.html#IDX56">filled circles</A> +<LI><A HREF="texdraw_2.html#IDX67">filling regions</A>, <A HREF="texdraw_6.html#IDX145">filling regions</A> +</DIR> +<H2><A NAME="cindex_g">g</A></H2> +<DIR> +<LI><A HREF="texdraw_1.html#IDX3"><CODE>graphics</CODE> package</A>, <A HREF="texdraw_2.html#IDX10"><CODE>graphics</CODE> package</A>, <A HREF="texdraw_4.html#IDX103"><CODE>graphics</CODE> package</A>, <A HREF="texdraw_5.html#IDX131"><CODE>graphics</CODE> package</A> +<LI><A HREF="texdraw_5.html#IDX127">graphics placement</A> +<LI><A HREF="texdraw_2.html#IDX39">gray levels for lines</A> +</DIR> +<H2><A NAME="cindex_i">i</A></H2> +<DIR> +<LI><A HREF="texdraw_5.html#IDX121">implementation</A> +<LI><A HREF="texdraw_3.html#IDX96">initial current position</A> +<LI><A HREF="texdraw_2.html#IDX6">invoking TeXdraw</A>, <A HREF="texdraw_4.html#IDX98">invoking TeXdraw</A> +</DIR> +<H2><A NAME="cindex_l">l</A></H2> +<DIR> +<LI><A HREF="texdraw_1.html#IDX2">LaTeX</A>, <A HREF="texdraw_2.html#IDX8">LaTeX</A>, <A HREF="texdraw_4.html#IDX99">LaTeX</A> +<LI><A HREF="texdraw_7.html#IDX174">length of a vector</A> +<LI><A HREF="texdraw_6.html#IDX138">line cap</A> +<LI><A HREF="texdraw_6.html#IDX139">line join</A> +<LI><A HREF="texdraw_2.html#IDX35">line width</A> +<LI><A HREF="texdraw_2.html#IDX23">lines</A>, <A HREF="texdraw_6.html#IDX156">lines</A> +<LI><A HREF="texdraw_9.html#IDX186">listing of commands</A> +</DIR> +<H2><A NAME="cindex_m">m</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX26">moves</A>, <A HREF="texdraw_6.html#IDX157">moves</A> +</DIR> +<H2><A NAME="cindex_o">o</A></H2> +<DIR> +<LI><A HREF="texdraw_4.html#IDX112"><CODE>oztex</CODE> printer driver</A> +</DIR> +<H2><A NAME="cindex_p">p</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX68">painting regions</A> +<LI><A HREF="texdraw_2.html#IDX69">paths</A>, <A HREF="texdraw_3.html#IDX77">paths</A>, <A HREF="texdraw_6.html#IDX146">paths</A> +<LI><A HREF="texdraw_4.html#IDX115"><CODE>pctexps</CODE> printer driver</A> +<LI><A HREF="texdraw_4.html#IDX116"><CODE>pctexwin</CODE> printer driver</A> +<LI><A HREF="texdraw_5.html#IDX129">placement of graphics and text</A> +<LI><A HREF="texdraw_2.html#IDX7">plain TeX</A> +<LI><A HREF="texdraw_2.html#IDX21">position specification</A> +<LI><A HREF="texdraw_3.html#IDX80">positions, saving</A> +<LI><A HREF="texdraw_6.html#IDX137">PostScript commands</A> +<LI><A HREF="texdraw_4.html#IDX102">PostScript printer drivers</A>, <A HREF="texdraw_5.html#IDX132">PostScript printer drivers</A> +<LI><A HREF="texdraw_4.html#IDX101">printer drivers</A>, <A HREF="texdraw_5.html#IDX133">printer drivers</A> +<LI><A HREF="texdraw_5.html#IDX119">problems while using TeXdraw</A> +<LI><A HREF="texdraw_4.html#IDX113"><CODE>psprint</CODE> driver</A> +</DIR> +<H2><A NAME="cindex_r">r</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX31">relative positioning</A> +<LI><A HREF="texdraw_3.html#IDX86">relative scaling</A> +<LI><A HREF="texdraw_5.html#IDX123">resolution</A> +<LI><A HREF="texdraw_2.html#IDX48">rotated text</A>, <A HREF="texdraw_2.html#IDX51">rotated text</A>, <A HREF="texdraw_4.html#IDX117">rotated text</A>, <A HREF="texdraw_5.html#IDX124">rotated text</A>, <A HREF="texdraw_5.html#IDX135">rotated text</A> +</DIR> +<H2><A NAME="cindex_s">s</A></H2> +<DIR> +<LI><A HREF="texdraw_3.html#IDX79">saving positions</A> +<LI><A HREF="texdraw_5.html#IDX122">scaling</A> +<LI><A HREF="texdraw_3.html#IDX85">scaling coordinates</A> +<LI><A HREF="texdraw_3.html#IDX87">segment scale</A> +<LI><A HREF="texdraw_3.html#IDX72">segments</A> +<LI><A HREF="texdraw_7.html#IDX173">sine of a vector direction</A> +<LI><A HREF="texdraw_3.html#IDX93">size of the drawing</A> +<LI><A HREF="texdraw_3.html#IDX78">stroking lines</A>, <A HREF="texdraw_6.html#IDX144">stroking lines</A> +<LI><A HREF="texdraw_3.html#IDX82">symbolic coordinate</A> +<LI><A HREF="texdraw_2.html#IDX18">syntax of commands</A> +</DIR> +<H2><A NAME="cindex_t">t</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX9"><CODE>texdraw</CODE> package</A>, <A HREF="texdraw_4.html#IDX100"><CODE>texdraw</CODE> package</A>, <A HREF="texdraw_5.html#IDX130"><CODE>texdraw</CODE> package</A> +<LI><A HREF="texdraw_2.html#IDX45">text commands</A> +<LI><A HREF="texdraw_5.html#IDX128">text placement</A> +<LI><A HREF="texdraw_2.html#IDX49">text rotation</A>, <A HREF="texdraw_2.html#IDX52">text rotation</A>, <A HREF="texdraw_4.html#IDX118">text rotation</A>, <A HREF="texdraw_5.html#IDX125">text rotation</A>, <A HREF="texdraw_5.html#IDX136">text rotation</A> +<LI><A HREF="texdraw_4.html#IDX114"><CODE>textures</CODE> printer driver</A> +</DIR> +<H2><A NAME="cindex_u">u</A></H2> +<DIR> +<LI><A HREF="texdraw_3.html#IDX88">unit scale</A> +</DIR> +<H2><A NAME="cindex_v">v</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX24">vectors</A> +<LI><A HREF="texdraw_2.html#IDX47">vertical text</A> +</DIR> +<H2><A NAME="cindex_w">w</A></H2> +<DIR> +<LI><A HREF="texdraw_2.html#IDX36">width of lines</A> +</DIR> +<H2><A NAME="cindex_x">x</A></H2> +<DIR> +<LI><A HREF="texdraw_4.html#IDX105"><CODE>xdvi</CODE> driver</A> +</DIR> + + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_10.html">previous</A>, next, last section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_2.html b/Master/texmf-dist/doc/texdraw/texdraw_2.html new file mode 100644 index 00000000000..25abbb1af0e --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_2.html @@ -0,0 +1,882 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - 2. Using the TeXdraw Commands</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_1.html">previous</A>, <A HREF="texdraw_3.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC3" HREF="texdraw_toc.html#TOC3">2. Using the TeXdraw Commands</A></H1> + +<P> +The main TeXdraw macros (commands) are defined in the file +<TT>`texdraw.tex'</TT>. These macros may be used directly in TeX. The +file <TT>`texdraw.sty'</TT> provides an interface for use with LaTeX2e. +The following sections describe the basic commands for TeXdraw. + + + +<UL> +<LI><A HREF="texdraw_2.html#SEC4">Accessing TeXdraw</A> +<LI><A HREF="texdraw_2.html#SEC5">Command syntax</A> +<LI><A HREF="texdraw_2.html#SEC6">TeXdraw coordinates</A> +<LI><A HREF="texdraw_2.html#SEC7">Coordinate specification</A> +<LI><A HREF="texdraw_2.html#SEC8">Line vectors</A> +<LI><A HREF="texdraw_2.html#SEC9">TeX text</A> +<LI><A HREF="texdraw_2.html#SEC10">Circles and arcs</A> +<LI><A HREF="texdraw_2.html#SEC11">Bezier curves</A> +<LI><A HREF="texdraw_2.html#SEC12">Fill commands</A> +</UL> + + + +<H2><A NAME="SEC4" HREF="texdraw_toc.html#TOC4">2.1 Accessing TeXdraw</A></H2> +<P> +<A NAME="IDX5"></A> +<A NAME="IDX6"></A> + + +<P> +<A NAME="IDX7"></A> +<A NAME="IDX8"></A> +The form of the user command to run the TeX program depends on which +version of TeX is being used, and which other macro packages are +preloaded as format files. Typically, installations have at least two +versions of TeX -- plain TeX which includes basic typesetting +macros (usually invoked as <TT>`tex'</TT>) and LaTeX2e which includes the +LaTeX2e typesetting macros (usually invoked as <TT>`latex'</TT>). An +older version of LaTeX, version 2.09, may also be available. The +TeXdraw macros can be used with plain TeX and with either version +of LaTeX. + + +<P> +For use with plain TeX, the user must read in the TeXdraw macros +from the file <TT>`texdraw.tex'</TT>. + +<PRE> +\input texdraw % Read in the TeXdraw macros + ... +\btexdraw + ... % TeXdraw commands to generate a drawing +\etexdraw +</PRE> + +<P> +For use with LaTeX version 2.09, the user reads in the TeXdraw +macros from the file <TT>`texdraw.tex'</TT> and optionally defines the +<CODE>\begin{texdraw}</CODE> / <CODE>\end{texdraw}</CODE> environment. + +<PRE> +\documentstyle[11pt]{article} % Article style with the 11pt size options +... +\input texdraw % Read in the TeXdraw macros +\newenvironment{texdraw}{\leavevmode\btexdraw}{\etexdraw} + ... +\begin{texdraw} + ... % TeXdraw commands to generate a drawing +\end{texdraw} +... +\end{document} +</PRE> + +<P> +<A NAME="IDX9"></A> +<A NAME="IDX10"></A> +For use with LaTeX2e, the user must load the <CODE>texdraw</CODE> package +(file <TT>`texdraw.sty'</TT>). This package file defines the +<CODE>\begin{texdraw}</CODE> / <CODE>\end{texdraw}</CODE> environment, brings in +the standard <CODE>graphics</CODE> package and reads in the file +<TT>`texdraw.tex'</TT> containing the definitions of the TeXdraw macros. + +<PRE> +\documentclass[11pt]{article} % Article class with the 11pt size option +\usepackage{texdraw} % TeXdraw commands + +\begin{document} + ... +\begin{texdraw} + ... % TeXdraw commands to generate a drawing +\end{texdraw} + ... +\end{document} +</PRE> + +<P> +As the TeXdraw commands are processed by TeX, an intermediate +PostScript file is generated. The intermediate PostScript has a name of +the form <TT>`<VAR>name</VAR>.ps1'</TT>. The name part is derived from the name +of the main TeX file being processed. If more than one drawing is +produced, the digit in the file name extension is +incremented.<A NAME="DOCF1" HREF="texdraw_foot.html#FOOT1">(1)</A> + + +<P> +The TeXdraw commands to produce a drawing are inserted between +<CODE>\btexdraw</CODE> and <CODE>\etexdraw</CODE> commands, or for LaTeX, between +<CODE>\begin{texdraw}</CODE> and <CODE>\end{texdraw}</CODE> commands. This +results in a TeX box of appropriate size containing the drawing +generated by the TeXdraw commands. The TeXdraw box can be +positioned in a document like any other TeX box. + + +<P> +The <CODE>\centertexdraw{...}</CODE> macro centers the box generated by +TeXdraw. The vertical space taken up is equal to the vertical size +of the drawing. The <CODE>\centertexdraw</CODE> macro is normally used in +vertical mode (between paragraphs). A <CODE>\par</CODE> command (a blank line +will do also) before a <CODE>\centertexdraw</CODE> command will terminate +horizontal mode and return to vertical mode. For LaTeX, a structured +equivalent to the <CODE>\centertexdraw{...}</CODE> command is shown below. + +<PRE> +\begin{center} +\begin{texdraw} + ... +\end{texdraw} +\end{center} +</PRE> + +<P> +The <CODE>\everytexdraw</CODE> command can be used to define a set of +TeXdraw commands that will be executed at the beginning of every +TeXdraw drawing. It is invoked as <CODE>\everytexdraw{ ...}</CODE>, +with the desired TeXdraw commands as arguments. + + +<DL COMPACT> + +<DT><CODE>\btexdraw</CODE> +<DD> +<A NAME="IDX11"></A> + +Start a TeXdraw drawing. The drawing is terminated with an +<CODE>\etexdraw</CODE> command. +<A NAME="IDX12"></A> +<DT><CODE>\etexdraw</CODE> +<DD> +End a TeXdraw drawing started with a <CODE>\btexdraw</CODE> command. The +resulting TeXdraw drawing is placed in a box with height equal to the +height of the drawing and width equal to the width of the drawing. The +depth of the box is zero. +<A NAME="IDX13"></A> +<DT><CODE>\begin{texdraw}</CODE> +<DD> +Start a TeXdraw drawing. The drawing is terminated with an +<CODE>\end{texdraw}</CODE> command. This command is for use with LaTeX. +<A NAME="IDX14"></A> +<DT><CODE>\end{texdraw}</CODE> +<DD> +End a TeXdraw drawing started with a <CODE>\begin{texdraw}</CODE> +command. The resulting TeXdraw drawing is placed in a box with +height equal to the height of the drawing and width equal to the width +of the drawing. The depth of the box is zero. This command is for use +with LaTeX. +<A NAME="IDX15"></A> +<DT><CODE>\centertexdraw{ ... }</CODE> +<DD> +Center a TeXdraw box horizontally. The argument contains TeXdraw +commands. The resulting box has the horizontal size <CODE>\hsize</CODE> and +height equal to the height of the drawing. +<A NAME="IDX16"></A> +<DT><CODE>\everytexdraw{ ... }</CODE> +<DD> +Specify TeXdraw commands to be executed at the beginning of every +TeXdraw drawing. +</DL> + + + +<H2><A NAME="SEC5" HREF="texdraw_toc.html#TOC5">2.2 Command syntax</A></H2> +<P> +<A NAME="IDX17"></A> +<A NAME="IDX18"></A> + + +<P> +Generally TeXdraw commands that take a single argument need a +terminating blank or newline after the argument. Arguments that are +self-delimiting, such as coordinates within parentheses and text within +braces, do not need the terminating blank. However, even when not +needed by the defining syntax of the command, blanks following command +arguments are allowed and ignored within the TeXdraw environment. + + +<P> +On entering the TeXdraw environment, TeX is in internal vertical +mode (vertical mode inside a <CODE>\vbox</CODE>). In this mode, spaces can be +placed freely between commands. However, any other extraneous input +that generates output that is not part of the TeXdraw environment is +disallowed. + + +<P> +Blank lines are interpreted as paragraph breaks, equivalent to a +<CODE>\par</CODE> command. The TeXdraw macro <CODE>\centertexdraw</CODE> is +defined with the <CODE>\long</CODE> attribute to allow <CODE>\par</CODE> commands +and blank lines to be interspersed between TeXdraw commands. The +<CODE>\btexdraw</CODE> and <CODE>\etexdraw</CODE> commands also allow <CODE>\par</CODE> +command and blank lines to be included. + + + + +<H2><A NAME="SEC6" HREF="texdraw_toc.html#TOC6">2.3 TeXdraw coordinates</A></H2> +<P> +<A NAME="IDX19"></A> + + +<P> +The TeXdraw coordinate system has increasing <VAR>x</VAR> to the right and +increasing <VAR>y</VAR> upward. The coordinates (without the unit) are +floating point numbers. Integer values can be written without a decimal +point. The size of the drawing is determined by the maximum excursions +of the coordinates specified in TeXdraw commands. + + +<P> +Consider the following example of TeXdraw commands to draw a simple +figure. + +<PRE> +\centertexdraw{ + \drawdim cm \linewd 0.02 + \move(2 2) \lvec(3 3) \lvec(2 4) \lvec(1 3) \lvec(2 2) + \textref h:C v:C \htext(2 3){$\sum \rho_n$} +} +</PRE> + +<P> +This drawing uses units of centimetres, with a line width of 0.02 cm. +The <VAR>x</VAR> coordinate ranges between 1 and 3 while the <VAR>y</VAR> +coordinate ranges between 2 and 4. When included into a document, the +size of the drawing is 2 cm by 2 cm. The drawing is placed in a TeX +box, with the lower lefthand corner of the box corresponding to +TeXdraw coordinate <CODE>(1 2)</CODE> and the upper righthand corner at +<CODE>(3 4)</CODE>. The <CODE>\centertexdraw</CODE> command centers the drawing +horizontally. The <CODE>\textref</CODE> command controls the centering of the +text. The text in this drawing is centered (both horizontally and +vertically) at the coordinate <CODE>(2 3)</CODE>. + + + + +<H2><A NAME="SEC7" HREF="texdraw_toc.html#TOC7">2.4 Coordinate specification</A></H2> +<P> +<A NAME="IDX20"></A> +<A NAME="IDX21"></A> + + +<P> +Coordinates are specified within parentheses, with blanks (but no comma) +between the values. Leading blanks and trailing blanks are permitted +within the parentheses. The coordinates refer to units, which are +specified by the <CODE>\drawdim</CODE> command. The default is inches, but +any valid TeX dimension unit can be specified. Symbolic +specification of saved coordinate values will be discused later +(see section <A HREF="texdraw_3.html#SEC16">3.3 Saving positions</A>). + + +<DL COMPACT> + +<DT><CODE>\drawdim <VAR>dim</VAR></CODE> +<DD> +<A NAME="IDX22"></A> + +Set the units to <VAR>dim</VAR>. The argument <VAR>dim</VAR> can be any valid +TeX dimension unit. The units are used to interpret coordinate +values. Examples of valid units: <CODE>cm</CODE>, <CODE>mm</CODE>, <CODE>in</CODE>, +<CODE>pt</CODE>, and <CODE>bp</CODE>. +</DL> + +<P> +Examples of coordinate and scaling specifications: +<DL COMPACT> + +<DT><CODE>\drawdim {cm} \move(2 2)</CODE> +<DD> +Set the units to centimetres, move to a position 2 cm to the right and 2 +cm up from the origin of the drawing coordinate system. +<DT><CODE>\drawdim bp</CODE> +<DD> +Set the units to big points. +<DT><CODE>\lvec ( 2.2 +5.5) \lvec(2.3 -2) \lvec(2.2 5.4 )</CODE> +<DD> +Examples of acceptable coordinate specifications. +</DL> + + + +<H2><A NAME="SEC8" HREF="texdraw_toc.html#TOC8">2.5 Line vectors</A></H2> +<P> +<A NAME="IDX23"></A> +<A NAME="IDX24"></A> +<A NAME="IDX25"></A> +<A NAME="IDX26"></A> +<A NAME="IDX27"></A> + + +<P> +TeXdraw implements moves, line vectors and arrow vectors. There are +both absolute and relative motion versions of these vector commands. +TeXdraw maintains a current position. Lines are drawn from the +current position to a new coordinate, with the new coordinate becoming +the new current position. An explicit move can be used to establish a +new current position. The position <CODE>(0 0)</CODE> is used if there is no +move to an initial current position. + + +<P> +The <CODE>\move</CODE> and <CODE>\rmove</CODE> commands establish a new current +position without drawing a line. The <CODE>\lvec</CODE> and <CODE>\rlvec</CODE> +commands draw a line from the current position to a new position, which +then becomes the new current position. The <CODE>\avec</CODE> and +<CODE>\ravec</CODE> commands draw a line with an arrowhead from the current +position to a new coordinate, which then becomes the new current +position. The tip of the arrow is at the new current position. The +direction of the arrow follows the direction of the line. Since this +direction is undefined for zero length vectors, these are not allowed +for <CODE>\avec</CODE> or <CODE>\ravec</CODE>. Zero length arrow vectors will +generate a PostScript print error: <CODE>undefinedresult</CODE>. For any +non-zero length vector, the full size arrowhead is drawn, even if that +arrowhead is longer than the line length. + + +<P> +The absolute motion versions of these commands specify the coordinate of +the final position. + + +<DL COMPACT> + +<DT><CODE>\move (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +<A NAME="IDX28"></A> + +Move to coordinate <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The new current position +is <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. +<A NAME="IDX29"></A> +<DT><CODE>\lvec (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +Draw a line from the current position to coordinate <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. +<A NAME="IDX30"></A> +<DT><CODE>\avec (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +Draw a line with an arrowhead from the current position to +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The arrowhead is aligned with the line, with the tip at +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. +</DL> + +<P> +<A NAME="IDX31"></A> +The relative motion versions of these commands interpret the coordinates +as displacements relative to the current position. Given the +displacements <CODE>(<VAR>dx</VAR> <VAR>dy</VAR>)</CODE> as a parameter, each of the +relative motion commands moves <VAR>dx</VAR> units in the <VAR>x</VAR> direction +and <VAR>dy</VAR> units in the <VAR>y</VAR> direction. + + +<DL COMPACT> + +<DT><CODE>\rmove (<VAR>dx</VAR> <VAR>dy</VAR>)</CODE> +<DD> +<A NAME="IDX32"></A> + +Move from the current position, <VAR>dx</VAR> units in the <VAR>x</VAR> direction +and <VAR>dy</VAR> units in the <VAR>y</VAR> direction. The final position becomes +the new current position. +<A NAME="IDX33"></A> +<DT><CODE>\rlvec (<VAR>dx</VAR> <VAR>dy</VAR>)</CODE> +<DD> +Draw a line from the current position, <VAR>dx</VAR> units in the <VAR>x</VAR> +direction and <VAR>dy</VAR> units in the <VAR>y</VAR> direction. The final +position becomes the new current position. +<A NAME="IDX34"></A> +<DT><CODE>\ravec (<VAR>dx</VAR> <VAR>dy</VAR>)</CODE> +<DD> +Draw a line with an arrowhead from the current position, <VAR>dx</VAR> units +in the <VAR>x</VAR> direction and <VAR>y</VAR> units in the <VAR>y</VAR> direction. +The final position becomes the new current position. The arrowhead is +aligned with the line, with the tip at the new current position. +</DL> + +<P> +Lines can be customized with commands to change the line width, line +pattern and line gray level rendition. In addition, commands for +changing the type and size of the arrowhead are available. + + +<P> +<A NAME="IDX35"></A> +<A NAME="IDX36"></A> +<A NAME="IDX37"></A> +<A NAME="IDX38"></A> +<A NAME="IDX39"></A> +<A NAME="IDX40"></A> +<DL COMPACT> + +<DT><CODE>\linewd <VAR>width</VAR></CODE> +<DD> +<A NAME="IDX41"></A> + +Set the line width to <VAR>width</VAR> units. Initially <VAR>width</VAR> is 0.01 +inches (corresponding to 3 pixels at 300 pixels to the inch). +<DT><CODE>\lpatt (<VAR>pattern</VAR>)</CODE> +<DD> +Set lines to have the pattern <CODE>(<VAR>pattern</VAR>)</CODE>. A pattern is a +sequence of on/off lengths separated by blanks and enclosed in parentheses. +The lengths alternately specify the length of a dash and the length of a +gap between dashes. Each length is interpreted using the current +scaling and drawing units. The pattern is used cyclically. The empty +pattern signifies a solid line. The initial line pattern is a solid +line, corresponding to the empty pattern <CODE>\lpatt ()</CODE>. +<A NAME="IDX42"></A> +<DT><CODE>\setgray <VAR>level</VAR></CODE> +<DD> +Set the gray level of lines. Gray levels are real values from 0 (black) +through intermediate values (gray) to 1 (white). The initial gray level +is 0 corresponding to black. +<A NAME="IDX43"></A> +<DT><CODE>\arrowheadtype t:<VAR>type</VAR></CODE> +<DD> +Set the arrowhead type to <VAR>type</VAR>, where <VAR>type</VAR> is one of +<CODE>F</CODE>, <CODE>T</CODE>, <CODE>W</CODE>, <CODE>V</CODE>, or <CODE>H</CODE>. There are two +kinds of arrowheads. The first kind is a triangle. There are 3 +variants: type <CODE>T</CODE> is an empty triangle, type <CODE>F</CODE> is a filled +triangle (using the current gray level for lines), type <CODE>W</CODE> is a +triangle filled with white. The second kind of arrowhead is an open +ended Vee. There are 2 variants: type <CODE>V</CODE> has the stem continue to +the tip, type <CODE>H</CODE> has the stem stop at the base of the arrowhead. +The initial arrowhead type is <CODE>T</CODE>. +<A NAME="IDX44"></A> +<DT><CODE>\arrowheadsize l:<VAR>length</VAR> w:<VAR>width</VAR></CODE> +<DD> +Set the arrowhead size to be <VAR>length</VAR> units long and <VAR>width</VAR> +units wide. The width is measured across the "base" of the arrowhead. +The initial arrowhead size has a <VAR>length</VAR> of 0.16 inches and a +<VAR>width</VAR> of 0.08 inches. +</DL> + +<P> +Note that the lines which outline the arrowhead will be drawn with the +same line pattern used for the stem. Normally, arrow vectors are drawn +with the line pattern set for a solid line. Note that the fill level +used for the <CODE>F</CODE> variant of the arrowhead uses the same gray level +as used for lines. The difference between the <CODE>T</CODE> variant and the +<CODE>W</CODE> variant only shows up if the arrowhead is placed over non-white +areas of the drawing. The <CODE>W</CODE> variant obliterates the area under +the arrowhead. + + +<P> +Examples of line parameter and arrowhead settings are shown in the +following code. + +<PRE> +\centertexdraw{ + \drawdim in + \linewd 0.03 \setgray 0.6 \arrowheadtype t:F \avec(0 0.5) + \linewd 0.01 \setgray 0 \arrowheadtype t:V \avec(0.5 0.5) + \linewd 0.015 \lpatt(0.067 0.1) \lvec (1 0) + \linewd 0.02 \lpatt() \arrowheadtype t:T \avec(1.5 0.5) + \arrowheadtype t:H \avec(2.0 0.5) + \setgray 0.4 \arrowheadtype t:W \avec(3.0 0) +} +</PRE> + + + +<H2><A NAME="SEC9" HREF="texdraw_toc.html#TOC9">2.6 TeX text</A></H2> +<P> +<A NAME="IDX45"></A> + + +<P> +Text may be superimposed on the drawing. The text argument of the +<CODE>\htext</CODE> command is in horizontal mode. This text can be ordinary +text, math mode expressions, or even more complicated boxes consisting +of tables and the like. The resulting TeX text is placed in a box. +The reference point of the box can be chosen to be one of nine +locations: horizontally left, center or right; vertically top, center or +bottom. The <CODE>\htext</CODE> command takes one of two forms. + + +<DL COMPACT> + +<DT><CODE>\htext (<VAR>x</VAR> <VAR>y</VAR>){<VAR>text</VAR>}</CODE> +<DD> +<A NAME="IDX46"></A> + +<DT><CODE>\htext {<VAR>text</VAR>}</CODE> +<DD> +The first form of this command places the TeX text <VAR>text</VAR> +horizontally with the text reference point at the coordinate +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The second form of this command places the TeX text +<VAR>text</VAR> horizontally with the text reference point at the current +position. The text reference point is set with the <CODE>\textref</CODE> +command. +</DL> + +<P> +<A NAME="IDX47"></A> +<A NAME="IDX48"></A> +<A NAME="IDX49"></A> +Text can be placed vertically using the <CODE>\vtext</CODE> command. The text +argument is in horizontal mode. The TeX text is placed in a box and +then rotated counterclockwise. The reference point is the point in the +box, <EM>before</EM> rotation of the text. Not all PostScript printer +drivers support vertical text. + + +<DL COMPACT> + +<DT><CODE>\vtext (x y){<VAR>text</VAR>}</CODE> +<DD> +<A NAME="IDX50"></A> + +<DT><CODE>\vtext {<VAR>text</VAR>}</CODE> +<DD> +The first form of this command places the TeX text <VAR>text</VAR> +vertically with the text reference point at the coordinate +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The second form of this command places the TeX text +<VAR>text</VAR> vertically with the text reference point at the current +position. In both cases, the TeX text is placed in a box and the box +is rotated counterclockwise by 90 degrees about the text reference +point. The text reference point is set with the <CODE>\textref</CODE> +command. +</DL> + +<P> +<A NAME="IDX51"></A> +<A NAME="IDX52"></A> +Text can be placed at an arbitrary angle using the <CODE>\rtext</CODE> +command. The text argument is in horizontal mode. The TeX text is +placed in a box and then rotated counterclockwise. The reference point +is the point in the box, <EM>before</EM> rotation of the text. Not all +PostScript printer drivers support rotated text. + + +<DL COMPACT> + +<DT><CODE>\rtext td:<VAR>angle</VAR> (x y){<VAR>text</VAR>}</CODE> +<DD> +<A NAME="IDX53"></A> + +<DT><CODE>\rtext td:<VAR>angle</VAR> {<VAR>text</VAR>}</CODE> +<DD> +The first form of this command places the TeX text <VAR>text</VAR> at an +angle with the text reference point at the coordinate <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The +second form of this command places the TeX text <VAR>text</VAR> at an +angle with the text reference point at the current position. In both +cases, the TeX text is placed in a box and the box is rotated +counterclockwise by <VAR>angle</VAR> degrees about the text reference point. +The text reference point is set with the <CODE>\textref</CODE> command. +</DL> + +<P> +The reference point for subsequent TeX text in a <CODE>\htext</CODE>, +<CODE>\vtext</CODE> or <CODE>\rtext</CODE> command is set with the <CODE>\textref</CODE> +command. + + +<DL COMPACT> + +<DT><CODE>\textref h:<VAR>h-ref</VAR> v:<VAR>v-ref</VAR></CODE> +<DD> +<A NAME="IDX54"></A> + +Set the text reference point for subsequent text commands. The +horizontal reference point <VAR>h-ref</VAR> is one of <CODE>L</CODE>, <CODE>C</CODE> or +<CODE>R</CODE> (left, center or right). The vertical reference point +<VAR>v-ref</VAR> is one of <CODE>T</CODE>, <CODE>C</CODE> or <CODE>B</CODE> (top, center or +bottom). For rotated text, the reference point is determined before +rotation. The initial text reference point corresponds to +<CODE>\textref h:L v:B</CODE>. +</DL> +<P> + + +<P> +The font used to render the text is determined as for any other TeX +text. Normally the font used outside of TeXdraw is in effect. If +desired, other fonts can be specified as part of the text. Any font +changes within a TeXdraw text command remain local to that command. + + +<P> +Only the coordinate of the text reference point in a <CODE>\htext</CODE>, +<CODE>\vtext</CODE> or <CODE>\rtext</CODE> command is used in calculating the size +of the drawing. This means that text itself can spill outside of the +drawing area determined by TeXdraw. The area of the drawing can be +increased to include the text by issuing additional <CODE>\move</CODE> +commands. + + + +<PRE> +\centertexdraw{ + \avec(-0.75 -0.25) \textref h:R v:C \htext{H-text} + \move(0 0) \avec(-0.75 +0.25) \textref h:R v:B \htext{H-text} + \move(0 0) \avec(0 +0.5) \textref h:L v:T \vtext{V-text} + \move(0 0) \avec(+0.75 +0.25) \textref h:L v:B \htext{H-text} + \move(0 0) \avec(+0.75 -0.25) \textref h:L v:C \htext{H-text} +} +</PRE> + + + +<H2><A NAME="SEC10" HREF="texdraw_toc.html#TOC10">2.7 Circles, ellipses and arcs</A></H2> +<P> +<A NAME="IDX55"></A> +<A NAME="IDX56"></A> +<A NAME="IDX57"></A> +<A NAME="IDX58"></A> + + +<P> +TeXdraw supplies commands to generate circles, ellipses and arcs. +There are two forms of the circle command. The <CODE>\lcir</CODE> command +draws a circle of given radius. The <CODE>\fcir</CODE> command draws a filled +circle. In the latter case, the circle is filled by a specified gray +level. For the filled circle, the line defining the circumference of +the circle is not drawn. Note that the gray level area filled in by the +<CODE>\fcir</CODE> command is opaque, even if the fill is chosen to be white. +For either form of the circle command, the drawing size is increased if +necessary to contain the circle. + + +<P> +The <CODE>\lellip</CODE> command generates an ellipse specified by the radius +of the ellipse in the <VAR>x</VAR> direction and the radius of the ellipse in +the <VAR>y</VAR> direction. The ellipse is symmetrical about horizontal and +vertical lines drawn through the current point. The <CODE>\fellip</CODE> +command draws a filled ellipse. In the latter case, the ellipse is +filled by a specified gray level. For the filled ellipse, the line +defining the boundary of the ellipse is not drawn. For either form of +the ellipse command, the drawing size is increased if necessary to +contain the ellipse. + + +<P> +The <CODE>\larc</CODE> command generates a counterclockwise arc specified by a +start angle in degrees and an end angle in degrees. The center of the +arc is the current position. Only the arc is drawn, not the line +joining the center to the beginning of the arc. Note that the +<CODE>\larc</CODE> command does not affect the size of the drawing. + + +<DL COMPACT> + +<DT><CODE>\lcir r:<VAR>radius</VAR></CODE> +<DD> +<A NAME="IDX59"></A> + +Draw a circle with center at the current position. The radius is +specified by <VAR>radius</VAR>. This command draws a line along the +circumference of the circle. The drawing size is increased if necessary +to contain the circle. +<A NAME="IDX60"></A> +<DT><CODE>\fcir f:<VAR>level</VAR> r:<VAR>radius</VAR></CODE> +<DD> +Draw a filled circle with center at the current position. The radius is +specified by <VAR>radius</VAR>. The circle is painted with the gray level +specified by <VAR>level</VAR>. A gray level of 1 corresponds to white, with +decreasing values getting darker. The level 0 is full black. This +command does not draw a line along the circumference. The drawing size +is increased if necessary to contain the circle. +<A NAME="IDX61"></A> +<DT><CODE>\lellip rx:<VAR>x-radius</VAR> ry:<VAR>y-radius</VAR></CODE> +<DD> +Draw an ellipse with center at the current position. The radius in the +<VAR>x</VAR> direction is specified by <VAR>x-radius</VAR>. The radius in the +<VAR>y</VAR> direction is specified by <VAR>y-radius</VAR>. The drawing size is +increased if necessary to contain the ellipse. +<A NAME="IDX62"></A> +<DT><CODE>\fellip f:<VAR>level</VAR> rx:<VAR>x-radius</VAR> ry:<VAR>y-radius</VAR></CODE> +<DD> +Draw a filled ellipse with center at the current position. The radius +in the <VAR>x</VAR> direction is specified by <VAR>x-radius</VAR>. The radius in +the <VAR>y</VAR> direction is specified by <VAR>y-radius</VAR>. The ellipse is +painted with the gray level specified by <VAR>level</VAR>. A gray level of 1 +corresponds to white, with decreasing values getting darker. The level +0 is full black. This command does not draw a line along the boundary +of the ellipse. The drawing size is increased if necessary to contain +the ellipse. +<A NAME="IDX63"></A> +<DT><CODE>\larc r:<VAR>radius</VAR> sd:<VAR>start-angle</VAR> ed:<VAR>end-angle</VAR></CODE> +<DD> +Draw a counterclockwise arc. The center of the arc is at the current +position. The radius is specified by <VAR>radius</VAR>. The start and end +angles (in degrees) are specified by <VAR>start-angle</VAR> and +<VAR>end-angle</VAR>. This command does not affect the limits (size) of the +drawing. +</DL> + +<P> +As an example, the following commands draw a filled circle, and +superimpose an arc. + +<PRE> +\centertexdraw{ + \linewd 0.02 + \fcir f:0.7 r:1 + \larc r:1 sd:45 ed:135 + \lvec (+0.707 +0.707) \move (0 0) \lvec (-0.707 +0.707) +} +</PRE> + +<P> +Note that for the arc command, the resulting figure can spill outside of +the TeXdraw box as determined by the maximum excursions of the +coordinates. Extra moves can be used to compensate for the size of the +arc. + + + + +<H2><A NAME="SEC11" HREF="texdraw_toc.html#TOC11">2.8 Bezier curves</A></H2> +<P> +<A NAME="IDX64"></A> +<A NAME="IDX65"></A> + + +<P> +Bezier curves in TeXdraw use 4 reference coordinates, two as the end +points and two others to control the shape of the curve. Let the 4 +points be <CODE>(<VAR>x0</VAR> <VAR>y0</VAR>)</CODE>, <CODE>(<VAR>x1</VAR> <VAR>y1</VAR>)</CODE>, +<CODE>(<VAR>x2</VAR> <VAR>y2</VAR>)</CODE> and <CODE>(<VAR>x3</VAR> <VAR>y3</VAR>)</CODE>. The curve +starts out tangent to the line joining the first two points and ends up +tangent to the line joining the second two points. The control points +"pull" at the curve to control the curvature. The amount of pull +increases with the distance of the control point from the endpoint. + + +<P> +As the parameter u varies from 0 to 1, the coordinates of the Bezier +curve are given by a pair of parametric cubic equations, + + +<P> +x(u) = (1-u)^3 x0 + 3u (1-u)^2 x1 + 3u^2 (1-u) x2 + u^3 x3 +y(u) = (1-u)^3 y0 + 3u (1-u)^2 y1 + 3u^2 (1-u) y2 + u^3 y3 . + + +<DL COMPACT> + +<DT><CODE>\clvec (<VAR>x1</VAR> <VAR>y1</VAR>)(<VAR>x2</VAR> <VAR>y2</VAR>)(<VAR>x3</VAR> <VAR>y3</VAR>)</CODE> +<DD> +<A NAME="IDX66"></A> + +Draw a Bezier curve from the current position to the coordinate +<CODE>(<VAR>x3</VAR> <VAR>y3</VAR>)</CODE> which becomes the new current position. The +coordinates <CODE>(<VAR>x1</VAR> <VAR>y1</VAR>)</CODE> and <CODE>(<VAR>x2</VAR> <VAR>y2</VAR>)</CODE> +serve as control points for the curve. Only the last coordinate given +is used to update the size of the drawing. +</DL> +<P> +Note that only 3 coordinate pairs are specified. The other point is the +current position before the <CODE>\clvec</CODE> command is executed. Only the +last coordinate specified in the <CODE>\clvec</CODE> command is used to +determine the extent of the drawing. While the Bezier curve passes +through the old current position and the new current position, in +general the curve will not reach the intermediate control points. The +curve is always entirely enclosed by the convex quadrilateral defined by +the two end points and the two control points. Note that the curve may +pass outside the limits of the drawing as determined by the end point of +the curve. + + +<P> +A simple Bezier curve is produced by the following example. + +<PRE> +\btexdraw + \move (0 0) + \clvec (0 1)(1 0)(1 1) +\etexdraw +</PRE> + + + +<H2><A NAME="SEC12" HREF="texdraw_toc.html#TOC12">2.9 Fill commands</A></H2> +<P> +<A NAME="IDX67"></A> +<A NAME="IDX68"></A> +<A NAME="IDX69"></A> + + +<P> +PostScript deals with paths consisting of line segments. The paths can +be closed and the interior of the closed region filled. From +TeXdraw, paths start with a <CODE>\move</CODE> or <CODE>\rmove</CODE> command and +continue with <CODE>\lvec</CODE>, <CODE>\rlvec</CODE> or <CODE>\clvec</CODE> commands. +The TeXdraw fill commands close the path and fill the interior of the +closed region. Closing the path means that effectively another +<CODE>\lvec</CODE> line is drawn from the last point specified to the initial +point. TeXdraw provides two forms of the fill command. The +<CODE>\ifill</CODE> fills the interior of the region with the given gray +level. The lines defining the path are not drawn. The <CODE>\lfill</CODE> +command fills the region defined by the closed path and draws a line +along the enclosing path. Note for both forms of the fill command, the +gray level used for filling is opaque, even if the gray level is chosen +to be white. + + +<DL COMPACT> + +<DT><CODE>\lfill f:<VAR>level</VAR></CODE> +<DD> +<A NAME="IDX70"></A> + +Close the current path, draw the line around the path using the current +grey level for lines and paint the interior of the region with specified +gray level <VAR>level</VAR>. Gray levels are real values from 0 (black) +through intermediate values (grays) to 1 (white). +<A NAME="IDX71"></A> +<DT><CODE>\ifill f:<VAR>level</VAR></CODE> +<DD> +Close the current path and paint the interior of the region with gray +level <VAR>level</VAR>. The line around the path is not drawn. Gray levels +are real values from 0 (black) through intermediate values (grays) to 1 +(white). +</DL> + +<P> +The following example draws a "flag" with the interior filled in. The +path around the boundary is given in a clockwise order to define a +closed path. We could take advantage of the fact that the fill command +will close an open path to eliminate one of the <CODE>\lvec</CODE> commands. + +<PRE> +\centertexdraw{ +\move (0.5 0) +\lvec (0 0.5) \clvec (0.5 0.85)(1 0.65)(1.5 1) +\lvec (2 0.5) \clvec (1.5 0.15)(1 0.35)(0.5 0) +\lfill f:0.8 +} +</PRE> + +<P> +In TeXdraw, the <CODE>\move</CODE> command always terminates any previous +paths and starts a new path. Commands that change line parameters +(e.g. <CODE>\setgray</CODE> or <CODE>\lpatt</CODE>) also terminate paths and start +new paths. The circle, ellipse and arc commands do not affect the +definition of the current path. The <CODE>\avec</CODE> command is not +appropriate for defining a path to be filled. It ends a subpath at its +tail and begins a new subpath at its tip. Filling a region defined by a +path with subpaths is more complicated in that each subpath is closed +before filling. + + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_1.html">previous</A>, <A HREF="texdraw_3.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_3.html b/Master/texmf-dist/doc/texdraw/texdraw_3.html new file mode 100644 index 00000000000..52193c720b2 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_3.html @@ -0,0 +1,369 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - 3. Drawing Segments and Scaling</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_2.html">previous</A>, <A HREF="texdraw_4.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC13" HREF="texdraw_toc.html#TOC13">3. Drawing Segments and Scaling</A></H1> + +<P> +TeXdraw provides individually scaled segments which can be used to +create relocatable drawing modules. + + + +<UL> +<LI><A HREF="texdraw_3.html#SEC14">Drawing segments</A> +<LI><A HREF="texdraw_3.html#SEC15">Drawing paths</A> +<LI><A HREF="texdraw_3.html#SEC16">Saving positions</A> +<LI><A HREF="texdraw_3.html#SEC17">Scaling coordinates</A> +<LI><A HREF="texdraw_3.html#SEC18">Drawing size</A> +<LI><A HREF="texdraw_3.html#SEC19">Initial current position</A> +</UL> + + + +<H2><A NAME="SEC14" HREF="texdraw_toc.html#TOC14">3.1 Drawing segments</A></H2> +<P> +<A NAME="IDX72"></A> +<A NAME="IDX73"></A> + + +<P> +A TeXdraw drawing segment allows for local modifications of +parameters and relative positioning. A TeXdraw segment is delimited +by a <CODE>\bsegment</CODE> command and an <CODE>\esegment</CODE> command. Inside +the segment, the initial current position is <CODE>(0 0)</CODE>. Any changes +to parameters such as the gray level and the line width, remain local to +the segment. Segments are implemented in TeX using a +<CODE>\begingroup</CODE> and <CODE>\endgroup</CODE>. Segments can be nested. + + +<DL COMPACT> + +<DT><CODE>\bsegment</CODE> +<DD> +<A NAME="IDX74"></A> + +Start a drawing segment. The coordinate system is shifted such that the +current position corresponds to the coordinate <CODE>(0 0)</CODE>. Changes to +scaling, position and line parameters stay local to the drawing segment. +<A NAME="IDX75"></A> +<DT><CODE>\esegment</CODE> +<DD> +End a drawing segment. The current position in effect before the +corresponding <CODE>\bsegment</CODE> command is restored. The scaling and +line parameter values revert to those in effect before the corresponding +<CODE>\bsegment</CODE> command was invoked. +</DL> + + + +<H2><A NAME="SEC15" HREF="texdraw_toc.html#TOC15">3.2 Drawing paths</A></H2> +<P> +<A NAME="IDX76"></A> +<A NAME="IDX77"></A> +<A NAME="IDX78"></A> +Certain subtle interactions occur between drawing segments and fill +operations. In PostScript, lines are drawn by first defining a path, +then later stroking the path to draw the line. In TeXdraw, this +stroking occurs when the line is terminated, say by a <CODE>\move</CODE> +command. PostScript paths are interrupted by, but continue after a +drawing segment. This means that a path started before a segment may +not be stroked (drawn) until after the segment ends. Consider the +following example. + +<PRE> +\move (0 0) +\lvec (1 1) +\bsegment + \move (-0.25 -0.25) + \fcir f:0.8 r:0.5 +\esegment +\move (0 0) +</PRE> + +<P> +A PostScript path is started at <CODE>(0 0)</CODE> and continues with a line +to <CODE>(1 1)</CODE>. This path is interrupted by the segment. The filled +circle is drawn next. After the segment, the path continues and is not +stroked until the <CODE>\move (0 0)</CODE> command after the end of the +segment. This means that the line appears on top of the filled region. + + +<P> +If the fill operation is to cover the line, the path must be stroked +before the fill operation. From TeXdraw, the move commands +<CODE>\move</CODE> and <CODE>\rmove</CODE>, and the end TeXdraw command +<CODE>\etexdraw</CODE> terminate a path and cause it to be stroked. Within a +segment, the end segment command <CODE>\esegment</CODE> also terminates and +strokes a path. In the example above, the line can be stroked by +inserting a move command (such as a <CODE>\rmove (0 0)</CODE> which does not +affect the position), before the start of the segment. + + + + +<H2><A NAME="SEC16" HREF="texdraw_toc.html#TOC16">3.3 Saving positions</A></H2> +<P> +<A NAME="IDX79"></A> +<A NAME="IDX80"></A> +<A NAME="IDX81"></A> +<A NAME="IDX82"></A> + + +<P> +The <CODE>\savecurrpos</CODE> command saves the current position. The saved +position is an absolute position, not one relative to a segment. The +position saving mechanism is global; the position can be saved within a +nested segment and then used outside of the segment. The <VAR>x</VAR> and +<VAR>y</VAR> coordinates of the position are saved separately as named +coordinates. The names are of the form <CODE>*<VAR>name</VAR></CODE>, with the +leading <CODE>*</CODE> being obligatory. A companion command, +<CODE>\savepos</CODE>, saves a given coordinate (relative to the current +segment) as an absolute symbolic position. + + +<DL COMPACT> + +<DT><CODE>\savecurrpos (*<VAR>px</VAR> *<VAR>py</VAR>)</CODE> +<DD> +<A NAME="IDX83"></A> + +Save the current position as the absolute position referenced by +<CODE>(*<VAR>px</VAR> *<VAR>py</VAR>)</CODE>. +<A NAME="IDX84"></A> +<DT><CODE>\savepos (<VAR>x</VAR> <VAR>y</VAR>)(*<VAR>px</VAR> *<VAR>py</VAR>)</CODE> +<DD> +Save the coordinate position <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE> as the absolute +position referenced by <CODE>(*<VAR>px</VAR> *<VAR>py</VAR>)</CODE>. The coordinate +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE> is interpreted in the normal fashion as a +coordinate relative to the current segment, using the current scaling +factors and drawing unit. +</DL> + +<P> +The symbolic names used to specify a saved position can consist of any +characters that are not special to TeX, but must start with a +<CODE>*</CODE> character. The symbolic names can be used as the <VAR>x</VAR> +and/or <VAR>y</VAR> coordinate in any command that needs a coordinate. +Symbolic coordinates are not normally used with relative motion commands +such as <CODE>\rlvec</CODE> or <CODE>\rmove</CODE>. If used with relative motion, +the corresponding displacement is equal to the symbolic coordinate +value. + + +<P> +On exit from a segment, the position and graphics state on entry is +restored. Any changes to line types, scaling and position are +discarded. However, it is sometimes useful alter the position on exit +from a segment. The <CODE>\savepos</CODE> command allows for the saving of a +position within the segment. This position can be restored after the +<CODE>\esegment</CODE> with a <CODE>\move</CODE> command using the saved symbolic +position. This approach can be used to build modules which operate in a +manner analogous to the basic relative motion line vector commands. + + +<P> +The following example defines a macro which draws a box 0.75 inches wide +by 0.5 inches high containing centered text. On leaving the macro the +position will be set at a point on the righthand side of the box. + +<PRE> +\def\tbox #1{\bsegment + \lvec (0 +0.25) \lvec (0.75 +0.25) + \lvec (0.75 -0.25) \lvec (0 -0.25) \lvec (0 0) + \textref h:C v:C \htext (0.375 0){#1} + \savepos (0.75 0)(*ex *ey) + \esegment + \move (*ex *ey)} +</PRE> + +<P> +With this definition, we can treat <CODE>\tbox</CODE> in the same way as the +basic vector commands, stringing them together to form a block diagram +as in this example. + +<PRE> +\centertexdraw{ + \ravec (1 0) \tbox{$H(z)$} \ravec (1 0) +} +</PRE> + + + +<H2><A NAME="SEC17" HREF="texdraw_toc.html#TOC17">3.4 Scaling coordinates</A></H2> +<P> +<A NAME="IDX85"></A> +<A NAME="IDX86"></A> +<A NAME="IDX87"></A> +<A NAME="IDX88"></A> + + +<P> +There are two scale factors available, the unit scale factor and the +segment scale factor. The overall scale factor is the product of these +two. There are absolute and relative versions of commands to change +these scale factors. + + +<P> +The unit scale factor is normally used to affect global scale changes. +Changes to the unit scale factor remains local to a segment, but +propagate to inferior segments. The default value is unity. + + +<P> +The segment scale factor is used for local scale changes. It remains +local to a segment. The segment scale factor is reset to unity on entry +into each segment. This means that changes to the segment scale factor +do not propagate to inferior segments. + + +<DL COMPACT> + +<DT><CODE>\setunitscale <VAR>scale</VAR></CODE> +<DD> +<A NAME="IDX89"></A> + +Set the unit scaling to <VAR>scale</VAR>. The argument <VAR>scale</VAR> is a real +number which is used to scale coordinate values. The overall scaling +factor is the product of the unit scale factor and the segment scale +factor. +<A NAME="IDX90"></A> +<DT><CODE>\relunitscale <VAR>value</VAR></CODE> +<DD> +Adjust the unit scale factor by multiplying by <VAR>value</VAR>. This has +the effect of multiplying the overall scale factor by the same factor. +The overall scaling factor is the product of the unit scale factor and +the segment scale factor. +<A NAME="IDX91"></A> +<DT><CODE>\setsegscale <VAR>scale</VAR></CODE> +<DD> +Set the segment scale factor. The argument <VAR>scale</VAR> is a real number +which is used to scale coordinate values. The overall scale factor is +the product of the unit scale factor and the segment scale factor. +<A NAME="IDX92"></A> +<DT><CODE>\relsegscale <VAR>value</VAR></CODE> +<DD> +Adjust the segment scale factor by multiplying by <VAR>value</VAR>. This has +the effect of multiplying the current overall scale factor by the same +factor. The overall scaling factor is the product of the unit scale +factor and the segment scale factor. +</DL> + +<P> +In addition to the unit scale factor and the segment scale factor, the +scaling can be controlled by the choice of drawing units with the +command <CODE>\drawdim</CODE> (see section <A HREF="texdraw_2.html#SEC7">2.4 Coordinate specification</A>). + + +<DL COMPACT> + +<DT><CODE>\drawdim cm \setunitscale 2.54</CODE> +<DD> +Set the units to centimetres scaled by 2.54. Together these commands +are effectively the same as <CODE>\drawdim in</CODE>. +</DL> + +<P> +The segment scale can be used to allow scale changes in segments so that +values are in more convenient units. For example suppose dimensions in +a segment are multiples of one third of an inch. The segment scale can +be set once to make 1 drawing unit equal 0.3333 inches. From that point +on, coordinates can be specified with integer values. + + +<P> +The following example defines a macro to draw a rectangular box which is +twice as wide as it is high. The width is specified as an argument. + +<PRE> +\def\mybox #1{\bsegment + \setsegscale #1 + \lvec (0 +0.25) \lvec (1 +0.25) \lvec (1 -0.25) + \lvec (0 -0.25) \lvec (0 0) + \esegment} +</PRE> + + + +<H2><A NAME="SEC18" HREF="texdraw_toc.html#TOC18">3.5 Drawing size</A></H2> +<P> +<A NAME="IDX93"></A> + + +<P> +The effective size of the drawing is determined by the maximum +excursions of the coordinates supplied to TeXdraw commands. The +minimum and maximum scaled <VAR>x</VAR> and <VAR>y</VAR> coordinates are tallied. +Note that <CODE>\move</CODE> commands contribute to the determination of the +calculated size of the drawing, even though they do not generate visible +lines. The circle and ellipse commands add a compensation for the radii +of circles and ellipses. The final TeXdraw drawing is placed in a +TeX box with lower lefthand corner corresponding to +<CODE>(</CODE><VAR>x</VAR>-min <VAR>y</VAR>-min<CODE>)</CODE> and upper righthand corner at +<CODE>(</CODE><VAR>x</VAR>-max <VAR>y</VAR>-max<CODE>)</CODE>. + + +<P> +Text generated by <CODE>\htext</CODE>, <CODE>\vtext</CODE> or <CODE>\rtext</CODE> can +spill outside the box as determined above. Only the text reference +point is guaranteed to be in the drawing box. Arcs can also spill +outside the drawing box. Note also that the widths of lines, and the +sizes of arrowheads do not affect the size of the drawing. The +calculated size of the drawing will never be larger than the actual size +of the drawing. In extreme cases in which text or lines extend far +outside the drawing, extra <CODE>\move</CODE> commands should be used to +establish the size of the drawing so that the TeXdraw box includes +all of the drawing. + + +<P> +TeXdraw provides the <CODE>\drawbb</CODE> command to draw a box which +indicates the effective size of the drawing. Whenever <CODE>\drawbb</CODE> is +invoked, a ruled box is drawn around the drawing as it has been sized up +to that point. Normally <CODE>\drawbb</CODE> is invoked just before the end +of a drawing to indicate the effective size of the final drawing. + + +<DL COMPACT> + +<DT><CODE>\drawbb</CODE> +<DD> +<A NAME="IDX94"></A> + +Draw a ruled box around the effective size of a drawing produced by +TeXdraw commands. +</DL> + + + +<H2><A NAME="SEC19" HREF="texdraw_toc.html#TOC19">3.6 Initial current position</A></H2> +<P> +<A NAME="IDX95"></A> +<A NAME="IDX96"></A> + + +<P> +The first operation in a drawing should be a move to establish the +current position. The current position can be established explicitly +through a <CODE>\move</CODE> command or a text positioning command such as +<CODE>\htext</CODE> with a coordinate. However, if an attempt is made to use +a drawing command which needs a current position and none has been +established, TeXdraw implicitly sets the initial current position to +<CODE>(0 0)</CODE>. The size of the TeXdraw figure is normally determined +from the sequence of coordinates specified, but will include the +implicit initial position in case another initial position has not been +explicitly specified. + + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_2.html">previous</A>, <A HREF="texdraw_4.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_4.html b/Master/texmf-dist/doc/texdraw/texdraw_4.html new file mode 100644 index 00000000000..d766d721409 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_4.html @@ -0,0 +1,119 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - 4. Using TeXdraw with LaTeX</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_3.html">previous</A>, <A HREF="texdraw_5.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC20" HREF="texdraw_toc.html#TOC20">4. Using TeXdraw with LaTeX</A></H1> +<P> +<A NAME="IDX97"></A> +<A NAME="IDX98"></A> +<A NAME="IDX99"></A> +<A NAME="IDX100"></A> + + +<P> +The LaTeX typesetting system uses a structured approach to declaring +typesetting environments. For LaTeX2e, the <CODE>texdraw</CODE> package +defines the <CODE>texdraw</CODE> environment. The TeXdraw environment is +started with a <CODE>\begin{texdraw}</CODE> command and terminated with an +<CODE>\end{texdraw}</CODE> command. All of the basic TeXdraw commands +can be used within the <CODE>texdraw</CODE> environment. + + +<P> +As an example, a LaTeX2e variant of an earlier example can be +constructed as follows. + +<PRE> +\documentclass{article} +\usepackage{texdraw} + ... +\begin{document} + ... +\newcommand{\tbox}[1]{% + \bsegment + \lvec (0 +0.25) \lvec (0.75 +0.25) + \lvec (0.75 -0.25) \lvec (0 -0.25) \lvec (0 0) + \textref h:C v:C \htext (0.375 0){#1} + \savepos (0.75 0)(*ex *ey) + \esegment + \move (*ex *ey)} +\begin{center} +\begin{texdraw} + \ravec (1 0) \tbox{$H(z)$} \ravec (1 0) +\end{texdraw} +\end{center} + ... +\end{document} +</PRE> + +<P> +This example illustrates the use of the LaTeX command +<CODE>\newcommand</CODE> as an alternative to the plain TeX command +<CODE>\def</CODE>. Instead of the basic TeXdraw command +<CODE>\centertexdraw</CODE>, a nested combination of the LaTeX centering +environment and the TeXdraw environment is used. + + + +<UL> +<LI><A HREF="texdraw_4.html#SEC21">PostScript printer drivers</A> +</UL> + + + +<H2><A NAME="SEC21" HREF="texdraw_toc.html#TOC21">4.1 PostScript printer drivers</A></H2> +<P> +<A NAME="IDX101"></A> +<A NAME="IDX102"></A> + + +<P> +<A NAME="IDX103"></A> +The <CODE>texdraw</CODE> package uses the printer driver interface provided by +the standard LaTeX2e <CODE>graphics</CODE> package. Any options to the +<CODE>texdraw</CODE> package are passed to the <CODE>graphics</CODE> package. +Specifically, the name of the PostScript driver to be used can be +specified as an option to the <CODE>texdraw</CODE> package. With no explicit +printer driver option, the default printer driver associated with the +<CODE>graphics</CODE> package is used. + + +<P> +<A NAME="IDX104"></A> +<A NAME="IDX105"></A> +<A NAME="IDX106"></A> +<A NAME="IDX107"></A> +<A NAME="IDX108"></A> +<A NAME="IDX109"></A> +<A NAME="IDX110"></A> +<A NAME="IDX111"></A> +<A NAME="IDX112"></A> +<A NAME="IDX113"></A> +<A NAME="IDX114"></A> +<A NAME="IDX115"></A> +<A NAME="IDX116"></A> +<A NAME="IDX117"></A> +<A NAME="IDX118"></A> +The <CODE>texdraw</CODE> package can be used with any of the printer drivers +supported by the <CODE>graphics</CODE> package that allow for the importation +of PostScript graphics files, viz., <CODE>dvips</CODE>, <CODE>xdvi</CODE>, +<CODE>dvi2ps</CODE>, <CODE>dvialw</CODE>, <CODE>dvilaser</CODE>, <CODE>dvipsone</CODE>, +<CODE>dviwindo</CODE>, <CODE>dvitops</CODE>, <CODE>oztex</CODE>, <CODE>psprint</CODE>, +<CODE>textures</CODE>, <CODE>pctexps</CODE>, and <CODE>pctexwin</CODE>. Not all of these +drivers support the text rotation needed for the TeXdraw commands +<CODE>\vtext</CODE> and <CODE>\rtext</CODE>. Of the drivers listed above, only the +following support support text rotation: <CODE>dvips</CODE>, <CODE>xdvi</CODE>, +<CODE>dvi2ps</CODE>, <CODE>dvitops</CODE>, <CODE>textures</CODE>, and <CODE>pctexps</CODE>. + + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_3.html">previous</A>, <A HREF="texdraw_5.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_5.html b/Master/texmf-dist/doc/texdraw/texdraw_5.html new file mode 100644 index 00000000000..c880d21341d --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_5.html @@ -0,0 +1,314 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - 5. More Details</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_4.html">previous</A>, <A HREF="texdraw_6.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC22" HREF="texdraw_toc.html#TOC22">5. More Details</A></H1> + +<P> +The first part of this chapter offers some suggestions for strategies to +isolate errors in TeX and TeXdraw input. The second part of this +chapter discusses implementational issues. An awareness of these issues +is useful if TeXdraw is to be extended. + + + +<UL> +<LI><A HREF="texdraw_5.html#SEC23">Errors while using TeXdraw</A> +<LI><A HREF="texdraw_5.html#SEC24">Extending TeXdraw</A> +<LI><A HREF="texdraw_5.html#SEC29">How TeXdraw merges graphics and text</A> +</UL> + + + +<H2><A NAME="SEC23" HREF="texdraw_toc.html#TOC23">5.1 Errors while using TeXdraw</A></H2> +<P> +<A NAME="IDX119"></A> +<A NAME="IDX120"></A> + + +<P> +TeX input is notoriously difficult to debug. If TeX reports +errors, so much the better. If the cause is not immediately obvious, +consider using a binary search strategy, removing sections of code with +the premature insertion of the <CODE>\bye</CODE> (or <CODE>\end{document}</CODE> +for LaTeX) command (with the appropriate closing of any open groups +and the like). Other strategies include the insertion of +<CODE>\message{I am here}</CODE> at appropriate places. Try using +<CODE>\tracingmacros=1</CODE>. Many problems turn out to be due to an +incorrect number of macro arguments or incorrectly delimited macro +arguments. The <CODE>\tracingmacros=1</CODE> option writes the macro +arguments and macro expansions to the TeX log file. + + +<P> +Certain errors may not manifest themselves until well after the +offending command. For instance, if a closing parenthesis is missing +from a TeXdraw coordinate, TeX continues searching for the +parenthesis. If one is found, perhaps many lines later, the TeXdraw +error message <CODE>invalid coordinate</CODE> will be printed at this later +point. + + +<P> +All input in the TeXdraw environment should be intended for +interpretation by TeXdraw commands. TeXdraw places text inside a +zero size box (the text itself extends outside the box). Extraneous +input manifests itself as a non-zero size TeXdraw text box. This +causes the TeXdraw text and the PostScript graphics to be displaced +from one another. An error message is issued if a non-zero width +TeXdraw text box is detected. If this error message appears, look +for unintended character sequences amongst the commands to TeXdraw. + + +<P> +Several TeXdraw commands pass their arguments "raw" to the +PostScript file. That means that invalid arguments can generate +PostScript errors when the document is printed. For instance the +argument of the <CODE>\setgray</CODE> command is passed straight through to +the PostScript file. If this argument is non-numeric, a PostScript +error results. Not all PostScript printers report errors back to the +user. The print may just stop prematurely. One approach to debugging +is to use a PostScript previewer on a workstation. That way, one can +determine at which point in the drawing the PostScript error occurs. + + + + +<H2><A NAME="SEC24" HREF="texdraw_toc.html#TOC24">5.2 Extending TeXdraw</A></H2> +<P> +<A NAME="IDX121"></A> + + +<P> +TeXdraw is implemented using a combination of TeX commands and +PostScript code. This section discusses some of the implementational +issues as they relate to extending TeXdraw. + + +<P> +TeXdraw as implemented, offers a basic set of drawing features. +These are adequate for certain tasks such as producing block diagrams. +There are different approaches to extending TeXdraw to include other +functions. In some cases, the desired functionality can be achieved by +writing a TeX macro which builds on top of the existing TeXdraw +commands. As these extensions become more complex, the limitations of +TeX for computations become increasingly evident. In other cases, +access to different features of PostScript is desired. The appropriate +approach would be to write new PostScript procedures which can be +accessed by TeX macros. + + +<P> +Included with TeXdraw is a set of macros for directly accessing +PostScript functions. These are described in an appendix +(see section <A HREF="texdraw_6.html#SEC30">A. PostScript Commands</A>). + + +<P> +TeXdraw also comes with a toolbox of routines for handling much of +the user interface, converting between different coordinate +representations and the like. The macros for coordinate decoding and +for computations involving coordinates are described in an appendix +(see section <A HREF="texdraw_7.html#SEC31">B. TeXdraw Toolbox</A>). + + + +<UL> +<LI><A HREF="texdraw_5.html#SEC25">Scaling</A> +<LI><A HREF="texdraw_5.html#SEC26">Resolution</A> +<LI><A HREF="texdraw_5.html#SEC27">Text placement</A> +<LI><A HREF="texdraw_5.html#SEC28">Intermediate PostScript file</A> +</UL> + + + +<H3><A NAME="SEC25" HREF="texdraw_toc.html#TOC25">5.2.1 Scaling</A></H3> +<P> +<A NAME="IDX122"></A> + + +<P> +The scaling commands provided in TeXdraw are designed to affect only +the coordinate values specified in commands. For instance, changing the +<CODE>\setunitscale</CODE> value changes the interpretation of the coordinate +in an <CODE>\avec (<VAR>x</VAR> <VAR>y</VAR>)</CODE> command, but does not change the +line width or arrowhead sizes in effect. None of the TeXdraw scaling +commands affect the size of TeX text produced by, for instance, the +<CODE>\htext</CODE> command. Scale changes will however affect the +positioning of text for subsequent commands. + + +<P> +The line parameters are changed only if the corresponding commands to +change them are issued. If the <CODE>\linewd</CODE> command is given, the +current coordinate scaling is used to determine the line width. To +achieve a behaviour more like a global scaling, whenever the scale +factor is changed, the line parameters should be set again. + + + + +<H3><A NAME="SEC26" HREF="texdraw_toc.html#TOC26">5.2.2 Resolution</A></H3> +<P> +<A NAME="IDX123"></A> + + +<P> +TeXdraw scales coordinates before passing them to PostScript. +Keeping track of the coordinate scaling is necessary, in any event, to +allow TeXdraw to compute the maximum excursions of the coordinates. +TeXdraw uses pixel units in its PostScript code. One pixel unit is +equal to 1/300 of an inch. TeXdraw issues PostScript commands with +integer valued pixel coordinates. This sets the positioning resolution +for TeXdraw. The passing of integer valued coordinates which +correspond to the device resolution keeps lines aligned with the device +grid; parallel lines of the same width will be rendered with the same +width. + + +<P> +The position saving mechanism in TeXdraw (see section <A HREF="texdraw_3.html#SEC16">3.3 Saving positions</A>) +associates the pixel coordinates of a position with the specified name. + + +<P> +TeXdraw uses the limited real number representation provided by +TeX. These operations are based on the representation of dimensions +as real-valued numbers of points. Internally in TeX, dimensions are +stored 32-bit values, normalized so that 1 pt corresponds to the scaled +point (sp) value of 65536. Dimensions with magnitudes between 0.000015 +pt and 32767 pt can be represented. This is also the dynamic range of +the TeXdraw pixel coordinates passed to PostScript. TeXdraw must +convert from user supplied coordinates using the scaling factor (which +itself consists of two components, the unit scale and the segment scale) +and a pixel conversion factor. The use of limited precision real +numbers in these computations can cause accumulation of error when +relative scaling is used repeatedly. + + + + +<H3><A NAME="SEC27" HREF="texdraw_toc.html#TOC27">5.2.3 Text placement</A></H3> + +<P> +While in the TeXdraw environment, TeX text is placed in a TeX +box while PostScript code is written to the intermediate file. At the +end of the TeXdraw environment, the size of the drawing is +determined. A TeX box of this size is created. The TeX +<CODE>\special</CODE> mechanism is used to instruct the PostScript driver +program to position the PostScript drawing from the intermediate file in +this area. Next, the text generated by TeXdraw is positioned and +placed in the box. Note that when the document is printed, the +PostScript drawing is placed on the page before the TeX text; TeX +text will appear on top of graphics. + + +<P> +<A NAME="IDX124"></A> +<A NAME="IDX125"></A> +The rotation of text is carried out with in-line PostScript code which +does not appear in the intermediate PostScript file. This code is sent +to the PostScript driver with a <CODE>\special</CODE> command. This +PostScript code is embedded in the dvi (device independent) file that +TeX produces. + + + + +<H3><A NAME="SEC28" HREF="texdraw_toc.html#TOC28">5.2.4 The intermediate PostScript file</A></H3> +<P> +<A NAME="IDX126"></A> + + +<P> +The intermediate PostScript file consists of a header, a body and a +trailer following Encapsulated PostScript File (EPSF) standards. The +header sets up PostScript definitions and default parameter values. The +trailer includes the <CODE>BoundingBox</CODE> information which gives the +coordinates in default PostScript units (72 per inch) for the lower +lefthand corner and the upper righthand corner of the drawing. The body +of the intermediate PostScript file contains the PostScript commands +generated by TeXdraw. + + +<P> +Many moves in TeXdraw serve only to position text or to reset saved +positions. TeXdraw buffers move commands in order to be able to +collapse runs of moves. Only the last move of a run of moves is +actually written to the PostScript file. However the intermediate moves +still affect the size of the drawing. The expunging of moves means that +the PostScript file <CODE>BoundingBox</CODE> information may indicate a drawing size +larger than the PostScript commands themselves would warrant. + + +<P> +Drawing segments in TeXdraw show up in the PostScript file as saves +and restores of the PostScript graphics state. Segment starts are +buffered and only written out if necessary. This way "empty" segments +do not generate output to the PostScript file. These empty segments +arise if a segment contains only moves and text commands. The moves +inside the segment are not needed since they are local to the segment, +and the text commands do not generate output to the PostScript file. + + +<P> +If TeXdraw is used only for moves and text, no intermediate +PostScript file will be created. + + + + +<H2><A NAME="SEC29" HREF="texdraw_toc.html#TOC29">5.3 How TeXdraw merges graphics and text</A></H2> +<P> +<A NAME="IDX127"></A> +<A NAME="IDX128"></A> +<A NAME="IDX129"></A> + + +<P> +TeXdraw creates a box which is the same size as the graphic. The +printer driver will place the PostScript graphic into this space. Any +TeX text generated by the TeXdraw commands will be superimposed on +this graphic. + + +<P> +<A NAME="IDX130"></A> +<A NAME="IDX131"></A> +The LaTeX2e front-end for TeXdraw is enabled by including the +<CODE>texdraw</CODE> package. The <CODE>texdraw</CODE> package automatically +invokes the standard <CODE>graphics</CODE> package distributed with +LaTeX2e. The <CODE>graphics</CODE> package has support for a number of +different printer drivers, including a number for PostScript printers. +Any options to the <CODE>texdraw</CODE> package are passed on to the +<CODE>graphics</CODE> package. Such an option can be used to select a driver +other than the default one. + + +<P> +<A NAME="IDX132"></A> +<A NAME="IDX133"></A> +<A NAME="IDX134"></A> +<A NAME="IDX135"></A> +<A NAME="IDX136"></A> +Within the <CODE>graphics</CODE> package, the driver option is used to select +definitions for the low-level macros which generate the <CODE>\special</CODE> +commands needed to request insertion of a graphics file and to rotate +text.<A NAME="DOCF2" HREF="texdraw_foot.html#FOOT2">(2)</A> +TeXdraw uses the user-level macros defined by the <CODE>graphics</CODE> +package (see section <A HREF="texdraw_4.html#SEC21">4.1 PostScript printer drivers</A>). When not used with the +LaTeX2e front-end, TeXdraw defines versions of these macros that +are suitable for use with the <CODE>dvips</CODE> printer driver. + + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_4.html">previous</A>, <A HREF="texdraw_6.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_6.html b/Master/texmf-dist/doc/texdraw/texdraw_6.html new file mode 100644 index 00000000000..9686e350ae8 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_6.html @@ -0,0 +1,183 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - A. PostScript Commands</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_5.html">previous</A>, <A HREF="texdraw_7.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC30" HREF="texdraw_toc.html#TOC30">A. PostScript Commands</A></H1> +<P> +<A NAME="IDX137"></A> + + +<P> +This appendix describes a set of macros for accessing some of the +PostScript builtin functions. Each of these macros issues a single +PostScript command. The extra services provided by TeXdraw are the +interpretation of coordinates in user units relative to the current +drawing segment and the writing of a pending TeXdraw move to the +PostScript file. This last operation establishes the current point in +PostScript. The user of these commands should be familiar with the +concepts of path construction and filling in PostScript. Further +details on the PostScript functions used can found in the +<CITE>PostScript Language Reference Manual, Second Edition</CITE>, Adobe +Systems, Addison-Wesley, 1990. + + +<P> +These macros are distributed in file <TT>`txdps.tex'</TT>. + + +<P> +The <CODE>\PSsetlinecap</CODE> and <CODE>\PSsetlinejoin</CODE> commands control the +way line ends and line joins are rendered. The default values set by +TeXdraw (round caps and round join) are appropriate for most +drawings. Changes to these parameters apply to the current and +subsequent paths. + + +<P> +<A NAME="IDX138"></A> +<A NAME="IDX139"></A> +<DL COMPACT> + +<DT><CODE>\PSsetlinecap <VAR>type</VAR></CODE> +<DD> +<A NAME="IDX140"></A> + <A NAME="IDX141"></A> + +Set the line cap parameter. The value <CODE>0</CODE> gives a butt cap; +<CODE>1</CODE> gives a round cap; and <CODE>2</CODE> gives a projecting square cap. +The initial value is corresponds to a round cap. +<A NAME="IDX142"></A> +<A NAME="IDX143"></A> +<DT><CODE>\PSsetlinejoin <VAR>type</VAR></CODE> +<DD> +Set the line join parameter. The value <CODE>0</CODE> gives a miter join; +<CODE>1</CODE> gives a round join; and <CODE>2</CODE> gives a bevel join. The +initial value corresponds to a round join. +</DL> + +<P> +<A NAME="IDX144"></A> +<A NAME="IDX145"></A> +<A NAME="IDX146"></A> +<A NAME="IDX147"></A> +PostScript paths and fill operations can be controlled by a number of +functions. By design, TeXdraw always maintains a defined PostScript +current point. Some of the following macros cause the PostScript +current point to become undefined. The PostScript current point must be +set again (say with a <CODE>\PSmoveto</CODE> command) before invoking basic +TeXdraw commands. +<DL COMPACT> + +<DT><CODE>\PSstroke</CODE> +<DD> +<A NAME="IDX148"></A> + <A NAME="IDX149"></A> + +Stroke a PostScript path. The current path is stroked with the current +gray level (set with <CODE>\setgray</CODE>) and the current line pattern (set +with <CODE>\lpatt</CODE>). The PostScript current point becomes undefined. +<A NAME="IDX150"></A> +<A NAME="IDX151"></A> +<DT><CODE>\PSnewpath</CODE> +<DD> +Establish a new path. The PostScript current point becomes undefined. +<A NAME="IDX152"></A> +<A NAME="IDX153"></A> +<DT><CODE>\PSclosepath</CODE> +<DD> +Close a subpath. A new subpath is started. +<A NAME="IDX154"></A> +<A NAME="IDX155"></A> +<DT><CODE>\PSfill</CODE> +<DD> +Fill a region defined by a path. Each subpath is closed and the +enclosed regions painted with the current gray level. The PostScript +current point becomes undefined. The gray level can be set with the +TeXdraw command <CODE>\setgray</CODE>. +</DL> + +<P> +The following line commands interpret coordinates relative to the +current TeXdraw scaling and drawing segment. The specified +coordinate affects the drawing size as determined by TeXdraw. +<A NAME="IDX156"></A> +<A NAME="IDX157"></A> +<DL COMPACT> + +<DT><CODE>\PSlineto (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +<A NAME="IDX158"></A> + <A NAME="IDX159"></A> + +Add a line segment to the current path. This command is identical to +the TeXdraw command <CODE>\lvec</CODE>. The PostScript current point must +be defined before this command is issued. +<A NAME="IDX160"></A> +<A NAME="IDX161"></A> +<DT><CODE>\PSmoveto (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +Move to the coordinate specified by <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The +PostScript current point becomes defined. +</DL> + +<P> +The following macros provide access to the general arc commands in +PostScript. The coordinates are interpreted relative to the current +TeXdraw scaling and drawing segment. The specified coordinate +affects the drawing size as determined by TeXdraw. +<A NAME="IDX162"></A> +<DL COMPACT> + +<DT><CODE>\PSarc r:<VAR>radius</VAR> sd:<VAR>start-angle</VAR> ed:<VAR>end-angle</VAR> (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +<A NAME="IDX163"></A> + <A NAME="IDX164"></A> + +Draw a counterclockwise arc. The center of the arc is at the given +position. The radius is specified by <VAR>radius</VAR>. The start and end +angles (in degrees) are specified by <VAR>start-angle</VAR> and +<VAR>end-angle</VAR>. If the PostScript current point is defined, this +command also draws the line from the current point to the beginning of +the arc. The line and arc become part of the current path. The current +point becomes defined. +<A NAME="IDX165"></A> +<A NAME="IDX166"></A> +<DT><CODE>\PSarcn r:<VAR>radius</VAR> sd:<VAR>start-angle</VAR> ed:<VAR>end-angle</VAR> (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +Draw a clockwise arc. The center of the arc is at the given position. +The radius is specified by <VAR>radius</VAR>. The start and end angles (in +degrees) are specified by <VAR>start-angle</VAR> and <VAR>end-angle</VAR>. If the +PostScript current point is defined, this command also draws the line +from the current point to the beginning of the arc. The line and arc +become part of the current path. The current point becomes defined. +</DL> + +<P> +The macro <CODE>\writeps</CODE> provides the general facility to write +arbitrary PostScript commands to the PostScript file. This macro is +used by the preceding commands and by the TeXdraw commands +themselves. This facility has to be used with care since changes in +position or scaling resulting from the PostScript commands are not known +to TeXdraw. +<DL COMPACT> + +<DT><CODE>\writeps {<VAR><ps-commands></VAR>}</CODE> +<DD> +<A NAME="IDX167"></A> + +Write PostScript commands to the intermediate PostScript file. Before +the commands are inserted, any pending TeXdraw move is written to the +PostScript file. The PostScript scaling gives 300 units/inch. +</DL> + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_5.html">previous</A>, <A HREF="texdraw_7.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_7.html b/Master/texmf-dist/doc/texdraw/texdraw_7.html new file mode 100644 index 00000000000..1905d68c0fe --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_7.html @@ -0,0 +1,250 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - B. TeXdraw Toolbox</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_6.html">previous</A>, <A HREF="texdraw_8.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC31" HREF="texdraw_toc.html#TOC31">B. TeXdraw Toolbox</A></H1> + +<P> +This appendix describes some of the macros supplied with TeXdraw +which can be used to define additional commands for creating drawings. +The macros described here work in the user specified coordinate system. +Some of these toolbox macros are used by the TeXdraw commands +themselves, others are supplied in an auxiliary file +<TT>`txdtools.tex'</TT>. + + + +<UL> +<LI><A HREF="texdraw_7.html#SEC32">Coordinate parsing</A> +<LI><A HREF="texdraw_7.html#SEC33">Real arithmetic</A> +<LI><A HREF="texdraw_7.html#SEC34">Arrow curve</A> +</UL> + + + +<H2><A NAME="SEC32" HREF="texdraw_toc.html#TOC32">B.1 Coordinate parsing</A></H2> + +<P> +The coordinate parsing macro <CODE>\getpos</CODE> is useful for creating new +commands. This macro takes care of stripping leading and trailing +blanks from coordinates specified between parentheses. In addition, +symbolic coordinates are translated to the corresponding relative +coordinate using the segment offset and scaling in effect. + + +<P> +The macro <CODE>\currentpos</CODE> returns the relative coordinates of the +current position. The returned values are relative to the current +segment and the current scaling. The macro <CODE>\cossin</CODE> returns the +real-valued cosine and sine of the direction of the line joining two +points. The macro <CODE>\vectlen</CODE> returns the length of a vector. The +results appear as the value of user supplied macro names. + + +<P> +<A NAME="IDX168"></A> +<A NAME="IDX169"></A> +<A NAME="IDX170"></A> +<A NAME="IDX171"></A> +<A NAME="IDX172"></A> +<A NAME="IDX173"></A> +<A NAME="IDX174"></A> +<DL COMPACT> + +<DT><CODE>\getpos (<VAR>x</VAR> <VAR>y</VAR>)\<VAR>mx</VAR>\<VAR>my</VAR></CODE> +<DD> +<A NAME="IDX175"></A> + +Decode coordinate values. The coordinates specified by <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE> are decoded. Symbolic coordinates are translated to the +corresponding relative coordinate using the current segment offset and +scaling. The resulting character strings representing the real-valued +coordinates are assigned to the macros specified by <CODE>\<VAR>mx</VAR></CODE> and +<CODE>\<VAR>my</VAR></CODE>. +<A NAME="IDX176"></A> +<DT><CODE>\currentpos \<VAR>mx</VAR>\<VAR>my</VAR></CODE> +<DD> +Return the coordinates of the current position. The coordinates are +relative to the current segment offset and scaling. The resulting +character strings representing the real-valued coordinates are assigned +to the macros specified by <CODE>\<VAR>mx</VAR></CODE> and <CODE>\<VAR>my</VAR></CODE>. +<A NAME="IDX177"></A> +<DT><CODE>\cossin (<VAR>x1</VAR> <VAR>y1</VAR>)(<VAR>x2</VAR> <VAR>y2</VAR>)\<VAR>cosa</VAR>\<VAR>sina</VAR></CODE> +<DD> +Return the cosine and sine of the direction of a vector joining two +points. The cosine and sine of the angle of the vector which goes from +<CODE>(<VAR>x1</VAR> <VAR>y1</VAR>)</CODE> to <CODE>(<VAR>x2</VAR> <VAR>y2</VAR>)</CODE>. The character +strings representing these real-valued quantities are assigned to the +macros specified by <CODE>\<VAR>cosa</VAR></CODE> and <CODE>\<VAR>sina</VAR></CODE>. +<A NAME="IDX178"></A> +<DT><CODE>\vectlen (<VAR>x1</VAR> <VAR>y1</VAR>)(<VAR>x2</VAR> <VAR>y2</VAR>)\<VAR>len</VAR></CODE> +<DD> +Return the length of a vector joining two points. The length of the +vector is relative to the current scaling. The character string +representing the real-valued length is assigned to the macro specified +by <CODE>\<VAR>len</VAR></CODE>. +</DL> + + + +<H2><A NAME="SEC33" HREF="texdraw_toc.html#TOC33">B.2 Real arithmetic</A></H2> + +<P> +The TeXdraw toolbox supplies macros to perform real arithmetic on +coordinate values. The result appears as the value of a user supplied +macro name. +<DL COMPACT> + +<DT><CODE>\realadd {<VAR>value1</VAR>} {<VAR>value2</VAR>} \<VAR>sum</VAR></CODE> +<DD> +<A NAME="IDX179"></A> + +Add two real quantities, assigning the resultant character string +representing the sum to the macro <CODE>\<VAR>sum</VAR></CODE>. +<A NAME="IDX180"></A> +<DT><CODE>\realmult {<VAR>value1</VAR>} {<VAR>value2</VAR>} \<VAR>prod</VAR></CODE> +<DD> +Multiply two real quantities, assigning the resultant character string +representing the product to the macro <CODE>\<VAR>prod</VAR></CODE>. +<A NAME="IDX181"></A> +<DT><CODE>\realdiv {<VAR>value1</VAR>} {<VAR>value2</VAR>} \<VAR>result</VAR></CODE> +<DD> +Divide two real quantities, assigning the resultant character string +representing the result of <VAR>value1</VAR>/<VAR>value2</VAR> to the macro +<CODE>\<VAR>result</VAR></CODE>. +</DL> + + + +<H2><A NAME="SEC34" HREF="texdraw_toc.html#TOC34">B.3 Arrow curve</A></H2> +<P> +<A NAME="IDX182"></A> + + +<P> +This example illustrates the use of the TeXdraw toolbox routines to +do computations with the coordinates. The problem will be tackled in +two parts. First, we will produce a macro to place an arrowhead on a +Bezier curve. Then given this macro, we will produce a macro which can +draw a "wiggly" line from the current position to a given coordinate. + + +<P> +The first macro, <CODE>\cavec</CODE>, uses the <CODE>\cossin</CODE> command to +determine the the cosine and sine of the angle of the line joining the +second control point to the end point of the Bezier curve. Recall that +the Bezier curve is tangent to this line at the end point. After +drawing the Bezier curve, the scaling is set locally to absolute units +of 0.05 inches. We go back down the line from the end point by 0.05 +inches and draw an arrow vector to the end point from there. This arrow +vector is mostly arrowhead, with little or no tail. + + + +<PRE> +\def\cavec (#1 #2)(#3 #4)(#5 #6){ + \clvec (#1 #2)(#3 #4)(#5 #6) + \cossin (#3 #4)(#5 #6)\cosa\sina + \rmove (0 0) + \bsegment + \drawdim in \setsegscale 0.05 + \move ({-\cosa} -\sina) \avec (0 0) + \esegment} +</PRE> + +<P> +Note the use of macros as arguments to a <CODE>\move</CODE> command. Minus +signs are put in front of the macros. However, the value of the macro +<CODE>\cosa</CODE> or <CODE>\sina</CODE> could be negative. Fortunately, TeX +accepts two minus signs in a row and interprets the result as positive. +Note that the <CODE>\rmove (0 0)</CODE> command before the beginning of the +segment ensures that the Bezier curve is stroked before the arrowhead is +drawn. + + +<P> +The second macro <CODE>\caw</CODE> builds on <CODE>\cavec</CODE>. The goal is to +produce a wiggly vector that can be used as a pointer in a drawing. +Consider the following symmetrical normalized Bezier curve. + +<PRE> +\centertexdraw{ \move (0 0) \cavec (1.4 0.1)(-0.4 -0.1)(1 0) } +</PRE> + +<P> +This curve has the appropriate wiggle. Now we want to be able to draw +this curve, appropriately scaled and rotated. The macro <CODE>\caw</CODE> +needs to do computations on the coordinates. First, <CODE>\caw</CODE> uses +the macros <CODE>\getpos</CODE> and <CODE>\currentpos</CODE> to get the positions of +the end and start of the curve. Next, the length of the vector is +calculated using the macro <CODE>\vectlen</CODE>. A local macro +<CODE>\rotatecoord</CODE> is used to rotate a coordinate pair about the +origin, using the cosine and sine of the rotation angle. The vector +length is used to scale the normalized curve. The remaining code draws +the rotated, normalized curve. + + + +<PRE> +\def\caw (#1 #2){ + \currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + +% The nominal wiggly curve is (0 0) (1+dx dy) (-dx -dy) (1 0) +% Find the rotated offset (dx dy) -> (du dv) + \rotatecoord (0.4 0.1)\cosa\sina \du\dv + +% calculate the length of the vector + \vectlen ({\xa} \ya)(#1 #2)\len + +% draw the curve in normalized units + \bsegment + \setsegscale {\len} + \realadd \cosa \du \tmpa \realadd \sina \dv \tmpb + \cavec ({\tmpa} \tmpb)({-\du} -\dv)({\cosa} \sina) + \esegment + \move (#1 #2)} + +% rotate a coordinate (x y) +% arguments: (x y) cosa sina x' y' +% x' = cosa * x - sina * y; y' = sina * x + cosa * y +\def\rotatecoord (#1 #2)#3#4#5#6{ + \getpos (#1 #2)\xarg\yarg + \realmult \xarg {#3} \tmpa \realmult \yarg {#4} \tmpb + \realadd \tmpa {-\tmpb} #5 + \realmult \xarg {#4} \tmpa \realmult \yarg {#3} \tmpb + \realadd \tmpa \tmpb #6} +</PRE> + +<P> +Finally, the new macro can be used as follows. + +<PRE> +\centertexdraw{ + \arrowheadtype t:W + \move (0 0) + \cavec (1.4 0.1)(-0.4 -0.1)(1 0) + \move (1 0) \caw (1 1) \htext{tip at \tt (1 1)} + \move (1 0) \caw (2 1) \htext{tip at \tt (2 1)} + \move (1 0) \caw (2 0) \htext{tip at \tt (2 0)} + +} +</PRE> + +<P> +Note that the Bezier curve in the macro <CODE>\cavec</CODE> lies below the +arrowhead. The example then draws an arrowhead of type <CODE>W</CODE> to +erase the part of the line below the arrowhead. + + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_6.html">previous</A>, <A HREF="texdraw_8.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_8.html b/Master/texmf-dist/doc/texdraw/texdraw_8.html new file mode 100644 index 00000000000..09ee5d14520 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_8.html @@ -0,0 +1,342 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - C. Examples</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_7.html">previous</A>, <A HREF="texdraw_9.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC35" HREF="texdraw_toc.html#TOC35">C. Examples</A></H1> +<P> +<A NAME="IDX183"></A> + + +<P> +This appendix shows examples of the use of TeXdraw. + + + +<UL> +<LI><A HREF="texdraw_8.html#SEC36">Block diagram</A> +<LI><A HREF="texdraw_8.html#SEC37">Filter response graph</A> +<LI><A HREF="texdraw_8.html#SEC38">Geometric construction</A> +</UL> + + + +<H2><A NAME="SEC36" HREF="texdraw_toc.html#TOC36">C.1 Block diagram of a lattice filter</A></H2> + +<P> +The block diagram of a lattice filter uses a library of extended +commands built from the basic TeXdraw commands. + + +<P> +The block diagram uses a "delay" block. This is defined as a segment +which leaves the current position at the end of this block. A second +macro, <CODE>\bdot</CODE>, draws a "big" dot which is used to mark junctions +of lines. The <CODE>\Ttext</CODE> command centers text above a given point. +The offset to position the text is local to a segment, resulting in no +change to the current point. Similar macros to position text below a +point (<CODE>\Btext</CODE>), to the left of a point (<CODE>\Ltext</CODE>) and to the +right of a point (<CODE>\Rtext</CODE>) are used in the final drawing. + +<PRE> +\def\delay {\bsegment + \setsegscale 0.3 + \lvec (0 +0.5) \lvec (1 +0.5) \lvec (1 -0.5) + \lvec (0 -0.5) \lvec (0 0) + \textref h:C v:C \htext (0.5 0){$z^{-1}$} + \savepos (1 0)(*ex *ey) + \esegment + \move (*ex *ey)} +\def\bdot {\fcir f:0 r:0.02 } +\def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 +0.06){#1} + \esegment} +</PRE> + +<P> +Several of the block diagram elements scale with the size of the summing +nodes. The radius of the circles for the summing nodes is defined as +the macro <CODE>\cradius</CODE>. The summing nodes will have enclosed plus +signs, appropriately scaled. The plus sign is drawn by the macro +<CODE>\pluss</CODE>. The macro <CODE>\pcir</CODE> draws both the circle and the +plus sign. The incoming lines to a summing node will be labelled with +plus or minus signs (characters this time), placed at the appropriate +position with respect to the center of the summing node. These +positions are given in terms of compass directions. The macro +<CODE>\putwnw</CODE> places text west by north-west relative to the center of +the summing node. + +<PRE> +\def\cradius {0.08} +\def\pluss {\bsegment + \setsegscale {\cradius} + \move (-0.5 0) \lvec (+0.5 0) + \move (0 -0.5) \lvec (0 +0.5) + \esegment} +\def\pcir {\lcir r:{\cradius} \pluss} +\def\puttext (#1 #2)#3{\bsegment + \setsegscale {\cradius} + \textref h:C v:C \htext (#1 #2){#3} + \esegment} +\def\putwnw #1{\puttext (-1.7 +1.2){#1}} +</PRE> + +<P> +The block diagram has vectors arriving and departing from the summing +nodes (circles). One could calculate the points of intersection of the +lines with the circles, and then enter the values into the TeXdraw +code. However, in this example, we implement an automated procedure. +Two macros are needed, an arrow vector to a circle (<CODE>\avectoc</CODE>) and +an arrow vector leaving from a circle (<CODE>\avecfrc</CODE>). The macros +will calculate the point of intersection with the circle and start or +end the vector at the intersection point. + + +<P> +The arrow macros use scaling and relative positioning inside of a +drawing segment. In the case of the macro <CODE>\avectoc</CODE>, a move is +made to the final point (center of the circle), then within a drawing +segment, a scaled move is made back towards the initial point to +determine the intersection point with the circle. + + + +<PRE> +\def\avectoc (#1 #2){\currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + \savepos (#1 #2)(*tx *ty) + \bsegment + \move (*tx *ty) + \setsegscale {\cradius} + \rmove ({-\cosa} -\sina) + \savecurrpos (*ex *ey) + \esegment + \avec (*ex *ey) + \move (#1 #2)} +\def\avecfrc (#1 #2){\currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + \bsegment + \setsegscale {\cradius} + \move ({\cosa} \sina) + \savecurrpos (*ex *ey) + \esegment + \move (*ex *ey) + \avec (#1 #2)} +</PRE> + +<P> +Having defined these macros, we are ready to draw the block diagram. +The first and last sections of the lattice filter are very similar, +differing mainly in the text labels. With more effort, code could be +shared between the commands used to draw these blocks. + +<PRE> +\centertexdraw{ +\drawdim in +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\pl {$\scriptscriptstyle +$} \def\mn {$\scriptscriptstyle -$} + +\move (0 +0.63) \move (0 -0.60) \move (0 0) % compensate for the text size + +% Input to the first stage +\bsegment + \Ltext{$x(n)$} + \lvec (0.3 0) \bdot \lvec (0.3 +0.4) \move (0.3 0) \lvec (0.3 -0.4) + \savepos (0.3 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% first lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw{\pl} \puts{\mn} + \avecfrc (2.1 +0.4) + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw{\pl} \putn{\mn} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext {$f_0(n)$} + \move (2.0 +0.42) \Ttext {$f_1(n)$} + \move (0.1 -0.4) \Btext {$b_0(n)$} + \move (2.0 -0.4) \Btext {$b_1(n)$} + \textref h:L v:B \htext (1.15 +0.2){$K_1$} + \textref h:L v:T \htext (1.15 -0.2){$K_1$} + \savepos (2.1 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% center section +\bsegment + \textref h:C v:C \htext (0.3 +0.4){$\cdots$} + \htext (0.3 -0.4){$\cdots$} + \savepos (0.6 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% last lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw{\pl} \puts{\mn} + \avecfrc (2.3 +0.4) \Rtext{$e(n)$} + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw{\pl} \putn{\mn} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext {$f_{P-1}(n)$} + \move (2.0 +0.42) \Ttext {$f_P(n)$} + \move (0.1 -0.4) \Btext {$b_{P-1}(n)$} + \move (2.0 -0.4) \Btext {$b_P(n)$} + \textref h:L v:B \htext (1.15 +0.2){$K_P$} + \textref h:L v:T \htext (1.15 -0.2){$K_P$} +\esegment +} +</PRE> + +<P> +The macros used in this example are similar to the block diagram macros +defined in the file <TT>`blockdiagram.tex'</TT>. + + + + +<H2><A NAME="SEC37" HREF="texdraw_toc.html#TOC37">C.2 Filter response graph</A></H2> +<P> +<A NAME="IDX184"></A> + + +<P> +This example shows the response of a canonical filter. TeXdraw is +not well suited for general purpose graphing -- it has no coordinate +translation facility nor does it have separate <VAR>x</VAR> and <VAR>y</VAR> +scaling. Nonetheless, for certain simple graphs, TeXdraw is +adequate. + + +<P> +In this example, macro <CODE>\ticklab</CODE> places a labelled axis tick at a +given position. The data is specified in a straightforward manner, +having been scaled beforehand to give the desired aspect ratio for the +graph. + + + +<PRE> +\centertexdraw{ +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\ds {\displaystyle} +\def\ticklab (#1 #2)#3{\move(#1 #2) + \bsegment + \lvec (0 0.05) + \textref h:C v:T \htext (0 -0.05){#3} + \esegment} +\def\Rtext #1{\bsegment + \textref h:L v:C \htext (+0.08 0){#1} + \esegment} + +\move (2.4 -0.3) % move to set the size + +\move (0 0) +% Axes +\avec (0 +1.4) +\move (0 0) \avec (2.2 0) \Rtext{$\omega$} +\ticklab (0 0) {0} +\ticklab (0.8 0) {$\ds {\pi \over 2N} $} +\ticklab (1.2 0) {$\omega_s$} +\ticklab (1.6 0) {$\ds {\pi \over N} $} + +\linewd 0.025 +\move (0 1) +\lvec (0.4 1) +\lvec (0.44 0.998) +\lvec (0.48 0.988) +\lvec (0.52 0.973) +\lvec (0.56 0.951) + ... +\lvec (1.08 0.233) +\lvec (1.12 0.156) +\lvec (1.16 0.078) +\lvec (1.20 0) +\lvec (1.9 0) +} +</PRE> + + + +<H2><A NAME="SEC38" HREF="texdraw_toc.html#TOC38">C.3 Geometric construction</A></H2> +<P> +<A NAME="IDX185"></A> + + +<P> +This example shows a geometric construction which places an ellipse +tangent to an enclosing circle. The size of the ellipse is determined +from geometric considerations. Macros are used to modularize the code. +The example alters the unit scale factor. This allows the drawing to be +carried out in units normalized to the radius of the circle. + + + +<PRE> +\centertexdraw{ +\arrowheadtype t:V \arrowheadsize l:0.08 w:0.04 +\linewd 0.01 +\setunitscale 1.5 % circle will have radius 1.5 inches + +\def\Btext #1{\bsegment + \textref h:C v:T \htext (0 -0.04){#1} + \esegment} +\def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 +0.04){#1} + \esegment} +\def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.04 0){#1} + \esegment} +\def\bdot {\fcir f:0 r:0.0133 } +\def\vtick {\bsegment + \move (0 -0.05) \lvec (0 +0.05) + \esegment} +\def\htick {\bsegment + \move (-0.05 0) \lvec (+0.05 0) + \esegment} +\def\Hlen #1#2{\bsegment + \vtick \avec ({#1} 0) \vtick \avec (0 0) + \relsegscale 0.5 + \move ({#1} 0) \Ttext {#2} + \esegment} +\def\Vlen #1#2{\bsegment + \htick \avec (0 {#1}) \htick \avec (0 0) + \relsegscale 0.5 + \move (0 {#1}) \Ltext {#2} + \esegment} + +\lcir r:1 % circle +\move (-1.05 0) \lvec ( 1.05 0) % axes +\move (0 -1.05) \lvec (0 1.05) + +\move (0 0) \lvec (0.707 0.707) \bdot +\rmove (0.02 0.02) \textref h:L v:B \htext {X} +\move (0.707 -0.707) \bdot +\textref h:R v:T \htext(-0.02 -0.02){O} + +\move (0.5 0) % center of ellipse +\bsegment + \lellip rx:0.435 ry:0.804 + \bdot \Btext {$\beta_2$} + \move (0 0.15) \Hlen {0.435}{$|\beta_1{+}\beta_3|$} + \move (-0.7 0) \Vlen {0.804}{$|\beta_1{-}\beta_3|$} +\esegment +} +</PRE> + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_7.html">previous</A>, <A HREF="texdraw_9.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_9.html b/Master/texmf-dist/doc/texdraw/texdraw_9.html new file mode 100644 index 00000000000..6a96d49c59d --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_9.html @@ -0,0 +1,321 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - D. Alphabetic listing of commands</TITLE> +</HEAD> +<BODY> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_8.html">previous</A>, <A HREF="texdraw_10.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +<P><HR><P> + + +<H1><A NAME="SEC39" HREF="texdraw_toc.html#TOC39">D. Alphabetic listing of commands</A></H1> +<P> +<A NAME="IDX186"></A> + + +<DL COMPACT> + +<DT><CODE>\arrowheadsize l:<VAR>length</VAR> w:<VAR>width</VAR></CODE> +<DD> +Set the arrowhead size to be <VAR>length</VAR> units long and <VAR>width</VAR> +units wide. The width is measured across the "base" of the arrowhead. +The initial arrowhead size has a <VAR>length</VAR> of 0.16 inches and a +<VAR>width</VAR> of 0.08 inches. + +<DT><CODE>\arrowheadtype t:<VAR>type</VAR></CODE> +<DD> +Set the arrowhead type to <VAR>type</VAR>, where <VAR>type</VAR> is one of +<CODE>F</CODE>, <CODE>T</CODE>, <CODE>W</CODE>, <CODE>V</CODE>, or <CODE>H</CODE>. There are two +kinds of arrowheads. The first kind is a triangle. There are 3 +variants: type <CODE>T</CODE> is an empty triangle, type <CODE>F</CODE> is a filled +triangle (using the current gray level for lines), type <CODE>W</CODE> is a +triangle filled with white. The second kind of arrowhead is an open +ended Vee. There are 2 variants: type <CODE>V</CODE> has the stem continue to +the tip, type <CODE>H</CODE> has the stem stop at the base of the arrowhead. +The initial arrowhead type is <CODE>T</CODE>. + +<DT><CODE>\avec (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +Draw a line with an arrowhead from the current position to +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The arrowhead is aligned with the line, with the tip at +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. + +<DT><CODE>\begin{texdraw}</CODE> +<DD> +Start a TeXdraw drawing. The drawing is terminated with an +<CODE>\end{texdraw}</CODE> command. This command is for use with LaTeX. + +<DT><CODE>\bsegment</CODE> +<DD> +Start a drawing segment. The coordinate system is shifted such that the +current position corresponds to the coordinate <CODE>(0 0)</CODE>. Changes to +scaling, position and line parameters stay local to the drawing segment. + +<DT><CODE>\btexdraw</CODE> +<DD> +Start a TeXdraw drawing. The drawing is terminated with an +<CODE>\etexdraw</CODE> command. + +<DT><CODE>\centertexdraw { ... }</CODE> +<DD> +Center a TeXdraw box. The argument contains TeXdraw commands. +The resulting box has the horizontal size <CODE>\hsize</CODE> and height equal +to the height of the drawing. + +<DT><CODE>\clvec (<VAR>x1</VAR> <VAR>y1</VAR>)(<VAR>x2</VAR> <VAR>y2</VAR>)(<VAR>x3</VAR> <VAR>y3</VAR>)</CODE> +<DD> +Draw a Bezier curve from the current position to the coordinate +<CODE>(<VAR>x3</VAR> <VAR>y3</VAR>)</CODE> which becomes the new current position. The +coordinates <CODE>(<VAR>x1</VAR> <VAR>y1</VAR>)</CODE> and <CODE>(<VAR>x2</VAR> <VAR>y2</VAR>)</CODE> +serve as control points for the curve. Only the last coordinate given +is used to update the size of the drawing. + +<DT><CODE>\drawbb</CODE> +<DD> +Draw a ruled box around the effective size of a drawing produced by +TeXdraw commands. + +<DT><CODE>\drawdim <VAR>dim</VAR></CODE> +<DD> +Set the units to <VAR>dim</VAR>. The argument <VAR>dim</VAR> can be any valid +TeX dimension unit. The units are used to interpret coordinate +values. Examples of valid units: <CODE>cm</CODE>, <CODE>mm</CODE>, <CODE>in</CODE>, +<CODE>pt</CODE>, and <CODE>bp</CODE>. + +<DT><CODE>\end{texdraw}</CODE> +<DD> +End a TeXdraw drawing started with a <CODE>\begin{texdraw}</CODE> +command. The resulting TeXdraw drawing is placed in a box with +height equal to the height of the drawing and width equal to the width +of the drawing. The depth of the box is zero. This command is for use +with LaTeX. + +<DT><CODE>\esegment</CODE> +<DD> +End a drawing segment. The current position in effect before the +corresponding <CODE>\bsegment</CODE> command is restored. The scaling and +line parameter values revert to those in effect before the corresponding +<CODE>\bsegment</CODE> was invoked. + +<DT><CODE>\etexdraw</CODE> +<DD> +End a TeXdraw drawing started with a <CODE>\btexdraw</CODE> command. The +resulting TeXdraw drawing is placed in a box with height equal to the +height of the drawing and width equal to the width of the drawing. The +depth of the box is zero. + +<DT><CODE>\everytexdraw { ... }</CODE> +<DD> +Specify TeXdraw commands to be executed at the beginning of every +TeXdraw drawing. + +<DT><CODE>\fcir f:<VAR>level</VAR> r:<VAR>radius</VAR></CODE> +<DD> +Draw a filled circle with center at the current position. The radius is +specified by <VAR>radius</VAR>. The circle is painted with the gray level +specified by <VAR>level</VAR>. A gray level of 1 corresponds to white, with +decreasing values getting darker. The level 0 is full black. This +command does not draw a line along the circumference. The drawing size +is increased if necessary to contain the circle. + +<DT><CODE>\fellip f:<VAR>level</VAR> rx:<VAR>x-radius</VAR> ry:<VAR>y-radius</VAR></CODE> +<DD> +Draw a filled ellipse with center at the current position. The radius +in the <VAR>x</VAR> direction is specified by <VAR>x-radius</VAR>. The radius in +the <VAR>y</VAR> direction is specified by <VAR>y-radius</VAR>. The ellipse is +painted with the gray level specified by <VAR>level</VAR>. A gray level of 1 +corresponds to white, with decreasing values getting darker. The level +0 is full black. This command does not draw a line along the boundary +of the ellipse. The drawing size is increased if necessary to contain +the ellipse. + +<DT><CODE>\htext (<VAR>x</VAR> <VAR>y</VAR>){<VAR>text</VAR>}</CODE> +<DD> +<DT><CODE>\htext {<VAR>text</VAR>}</CODE> +<DD> +The first form of this command places the TeX text <VAR>text</VAR> +horizontally with the text reference point at the coordinate +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The second form of this command places the TeX text +<VAR>text</VAR> horizontally with the text reference point at the current +position. The text reference point is set with the <CODE>\textref</CODE> +command. + +<DT><CODE>\ifill f:<VAR>level</VAR></CODE> +<DD> +Close the current path and paint the interior of the region with gray +level <VAR>level</VAR>. The line around the path is not drawn. Gray levels +are real values from 0 (black) through intermediate values (grays) to 1 +(white). + +<DT><CODE>\larc r:<VAR>radius</VAR> sd:<VAR>start-angle</VAR> ed:<VAR>end-angle</VAR></CODE> +<DD> +Draw a counterclockwise arc. The center of the arc is at the current +position. The radius is specified by <VAR>radius</VAR>. The start and end +angles (in degrees) are specified by <VAR>start-angle</VAR> and +<VAR>end-angle</VAR>. This command does not affect the limits (size) of the +drawing. + +<DT><CODE>\lcir r:<VAR>radius</VAR></CODE> +<DD> +Draw a circle with center at the current position. The radius is +specified by <VAR>radius</VAR>. This command draws a line along the +circumference of the circle. The drawing size is increased if necessary +to contain the circle. + +<DT><CODE>\lellip rx:<VAR>x-radius</VAR> ry:<VAR>y-radius</VAR></CODE> +<DD> +Draw an ellipse with center at the current position. The radius in the +<VAR>x</VAR> direction is specified by <VAR>x-radius</VAR>. The radius in the +<VAR>y</VAR> direction is specified by <VAR>y-radius</VAR>. The drawing size is +increased if necessary to contain the ellipse. + +<DT><CODE>\lfill f:<VAR>level</VAR></CODE> +<DD> +Close the current path, draw the line around the path using the current +grey level for lines and paint the interior of the region with specified +gray level <VAR>level</VAR>. Gray levels are real values from 0 (black) +through intermediate values (grays) to 1 (white). + +<DT><CODE>\linewd <VAR>width</VAR></CODE> +<DD> +Set the line width to <VAR>width</VAR> units. Initially <VAR>width</VAR> is 0.01 +inches (corresponding to 3 pixels at 300 pixels to the inch). + +<DT><CODE>\lpatt (<VAR>pattern</VAR>)</CODE> +<DD> +Set lines to have the pattern <CODE>(<VAR>pattern</VAR>)</CODE>. A pattern is a +sequence of on/off lengths separated by blanks and enclosed in parentheses. +The lengths alternately specify the length of a dash and the length of a +gap between dashes. Each length is interpreted using the current +scaling and drawing units. The pattern is used cyclically. The empty +pattern signifies a solid line. The initial line pattern is a solid +line, corresponding to the empty pattern <CODE>\lpatt ()</CODE>. + +<DT><CODE>\lvec (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +Draw a line from the current position to coordinate <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. + +<DT><CODE>\move (<VAR>x</VAR> <VAR>y</VAR>)</CODE> +<DD> +Move to coordinate <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The new current position +is <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. + +<DT><CODE>\ravec (<VAR>dx</VAR> <VAR>dy</VAR>)</CODE> +<DD> +Draw a line with an arrowhead from the current position, <VAR>dx</VAR> units +in the <VAR>x</VAR> direction and <VAR>y</VAR> units in the <VAR>y</VAR> direction. +The final position becomes the new current position. The arrowhead is +aligned with the line, with the tip at the new current position. + +<DT><CODE>\relsegscale <VAR>value</VAR></CODE> +<DD> +Adjust the segment scale factor by multiplying by <VAR>value</VAR>. This has +the effect of multiplying the current overall scale factor by the same +factor. The overall scaling factor is the product of the unit scale +factor and the segment scale factor. + +<DT><CODE>\relunitscale <VAR>value</VAR></CODE> +<DD> +Adjust the unit scale factor by multiplying by <VAR>value</VAR>. This has +the effect of multiplying the overall scale factor by the same factor. +The overall scaling factor is the product of the unit scale factor and +the segment scale factor. + +<DT><CODE>\rlvec (<VAR>dx</VAR> <VAR>dy</VAR>)</CODE> +<DD> +Draw a line from the current position, <VAR>dx</VAR> units in the <VAR>x</VAR> +direction and <VAR>dy</VAR> units in the <VAR>y</VAR> direction. The final +position becomes the new current position. + +<DT><CODE>\rmove (<VAR>dx</VAR> <VAR>dy</VAR>)</CODE> +<DD> +Move from the current position, <VAR>dx</VAR> units in the <VAR>x</VAR> direction +and <VAR>dy</VAR> units in the <VAR>y</VAR> direction. The final position becomes +the new current position. + +<DT><CODE>\rtext td:<VAR>angle</VAR> (x y){<VAR>text</VAR>}</CODE> +<DD> +<DT><CODE>\rtext td:<VAR>angle</VAR> {<VAR>text</VAR>}</CODE> +<DD> +The first form of this command places the TeX text <VAR>text</VAR> at an +angle with the text reference point at the coordinate <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The +second form of this command places the TeX text <VAR>text</VAR> at an +angle with the text reference point at the current position. In both +cases, the TeX text is placed in a box and the box is rotated +counterclockwise by <VAR>angle</VAR> degrees about the text reference point. +The text reference point is set with the <CODE>\textref</CODE> command. + +<DT><CODE>\savecurrpos (*<VAR>px</VAR> *<VAR>py</VAR>)</CODE> +<DD> +Save the current position as the absolute position referenced by +<CODE>(*<VAR>px</VAR> *<VAR>py</VAR>)</CODE>. + +<DT><CODE>\savepos (<VAR>x</VAR> <VAR>y</VAR>)(*<VAR>px</VAR> *<VAR>py</VAR>)</CODE> +<DD> +Save the coordinate position <CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE> as the absolute +position referenced by <CODE>(*<VAR>px</VAR> *<VAR>py</VAR>)</CODE>. The coordinate +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE> is interpreted in the normal fashion as a +coordinate relative to the current segment, using the current scaling +factors and drawing unit. + +<DT><CODE>\setgray <VAR>level</VAR></CODE> +<DD> +Set the gray level of lines. Gray levels are real values from 0 (black) +through intermediate values (gray) to 1 (white). The initial gray level +is 0 corresponding to black. + +<DT><CODE>\setsegscale <VAR>scale</VAR></CODE> +<DD> +Set the segment scale factor. The argument <VAR>scale</VAR> is a real number +which is used to scale coordinate values. The overall scale factor is +the product of the unit scale factor and the segment scale factor. + +<DT><CODE>\setunitscale <VAR>scale</VAR></CODE> +<DD> +Set the unit scaling to <VAR>scale</VAR>. The argument <VAR>scale</VAR> is a real +number which is used to scale coordinate values. The overall scaling +factor is the product of the unit scale factor and the segment scale +factor. + +<DT><CODE>\texdrawbox { ... }</CODE> +<DD> +Create a TeXdraw box. The argument contains TeXdraw commands. +This macro returns a TeX box with height equal to the height of the +drawing and width equal to the width of the drawing. The depth of the +box is zero. + +<DT><CODE>\textref h:<VAR>h-ref</VAR> v:<VAR>v-ref</VAR></CODE> +<DD> +Set the text reference point for subsequent text commands. The +horizontal reference point <VAR>h-ref</VAR> is one of <CODE>L</CODE>, <CODE>C</CODE> or +<CODE>R</CODE> (left, center or right). The vertical reference point +<VAR>v-ref</VAR> is one of <CODE>T</CODE>, <CODE>C</CODE> or <CODE>B</CODE> (top, center or +bottom). For rotated text, the reference point is determined before +rotation. The initial text reference point corresponds to +<CODE>\textref h:L v:B</CODE>. + +<DT><CODE>\vtext (x y){<VAR>text</VAR>}</CODE> +<DD> +<DT><CODE>\vtext {<VAR>text</VAR>}</CODE> +<DD> +The first form of this command places the TeX text <VAR>text</VAR> +vertically with the text reference point at the coordinate +<CODE>(<VAR>x</VAR> <VAR>y</VAR>)</CODE>. The new current position is <CODE>(<VAR>x</VAR> +<VAR>y</VAR>)</CODE>. The second form of this command places the TeX text +<VAR>text</VAR> vertically with the text reference point at the current +position. In both cases, the TeX text is placed in a box and the box +is rotated counterclockwise by 90 degrees about the text reference +point. The text reference point is set with the <CODE>\textref</CODE> +command. + +</DL> + +<P><HR><P> +Go to the <A HREF="texdraw_1.html">first</A>, <A HREF="texdraw_8.html">previous</A>, <A HREF="texdraw_10.html">next</A>, <A HREF="texdraw_11.html">last</A> section, <A HREF="texdraw_toc.html">table of contents</A>. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_foot.html b/Master/texmf-dist/doc/texdraw/texdraw_foot.html new file mode 100644 index 00000000000..b45e6c36d32 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_foot.html @@ -0,0 +1,25 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - Footnotes</TITLE> +</HEAD> +<BODY> +<H1>TeXdraw</H1> +<H2>PostScript Drawings from TeX</H2> +<H2>Edition 2.0</H2> +<H2>December 1995</H2> +<ADDRESS>Peter Kabal</ADDRESS> +<P> +<P><HR><P> +<H3><A NAME="FOOT1" HREF="texdraw_2.html#DOCF1">(1)</A></H3> +<P>After the ninth PostScript file, the name of the +intermediate PostScript file takes the form <TT>`<VAR>name</VAR>.p10'</TT>, with +the number increasing from 10 with each file. +<H3><A NAME="FOOT2" HREF="texdraw_5.html#DOCF2">(2)</A></H3> +<P>Not all PostScript drivers support text rotation. +<P><HR><P> +This document was generated on 10 March 2004 using +<A HREF="http://wwwinfo.cern.ch/dis/texi2html/">texi2html</A> 1.56k. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texdraw_toc.html b/Master/texmf-dist/doc/texdraw/texdraw_toc.html new file mode 100644 index 00000000000..fdf24359723 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texdraw_toc.html @@ -0,0 +1,78 @@ +<HTML> +<HEAD> +<!-- Created by texi2html 1.56k from texdraw.texi on 10 March 2004 --> + +<TITLE>TeXdraw - Table of Contents</TITLE> +</HEAD> +<BODY> +<H1>TeXdraw</H1> +<H2>PostScript Drawings from TeX</H2> +<H2>Edition 2.0</H2> +<H2>December 1995</H2> +<ADDRESS>Peter Kabal</ADDRESS> +<P> +<P><HR><P> +<UL> +<LI><A NAME="TOC1" HREF="texdraw_1.html#SEC1">1. Introduction</A> +<UL> +<LI><A NAME="TOC2" HREF="texdraw_1.html#SEC2">1.1 Distribution information</A> +</UL> +<LI><A NAME="TOC3" HREF="texdraw_2.html#SEC3">2. Using the TeXdraw Commands</A> +<UL> +<LI><A NAME="TOC4" HREF="texdraw_2.html#SEC4">2.1 Accessing TeXdraw</A> +<LI><A NAME="TOC5" HREF="texdraw_2.html#SEC5">2.2 Command syntax</A> +<LI><A NAME="TOC6" HREF="texdraw_2.html#SEC6">2.3 TeXdraw coordinates</A> +<LI><A NAME="TOC7" HREF="texdraw_2.html#SEC7">2.4 Coordinate specification</A> +<LI><A NAME="TOC8" HREF="texdraw_2.html#SEC8">2.5 Line vectors</A> +<LI><A NAME="TOC9" HREF="texdraw_2.html#SEC9">2.6 TeX text</A> +<LI><A NAME="TOC10" HREF="texdraw_2.html#SEC10">2.7 Circles, ellipses and arcs</A> +<LI><A NAME="TOC11" HREF="texdraw_2.html#SEC11">2.8 Bezier curves</A> +<LI><A NAME="TOC12" HREF="texdraw_2.html#SEC12">2.9 Fill commands</A> +</UL> +<LI><A NAME="TOC13" HREF="texdraw_3.html#SEC13">3. Drawing Segments and Scaling</A> +<UL> +<LI><A NAME="TOC14" HREF="texdraw_3.html#SEC14">3.1 Drawing segments</A> +<LI><A NAME="TOC15" HREF="texdraw_3.html#SEC15">3.2 Drawing paths</A> +<LI><A NAME="TOC16" HREF="texdraw_3.html#SEC16">3.3 Saving positions</A> +<LI><A NAME="TOC17" HREF="texdraw_3.html#SEC17">3.4 Scaling coordinates</A> +<LI><A NAME="TOC18" HREF="texdraw_3.html#SEC18">3.5 Drawing size</A> +<LI><A NAME="TOC19" HREF="texdraw_3.html#SEC19">3.6 Initial current position</A> +</UL> +<LI><A NAME="TOC20" HREF="texdraw_4.html#SEC20">4. Using TeXdraw with LaTeX</A> +<UL> +<LI><A NAME="TOC21" HREF="texdraw_4.html#SEC21">4.1 PostScript printer drivers</A> +</UL> +<LI><A NAME="TOC22" HREF="texdraw_5.html#SEC22">5. More Details</A> +<UL> +<LI><A NAME="TOC23" HREF="texdraw_5.html#SEC23">5.1 Errors while using TeXdraw</A> +<LI><A NAME="TOC24" HREF="texdraw_5.html#SEC24">5.2 Extending TeXdraw</A> +<UL> +<LI><A NAME="TOC25" HREF="texdraw_5.html#SEC25">5.2.1 Scaling</A> +<LI><A NAME="TOC26" HREF="texdraw_5.html#SEC26">5.2.2 Resolution</A> +<LI><A NAME="TOC27" HREF="texdraw_5.html#SEC27">5.2.3 Text placement</A> +<LI><A NAME="TOC28" HREF="texdraw_5.html#SEC28">5.2.4 The intermediate PostScript file</A> +</UL> +<LI><A NAME="TOC29" HREF="texdraw_5.html#SEC29">5.3 How TeXdraw merges graphics and text</A> +</UL> +<LI><A NAME="TOC30" HREF="texdraw_6.html#SEC30">A. PostScript Commands</A> +<LI><A NAME="TOC31" HREF="texdraw_7.html#SEC31">B. TeXdraw Toolbox</A> +<UL> +<LI><A NAME="TOC32" HREF="texdraw_7.html#SEC32">B.1 Coordinate parsing</A> +<LI><A NAME="TOC33" HREF="texdraw_7.html#SEC33">B.2 Real arithmetic</A> +<LI><A NAME="TOC34" HREF="texdraw_7.html#SEC34">B.3 Arrow curve</A> +</UL> +<LI><A NAME="TOC35" HREF="texdraw_8.html#SEC35">C. Examples</A> +<UL> +<LI><A NAME="TOC36" HREF="texdraw_8.html#SEC36">C.1 Block diagram of a lattice filter</A> +<LI><A NAME="TOC37" HREF="texdraw_8.html#SEC37">C.2 Filter response graph</A> +<LI><A NAME="TOC38" HREF="texdraw_8.html#SEC38">C.3 Geometric construction</A> +</UL> +<LI><A NAME="TOC39" HREF="texdraw_9.html#SEC39">D. Alphabetic listing of commands</A> +<LI><A NAME="TOC40" HREF="texdraw_10.html#SEC40">Command Index</A> +<LI><A NAME="TOC41" HREF="texdraw_11.html#SEC41">Concept Index</A> +</UL> +<P><HR><P> +This document was generated on 10 March 2004 using +<A HREF="http://wwwinfo.cern.ch/dis/texi2html/">texi2html</A> 1.56k. +</BODY> +</HTML> diff --git a/Master/texmf-dist/doc/texdraw/texi2dvi b/Master/texmf-dist/doc/texdraw/texi2dvi new file mode 100644 index 00000000000..45e92ff8e7f --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texi2dvi @@ -0,0 +1,275 @@ +#! /bin/sh +# texi2dvi --- smartly produce DVI files from texinfo sources + +# Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + +# $Id: texi2dvi,v 1.7 1995/11/03 texdraw-V2R0 $ + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you can either send email to this +# program's maintainer or write to: The Free Software Foundation, +# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. + +# Commentary: + +# Author: Noah Friedman <friedman@prep.ai.mit.edu> + +# Please send bug reports, etc. to bug-texinfo@prep.ai.mit.edu +# If possible, please send a copy of the output of the script called with +# the `--debug' option when making a bug report. + +# In the interest of general portability, some common bourne shell +# constructs were avoided because they weren't guaranteed to be available +# in some earlier implementations. I've tried to make this program as +# portable as possible. Welcome to unix, where the lowest common +# denominator is rapidly diminishing. +# +# Among the more interesting lossages I noticed with some bourne shells +# are: +# * No shell functions. +# * No `unset' builtin. +# * `shift' cannot take a numeric argument, and signals an error if +# there are no arguments to shift. + +# Code: + +# Name by which this script was invoked. +progname=`echo "$0" | sed -e 's/[^\/]*\///g'` + +# This string is expanded by rcs automatically when this file is checked out. +rcs_revision='$Revision: 1.7 $' +version=`set - $rcs_revision; echo $2` + +# To prevent hairy quoting and escaping later. +bq='`' +eq="'" + +usage="Usage: $progname {options} [file1] {file2 {...}} +(version $version) + +Options are: +-D, --debug Turn on shell debugging ($bq${bq}set -x$eq$eq). +-h, --help You're looking at it. +-v, --version Print version number. + +Arguments in brackets are required. Those in braces are optional. +" + +# Initialize variables. +# Don't use `unset' since old bourne shells don't have this command. +# Instead, assign them an empty value. +# Some of these, like TEX and TEXINDEX, may be inherited from the environment +backup_extension=.bak +debug= +orig_pwd="`pwd`" +verbose= +texindex="${TEXINDEX-texindex}" +tex="${TEX-tex}" + +# Save this so we can construct a new TEXINPUTS path for each file to be +# processed. +TEXINPUTS_orig="$TEXINPUTS" +export TEXINPUTS + +# Parse command line arguments. +# Make sure that all wildcarded options are long enough to be unambiguous. +# It's a good idea to document the full long option name in each case. +# Long options which take arguments will need a `*' appended to the +# canonical name to match the value appended after the `=' character. +while : ; do + case $# in 0) break ;; esac + case "$1" in + -D | --debug | --d* ) + debug=t + shift + ;; + -h | --help | --h* ) + echo "$usage" 1>&2 + exit 0 + ;; + -v | --version | --v* ) + echo "texi2dvi version $version" 1>&2 + exit 0 + ;; + -- ) # Stop option processing + shift + break + ;; + -* ) + case "$1" in + --*=* ) arg=`echo "$1" | sed -e 's/=.*//'` ;; + * ) arg="$1" ;; + esac + exec 1>&2 + echo "$progname: unknown or ambiguous option $bq$arg$eq" + echo "$progname: Use $bq--help$eq for a list of options." + exit 1 + ;; + * ) + break + ;; + esac +done + +# See if there are any command line args left (which will be interpreted as +# filename arguments) +case $# in + 0 ) + exec 1>&2 + echo "$progname: at least one file name is required as an argument." + echo "$progname: Use $bq--help$eq for a description of command syntax." + exit 2 + ;; +esac + +case "$debug" in t ) set -x ;; esac + +# Texify files +for command_line_filename in ${1+"$@"} ; do + # Roughly equivalent to `dirname ...`, but more portable + directory="`echo ${command_line_filename} | sed 's/\/[^\/]*$//'`" + filename_texi="`basename ${command_line_filename}`" + # Strip off the last extension part (probably .texinfo or .texi) + filename_noext="`echo ${filename_texi} | sed 's/\.[^.]*$//'`" + + # If directory and file are the same, then it's probably because there's + # no pathname component. Set dirname to `.', the current directory. + if test "z${directory}" = "z${command_line_filename}" ; then + directory="." + fi + + # Source file might @include additional texinfo sources. Put `.' and + # directory where source file(s) reside in TEXINPUTS before anything + # else. `.' goes first to ensure that any old .aux, .cps, etc. files in + # ${directory} don't get used in preference to fresher files in `.'. + TEXINPUTS=".:${directory}:${TEXINPUTS_orig}" + + # "Unset" variables that might have values from previous iterations and + # which won't be completely reset later. + definite_index_files="" + + # See if file exists here. If it doesn't we're in trouble since, even + # though the user may be able to reenter a valid filename at the tex + # prompt (assuming they're attending the terminal), this script won't be + # able to find the right index files and so forth. + if test ! -r "${command_line_filename}" ; then + echo "${progname}: ${command_line_filename}: No such file or permission denied." 1>&2 + continue; + fi + + # Find all files having root filename with a two-letter extension, + # determine whether they're really index files, and save them. Foo.aux + # is actually the cross-references file, but we need to keep track of + # that too. + possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" + for this_file in ${possible_index_files} ; do + # If file is empty, forget it. + if test ! -s "${this_file}" ; then + continue; + fi + + # Examine first character of file. If it's not a backslash or + # single quote, then it's definitely not an index or xref file. + first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" + if test "${first_character}" = "\\" -o "${first_character}" = "'" ; then + definite_index_files="${definite_index_files} ${this_file}" + fi + done + orig_index_files="${definite_index_files}" + orig_index_files_sans_aux="`echo ${definite_index_files} \ + | sed 's/'${filename_noext}'\.aux//; + s/^[ ]*//;s/[ ]*$//;'`" + + # Now save copies of original index files so we have some means of + # comparison later. + for index_file_to_save in ${orig_index_files} ; do + cp "${index_file_to_save}" "${index_file_to_save}${backup_extension}" + done + + # Run texindex on current index files. If they already exist, and + # after running TeX a first time the index files don't change, then + # there's no reason to run TeX again. But we won't know that if the + # index files are out of date or nonexistent. + if test "${orig_index_files_sans_aux}" ; then + ${texindex} ${orig_index_files_sans_aux} + fi + + if ${tex} ${command_line_filename} ; then # TeX run first time + definite_index_files="" + # Get list of new index files + possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" + for this_file in ${possible_index_files} ; do + # If file is empty, forget it. + if test ! -s ${this_file} ; then + continue; + fi + + # Examine first character of file. If it's not a backslash or + # single quote, then it's definitely not an index or xref file. + first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" + if test "${first_character}" = "\\" -o "${first_character}" = "'" ; then + definite_index_files="${definite_index_files} ${this_file}" + fi + done + new_index_files="${definite_index_files}" + new_index_files_sans_aux="`echo ${definite_index_files} \ + | sed 's/'${filename_noext}'\.aux//; + s/^[ ]*//;s/[ ]*$//;'`" + + # If old and new list don't at least have the same file list, then one + # file or another has definitely changed. + if test "${orig_index_files}" != "${new_index_files}" ; then + index_files_changed_p=t + else + # File list is the same. We must compare each file until we find a + # difference. + index_files_changed_p="" + for this_file in ${new_index_files} ; do + # cmp -s will return nonzero exit status if files differ. + cmp -s "${this_file}" "${this_file}${backup_extension}" + if test $? -ne 0 ; then + # We only need to keep comparing until we find *one* that + # differs, because we'll have to run texindex & tex no + # matter what. + index_files_changed_p=t + break + fi + done + fi + + # If index files have changed since TeX has been run, or if the aux + # file wasn't present originally, run texindex and TeX again. + if test "${index_files_changed_p}" ; then + retval=0 + if test "${new_index_files_sans_aux}" ; then + ${texindex} ${new_index_files_sans_aux} + retval=$? + fi + if test ${retval} -eq 0 ; then + ${tex} "${command_line_filename}" + fi + fi + fi + + # Generate list of files to delete, then call rm once with the entire + # list. This is significantly faster than multiple executions of rm. + file_list="" + for file in ${orig_index_files} ; do + file_list="${file_list} ${file}${backup_extension}" + done + if test "${file_list}" ; then + rm -f ${file_list} + fi +done + +# texi2dvi ends here diff --git a/Master/texmf-dist/doc/texdraw/texindex.c b/Master/texmf-dist/doc/texdraw/texindex.c new file mode 100644 index 00000000000..a88d5169691 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/texindex.c @@ -0,0 +1,1700 @@ +/* Prepare TeX index dribble output into an actual index. + + Version 1.45 + + Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +#include <stdio.h> +#include <ctype.h> +#include <errno.h> +#include "getopt.h" + +#if defined (STDC_HEADERS) +# include <string.h> +# include <stdlib.h> +# if !defined (bzero) +# define bzero(p, n) memset((p), '\0', (n)) +# endif /* !bzero */ +#else /* !STDC_HEADERS */ +extern int errno; +char *getenv (), *malloc (), *realloc (); +void bzero (); +#endif /* !STDC_HEADERS */ + +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#else /* !HAVE_UNISTD_H */ +long lseek (); +#endif /* !HAVE_UNISTD_H */ + +char *mktemp (); + +#if defined (VMS) +# if !defined (VAX11C) +# define noshare +# endif /* !VAX11C */ +# include <perror.h> +extern noshare int sys_nerr; +extern noshare char *sys_errlist[]; + +# include <file.h> + +# define TI_NO_ERROR ((1 << 28) | 1) +# define TI_FATAL_ERROR ((1 << 28) | 4) +# define unlink delete + +#else /* !VMS */ + +extern int sys_nerr; +extern char *sys_errlist[]; + +# if defined (HAVE_SYS_FCNTL_H) +# include <sys/types.h> +# include <sys/fcntl.h> +# endif /* HAVE_SYS_FCNTL_H */ + +# if defined (_AIX) || !defined (_POSIX_VERSION) +# include <sys/file.h> +# else /* !AIX && _POSIX_VERSION */ +# if !defined (HAVE_SYS_FCNTL_H) +# include <fcntl.h> +# endif /* !HAVE_FCNTL_H */ +# endif /* !_AIX && _POSIX_VERSION */ +# define TI_NO_ERROR 0 +# define TI_FATAL_ERROR 1 +#endif /* !VMS */ + +#if !defined (SEEK_SET) +# define SEEK_SET 0 +# define SEEK_CUR 1 +# define SEEK_END 2 +#endif /* !SEEK_SET */ + +/* When sorting in core, this structure describes one line + and the position and length of its first keyfield. */ +struct lineinfo +{ + char *text; /* The actual text of the line. */ + union { + char *text; /* The start of the key (for textual comparison). */ + long number; /* The numeric value (for numeric comparison). */ + } key; + long keylen; /* Length of KEY field. */ +}; + +/* This structure describes a field to use as a sort key. */ +struct keyfield +{ + int startwords; /* Number of words to skip. */ + int startchars; /* Number of additional chars to skip. */ + int endwords; /* Number of words to ignore at end. */ + int endchars; /* Ditto for characters of last word. */ + char ignore_blanks; /* Non-zero means ignore spaces and tabs. */ + char fold_case; /* Non-zero means case doesn't matter. */ + char reverse; /* Non-zero means compare in reverse order. */ + char numeric; /* Non-zeros means field is ASCII numeric. */ + char positional; /* Sort according to file position. */ + char braced; /* Count balanced-braced groupings as fields. */ +}; + +/* Vector of keyfields to use. */ +struct keyfield keyfields[3]; + +/* Number of keyfields stored in that vector. */ +int num_keyfields = 3; + +/* Vector of input file names, terminated with a null pointer. */ +char **infiles; + +/* Vector of corresponding output file names, or NULL, meaning default it + (add an `s' to the end). */ +char **outfiles; + +/* Length of `infiles'. */ +int num_infiles; + +/* Pointer to the array of pointers to lines being sorted. */ +char **linearray; + +/* The allocated length of `linearray'. */ +long nlines; + +/* Directory to use for temporary files. On Unix, it ends with a slash. */ +char *tempdir; + +/* Start of filename to use for temporary files. */ +char *tempbase; + +/* Number of last temporary file. */ +int tempcount; + +/* Number of last temporary file already deleted. + Temporary files are deleted by `flush_tempfiles' in order of creation. */ +int last_deleted_tempcount; + +/* During in-core sort, this points to the base of the data block + which contains all the lines of data. */ +char *text_base; + +/* Additional command switches .*/ + +/* Nonzero means do not delete tempfiles -- for debugging. */ +int keep_tempfiles; + +/* The name this program was run with. */ +char *program_name; + +/* Forward declarations of functions in this file. */ + +void decode_command (); +void sort_in_core (); +void sort_offline (); +char **parsefile (); +char *find_field (); +char *find_pos (); +long find_value (); +char *find_braced_pos (); +char *find_braced_end (); +void writelines (); +int compare_field (); +int compare_full (); +long readline (); +int merge_files (); +int merge_direct (); +void pfatal_with_name (); +void fatal (); +void error (); +void *xmalloc (), *xrealloc (); +char *concat (); +char *maketempname (); +void flush_tempfiles (); +char *tempcopy (); + +#define MAX_IN_CORE_SORT 500000 + +void +main (argc, argv) + int argc; + char **argv; +{ + int i; + + tempcount = 0; + last_deleted_tempcount = 0; + program_name = argv[0]; + + /* Describe the kind of sorting to do. */ + /* The first keyfield uses the first braced field and folds case. */ + keyfields[0].braced = 1; + keyfields[0].fold_case = 1; + keyfields[0].endwords = -1; + keyfields[0].endchars = -1; + + /* The second keyfield uses the second braced field, numerically. */ + keyfields[1].braced = 1; + keyfields[1].numeric = 1; + keyfields[1].startwords = 1; + keyfields[1].endwords = -1; + keyfields[1].endchars = -1; + + /* The third keyfield (which is ignored while discarding duplicates) + compares the whole line. */ + keyfields[2].endwords = -1; + keyfields[2].endchars = -1; + + decode_command (argc, argv); + + tempbase = mktemp (concat ("txiXXXXXX", "", "")); + + /* Process input files completely, one by one. */ + + for (i = 0; i < num_infiles; i++) + { + int desc; + long ptr; + char *outfile; + + desc = open (infiles[i], O_RDONLY, 0); + if (desc < 0) + pfatal_with_name (infiles[i]); + lseek (desc, 0L, SEEK_END); + ptr = lseek (desc, 0L, SEEK_CUR); + + close (desc); + + outfile = outfiles[i]; + if (!outfile) + { + outfile = concat (infiles[i], "s", ""); + } + + if (ptr < MAX_IN_CORE_SORT) + /* Sort a small amount of data. */ + sort_in_core (infiles[i], ptr, outfile); + else + sort_offline (infiles[i], ptr, outfile); + } + + flush_tempfiles (tempcount); + exit (TI_NO_ERROR); +} + +void +usage () +{ + fprintf (stderr, "\ +Usage: %s [-k] infile [-o outfile] ...\n", program_name); + exit (1); +} + +/* Decode the command line arguments to set the parameter variables + and set up the vector of keyfields and the vector of input files. */ + +void +decode_command (argc, argv) + int argc; + char **argv; +{ + int optc; + char **ip; + char **op; + + /* Store default values into parameter variables. */ + + tempdir = getenv ("TMPDIR"); +#ifdef VMS + if (tempdir == NULL) + tempdir = "sys$scratch:"; +#else + if (tempdir == NULL) + tempdir = "/tmp/"; + else + tempdir = concat (tempdir, "/", ""); +#endif + + keep_tempfiles = 0; + + /* Allocate ARGC input files, which must be enough. */ + + infiles = (char **) xmalloc (argc * sizeof (char *)); + outfiles = (char **) xmalloc (argc * sizeof (char *)); + ip = infiles; + op = outfiles; + + while ((optc = getopt (argc, argv, "-ko:")) != EOF) + { + switch (optc) + { + case 1: /* Non-option filename. */ + *ip++ = optarg; + *op++ = NULL; + break; + + case 'k': + keep_tempfiles = 1; + break; + + case 'o': + if (op > outfiles) + *(op - 1) = optarg; + break; + + default: + usage (); + } + } + + /* Record number of keyfields and terminate list of filenames. */ + num_infiles = ip - infiles; + *ip = 0; + if (num_infiles == 0) + usage (); +} + +/* Return a name for a temporary file. */ + +char * +maketempname (count) + int count; +{ + char tempsuffix[10]; + sprintf (tempsuffix, "%d", count); + return concat (tempdir, tempbase, tempsuffix); +} + +/* Delete all temporary files up to TO_COUNT. */ + +void +flush_tempfiles (to_count) + int to_count; +{ + if (keep_tempfiles) + return; + while (last_deleted_tempcount < to_count) + unlink (maketempname (++last_deleted_tempcount)); +} + +/* Copy the input file open on IDESC into a temporary file + and return the temporary file name. */ + +#define BUFSIZE 1024 + +char * +tempcopy (idesc) + int idesc; +{ + char *outfile = maketempname (++tempcount); + int odesc; + char buffer[BUFSIZE]; + + odesc = open (outfile, O_WRONLY | O_CREAT, 0666); + + if (odesc < 0) + pfatal_with_name (outfile); + + while (1) + { + int nread = read (idesc, buffer, BUFSIZE); + write (odesc, buffer, nread); + if (!nread) + break; + } + + close (odesc); + + return outfile; +} + +/* Compare LINE1 and LINE2 according to the specified set of keyfields. */ + +int +compare_full (line1, line2) + char **line1, **line2; +{ + int i; + + /* Compare using the first keyfield; + if that does not distinguish the lines, try the second keyfield; + and so on. */ + + for (i = 0; i < num_keyfields; i++) + { + long length1, length2; + char *start1 = find_field (&keyfields[i], *line1, &length1); + char *start2 = find_field (&keyfields[i], *line2, &length2); + int tem = compare_field (&keyfields[i], start1, length1, *line1 - text_base, + start2, length2, *line2 - text_base); + if (tem) + { + if (keyfields[i].reverse) + return -tem; + return tem; + } + } + + return 0; /* Lines match exactly. */ +} + +/* Compare LINE1 and LINE2, described by structures + in which the first keyfield is identified in advance. + For positional sorting, assumes that the order of the lines in core + reflects their nominal order. */ + +int +compare_prepared (line1, line2) + struct lineinfo *line1, *line2; +{ + int i; + int tem; + char *text1, *text2; + + /* Compare using the first keyfield, which has been found for us already. */ + if (keyfields->positional) + { + if (line1->text - text_base > line2->text - text_base) + tem = 1; + else + tem = -1; + } + else if (keyfields->numeric) + tem = line1->key.number - line2->key.number; + else + tem = compare_field (keyfields, line1->key.text, line1->keylen, 0, + line2->key.text, line2->keylen, 0); + if (tem) + { + if (keyfields->reverse) + return -tem; + return tem; + } + + text1 = line1->text; + text2 = line2->text; + + /* Compare using the second keyfield; + if that does not distinguish the lines, try the third keyfield; + and so on. */ + + for (i = 1; i < num_keyfields; i++) + { + long length1, length2; + char *start1 = find_field (&keyfields[i], text1, &length1); + char *start2 = find_field (&keyfields[i], text2, &length2); + int tem = compare_field (&keyfields[i], start1, length1, text1 - text_base, + start2, length2, text2 - text_base); + if (tem) + { + if (keyfields[i].reverse) + return -tem; + return tem; + } + } + + return 0; /* Lines match exactly. */ +} + +/* Like compare_full but more general. + You can pass any strings, and you can say how many keyfields to use. + POS1 and POS2 should indicate the nominal positional ordering of + the two lines in the input. */ + +int +compare_general (str1, str2, pos1, pos2, use_keyfields) + char *str1, *str2; + long pos1, pos2; + int use_keyfields; +{ + int i; + + /* Compare using the first keyfield; + if that does not distinguish the lines, try the second keyfield; + and so on. */ + + for (i = 0; i < use_keyfields; i++) + { + long length1, length2; + char *start1 = find_field (&keyfields[i], str1, &length1); + char *start2 = find_field (&keyfields[i], str2, &length2); + int tem = compare_field (&keyfields[i], start1, length1, pos1, + start2, length2, pos2); + if (tem) + { + if (keyfields[i].reverse) + return -tem; + return tem; + } + } + + return 0; /* Lines match exactly. */ +} + +/* Find the start and length of a field in STR according to KEYFIELD. + A pointer to the starting character is returned, and the length + is stored into the int that LENGTHPTR points to. */ + +char * +find_field (keyfield, str, lengthptr) + struct keyfield *keyfield; + char *str; + long *lengthptr; +{ + char *start; + char *end; + char *(*fun) (); + + if (keyfield->braced) + fun = find_braced_pos; + else + fun = find_pos; + + start = (*fun) (str, keyfield->startwords, keyfield->startchars, + keyfield->ignore_blanks); + if (keyfield->endwords < 0) + { + if (keyfield->braced) + end = find_braced_end (start); + else + { + end = start; + while (*end && *end != '\n') + end++; + } + } + else + { + end = (*fun) (str, keyfield->endwords, keyfield->endchars, 0); + if (end - str < start - str) + end = start; + } + *lengthptr = end - start; + return start; +} + +/* Return a pointer to a specified place within STR, + skipping (from the beginning) WORDS words and then CHARS chars. + If IGNORE_BLANKS is nonzero, we skip all blanks + after finding the specified word. */ + +char * +find_pos (str, words, chars, ignore_blanks) + char *str; + int words, chars; + int ignore_blanks; +{ + int i; + char *p = str; + + for (i = 0; i < words; i++) + { + char c; + /* Find next bunch of nonblanks and skip them. */ + while ((c = *p) == ' ' || c == '\t') + p++; + while ((c = *p) && c != '\n' && !(c == ' ' || c == '\t')) + p++; + if (!*p || *p == '\n') + return p; + } + + while (*p == ' ' || *p == '\t') + p++; + + for (i = 0; i < chars; i++) + { + if (!*p || *p == '\n') + break; + p++; + } + return p; +} + +/* Like find_pos but assumes that each field is surrounded by braces + and that braces within fields are balanced. */ + +char * +find_braced_pos (str, words, chars, ignore_blanks) + char *str; + int words, chars; + int ignore_blanks; +{ + int i; + int bracelevel; + char *p = str; + char c; + + for (i = 0; i < words; i++) + { + bracelevel = 1; + while ((c = *p++) != '{' && c != '\n' && c) + /* Do nothing. */ ; + if (c != '{') + return p - 1; + while (bracelevel) + { + c = *p++; + if (c == '{') + bracelevel++; + if (c == '}') + bracelevel--; + if (c == 0 || c == '\n') + return p - 1; + } + } + + while ((c = *p++) != '{' && c != '\n' && c) + /* Do nothing. */ ; + + if (c != '{') + return p - 1; + + if (ignore_blanks) + while ((c = *p) == ' ' || c == '\t') + p++; + + for (i = 0; i < chars; i++) + { + if (!*p || *p == '\n') + break; + p++; + } + return p; +} + +/* Find the end of the balanced-brace field which starts at STR. + The position returned is just before the closing brace. */ + +char * +find_braced_end (str) + char *str; +{ + int bracelevel; + char *p = str; + char c; + + bracelevel = 1; + while (bracelevel) + { + c = *p++; + if (c == '{') + bracelevel++; + if (c == '}') + bracelevel--; + if (c == 0 || c == '\n') + return p - 1; + } + return p - 1; +} + +long +find_value (start, length) + char *start; + long length; +{ + while (length != 0L) + { + if (isdigit (*start)) + return atol (start); + length--; + start++; + } + return 0l; +} + +/* Vector used to translate characters for comparison. + This is how we make all alphanumerics follow all else, + and ignore case in the first sorting. */ +int char_order[256]; + +void +init_char_order () +{ + int i; + for (i = 1; i < 256; i++) + char_order[i] = i; + + for (i = '0'; i <= '9'; i++) + char_order[i] += 512; + + for (i = 'a'; i <= 'z'; i++) + { + char_order[i] = 512 + i; + char_order[i + 'A' - 'a'] = 512 + i; + } +} + +/* Compare two fields (each specified as a start pointer and a character count) + according to KEYFIELD. + The sign of the value reports the relation between the fields. */ + +int +compare_field (keyfield, start1, length1, pos1, start2, length2, pos2) + struct keyfield *keyfield; + char *start1; + long length1; + long pos1; + char *start2; + long length2; + long pos2; +{ + if (keyfields->positional) + { + if (pos1 > pos2) + return 1; + else + return -1; + } + if (keyfield->numeric) + { + long value = find_value (start1, length1) - find_value (start2, length2); + if (value > 0) + return 1; + if (value < 0) + return -1; + return 0; + } + else + { + char *p1 = start1; + char *p2 = start2; + char *e1 = start1 + length1; + char *e2 = start2 + length2; + + while (1) + { + int c1, c2; + + if (p1 == e1) + c1 = 0; + else + c1 = *p1++; + if (p2 == e2) + c2 = 0; + else + c2 = *p2++; + + if (char_order[c1] != char_order[c2]) + return char_order[c1] - char_order[c2]; + if (!c1) + break; + } + + /* Strings are equal except possibly for case. */ + p1 = start1; + p2 = start2; + while (1) + { + int c1, c2; + + if (p1 == e1) + c1 = 0; + else + c1 = *p1++; + if (p2 == e2) + c2 = 0; + else + c2 = *p2++; + + if (c1 != c2) + /* Reverse sign here so upper case comes out last. */ + return c2 - c1; + if (!c1) + break; + } + + return 0; + } +} + +/* A `struct linebuffer' is a structure which holds a line of text. + `readline' reads a line from a stream into a linebuffer + and works regardless of the length of the line. */ + +struct linebuffer +{ + long size; + char *buffer; +}; + +/* Initialize LINEBUFFER for use. */ + +void +initbuffer (linebuffer) + struct linebuffer *linebuffer; +{ + linebuffer->size = 200; + linebuffer->buffer = (char *) xmalloc (200); +} + +/* Read a line of text from STREAM into LINEBUFFER. + Return the length of the line. */ + +long +readline (linebuffer, stream) + struct linebuffer *linebuffer; + FILE *stream; +{ + char *buffer = linebuffer->buffer; + char *p = linebuffer->buffer; + char *end = p + linebuffer->size; + + while (1) + { + int c = getc (stream); + if (p == end) + { + buffer = (char *) xrealloc (buffer, linebuffer->size *= 2); + p += buffer - linebuffer->buffer; + end += buffer - linebuffer->buffer; + linebuffer->buffer = buffer; + } + if (c < 0 || c == '\n') + { + *p = 0; + break; + } + *p++ = c; + } + + return p - buffer; +} + +/* Sort an input file too big to sort in core. */ + +void +sort_offline (infile, nfiles, total, outfile) + char *infile; + int nfiles; + long total; + char *outfile; +{ + /* More than enough. */ + int ntemps = 2 * (total + MAX_IN_CORE_SORT - 1) / MAX_IN_CORE_SORT; + char **tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); + FILE *istream = fopen (infile, "r"); + int i; + struct linebuffer lb; + long linelength; + int failure = 0; + + initbuffer (&lb); + + /* Read in one line of input data. */ + + linelength = readline (&lb, istream); + + if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') + { + error ("%s: not a texinfo index file", infile); + return; + } + + /* Split up the input into `ntemps' temporary files, or maybe fewer, + and put the new files' names into `tempfiles' */ + + for (i = 0; i < ntemps; i++) + { + char *outname = maketempname (++tempcount); + FILE *ostream = fopen (outname, "w"); + long tempsize = 0; + + if (!ostream) + pfatal_with_name (outname); + tempfiles[i] = outname; + + /* Copy lines into this temp file as long as it does not make file + "too big" or until there are no more lines. */ + + while (tempsize + linelength + 1 <= MAX_IN_CORE_SORT) + { + tempsize += linelength + 1; + fputs (lb.buffer, ostream); + putc ('\n', ostream); + + /* Read another line of input data. */ + + linelength = readline (&lb, istream); + if (!linelength && feof (istream)) + break; + + if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') + { + error ("%s: not a texinfo index file", infile); + failure = 1; + goto fail; + } + } + fclose (ostream); + if (feof (istream)) + break; + } + + free (lb.buffer); + +fail: + /* Record number of temp files we actually needed. */ + + ntemps = i; + + /* Sort each tempfile into another tempfile. + Delete the first set of tempfiles and put the names of the second + into `tempfiles'. */ + + for (i = 0; i < ntemps; i++) + { + char *newtemp = maketempname (++tempcount); + sort_in_core (&tempfiles[i], MAX_IN_CORE_SORT, newtemp); + if (!keep_tempfiles) + unlink (tempfiles[i]); + tempfiles[i] = newtemp; + } + + if (failure) + return; + + /* Merge the tempfiles together and indexify. */ + + merge_files (tempfiles, ntemps, outfile); +} + +/* Sort INFILE, whose size is TOTAL, + assuming that is small enough to be done in-core, + then indexify it and send the output to OUTFILE (or to stdout). */ + +void +sort_in_core (infile, total, outfile) + char *infile; + long total; + char *outfile; +{ + char **nextline; + char *data = (char *) xmalloc (total + 1); + char *file_data; + long file_size; + int i; + FILE *ostream = stdout; + struct lineinfo *lineinfo; + + /* Read the contents of the file into the moby array `data'. */ + + int desc = open (infile, O_RDONLY, 0); + + if (desc < 0) + fatal ("failure reopening %s", infile); + for (file_size = 0;;) + { + i = read (desc, data + file_size, total - file_size); + if (i <= 0) + break; + file_size += i; + } + file_data = data; + data[file_size] = 0; + + close (desc); + + if (file_size > 0 && data[0] != '\\' && data[0] != '@') + { + error ("%s: not a texinfo index file", infile); + return; + } + + init_char_order (); + + /* Sort routines want to know this address. */ + + text_base = data; + + /* Create the array of pointers to lines, with a default size + frequently enough. */ + + nlines = total / 50; + if (!nlines) + nlines = 2; + linearray = (char **) xmalloc (nlines * sizeof (char *)); + + /* `nextline' points to the next free slot in this array. + `nlines' is the allocated size. */ + + nextline = linearray; + + /* Parse the input file's data, and make entries for the lines. */ + + nextline = parsefile (infile, nextline, file_data, file_size); + if (nextline == 0) + { + error ("%s: not a texinfo index file", infile); + return; + } + + /* Sort the lines. */ + + /* If we have enough space, find the first keyfield of each line in advance. + Make a `struct lineinfo' for each line, which records the keyfield + as well as the line, and sort them. */ + + lineinfo = (struct lineinfo *) malloc ((nextline - linearray) * sizeof (struct lineinfo)); + + if (lineinfo) + { + struct lineinfo *lp; + char **p; + + for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) + { + lp->text = *p; + lp->key.text = find_field (keyfields, *p, &lp->keylen); + if (keyfields->numeric) + lp->key.number = find_value (lp->key.text, lp->keylen); + } + + qsort (lineinfo, nextline - linearray, sizeof (struct lineinfo), compare_prepared); + + for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) + *p = lp->text; + + free (lineinfo); + } + else + qsort (linearray, nextline - linearray, sizeof (char *), compare_full); + + /* Open the output file. */ + + if (outfile) + { + ostream = fopen (outfile, "w"); + if (!ostream) + pfatal_with_name (outfile); + } + + writelines (linearray, nextline - linearray, ostream); + if (outfile) + fclose (ostream); + + free (linearray); + free (data); +} + +/* Parse an input string in core into lines. + DATA is the input string, and SIZE is its length. + Data goes in LINEARRAY starting at NEXTLINE. + The value returned is the first entry in LINEARRAY still unused. + Value 0 means input file contents are invalid. */ + +char ** +parsefile (filename, nextline, data, size) + char *filename; + char **nextline; + char *data; + long size; +{ + char *p, *end; + char **line = nextline; + + p = data; + end = p + size; + *end = 0; + + while (p != end) + { + if (p[0] != '\\' && p[0] != '@') + return 0; + + *line = p; + while (*p && *p != '\n') + p++; + if (p != end) + p++; + + line++; + if (line == linearray + nlines) + { + char **old = linearray; + linearray = (char **) xrealloc (linearray, sizeof (char *) * (nlines *= 4)); + line += linearray - old; + } + } + + return line; +} + +/* Indexification is a filter applied to the sorted lines + as they are being written to the output file. + Multiple entries for the same name, with different page numbers, + get combined into a single entry with multiple page numbers. + The first braced field, which is used for sorting, is discarded. + However, its first character is examined, folded to lower case, + and if it is different from that in the previous line fed to us + a \initial line is written with one argument, the new initial. + + If an entry has four braced fields, then the second and third + constitute primary and secondary names. + In this case, each change of primary name + generates a \primary line which contains only the primary name, + and in between these are \secondary lines which contain + just a secondary name and page numbers. */ + +/* The last primary name we wrote a \primary entry for. + If only one level of indexing is being done, this is the last name seen. */ +char *lastprimary; +/* Length of storage allocated for lastprimary. */ +int lastprimarylength; + +/* Similar, for the secondary name. */ +char *lastsecondary; +int lastsecondarylength; + +/* Zero if we are not in the middle of writing an entry. + One if we have written the beginning of an entry but have not + yet written any page numbers into it. + Greater than one if we have written the beginning of an entry + plus at least one page number. */ +int pending; + +/* The initial (for sorting purposes) of the last primary entry written. + When this changes, a \initial {c} line is written */ + +char *lastinitial; + +int lastinitiallength; + +/* When we need a string of length 1 for the value of lastinitial, + store it here. */ + +char lastinitial1[2]; + +/* Initialize static storage for writing an index. */ + +void +init_index () +{ + pending = 0; + lastinitial = lastinitial1; + lastinitial1[0] = 0; + lastinitial1[1] = 0; + lastinitiallength = 0; + lastprimarylength = 100; + lastprimary = (char *) xmalloc (lastprimarylength + 1); + bzero (lastprimary, lastprimarylength + 1); + lastsecondarylength = 100; + lastsecondary = (char *) xmalloc (lastsecondarylength + 1); + bzero (lastsecondary, lastsecondarylength + 1); +} + +/* Indexify. Merge entries for the same name, + insert headers for each initial character, etc. */ + +void +indexify (line, ostream) + char *line; + FILE *ostream; +{ + char *primary, *secondary, *pagenumber; + int primarylength, secondarylength = 0, pagelength; + int nosecondary; + int initiallength; + char *initial; + char initial1[2]; + register char *p; + + /* First, analyze the parts of the entry fed to us this time. */ + + p = find_braced_pos (line, 0, 0, 0); + if (*p == '{') + { + initial = p; + /* Get length of inner pair of braces starting at `p', + including that inner pair of braces. */ + initiallength = find_braced_end (p + 1) + 1 - p; + } + else + { + initial = initial1; + initial1[0] = *p; + initial1[1] = 0; + initiallength = 1; + + if (initial1[0] >= 'a' && initial1[0] <= 'z') + initial1[0] -= 040; + } + + pagenumber = find_braced_pos (line, 1, 0, 0); + pagelength = find_braced_end (pagenumber) - pagenumber; + if (pagelength == 0) + abort (); + + primary = find_braced_pos (line, 2, 0, 0); + primarylength = find_braced_end (primary) - primary; + + secondary = find_braced_pos (line, 3, 0, 0); + nosecondary = !*secondary; + if (!nosecondary) + secondarylength = find_braced_end (secondary) - secondary; + + /* If the primary is different from before, make a new primary entry. */ + if (strncmp (primary, lastprimary, primarylength)) + { + /* Close off current secondary entry first, if one is open. */ + if (pending) + { + fputs ("}\n", ostream); + pending = 0; + } + + /* If this primary has a different initial, include an entry for + the initial. */ + if (initiallength != lastinitiallength || + strncmp (initial, lastinitial, initiallength)) + { + fprintf (ostream, "\\initial {"); + fwrite (initial, 1, initiallength, ostream); + fprintf (ostream, "}\n", initial); + if (initial == initial1) + { + lastinitial = lastinitial1; + *lastinitial1 = *initial1; + } + else + { + lastinitial = initial; + } + lastinitiallength = initiallength; + } + + /* Make the entry for the primary. */ + if (nosecondary) + fputs ("\\entry {", ostream); + else + fputs ("\\primary {", ostream); + fwrite (primary, primarylength, 1, ostream); + if (nosecondary) + { + fputs ("}{", ostream); + pending = 1; + } + else + fputs ("}\n", ostream); + + /* Record name of most recent primary. */ + if (lastprimarylength < primarylength) + { + lastprimarylength = primarylength + 100; + lastprimary = (char *) xrealloc (lastprimary, + 1 + lastprimarylength); + } + strncpy (lastprimary, primary, primarylength); + lastprimary[primarylength] = 0; + + /* There is no current secondary within this primary, now. */ + lastsecondary[0] = 0; + } + + /* Should not have an entry with no subtopic following one with a subtopic. */ + + if (nosecondary && *lastsecondary) + error ("entry %s follows an entry with a secondary name", line); + + /* Start a new secondary entry if necessary. */ + if (!nosecondary && strncmp (secondary, lastsecondary, secondarylength)) + { + if (pending) + { + fputs ("}\n", ostream); + pending = 0; + } + + /* Write the entry for the secondary. */ + fputs ("\\secondary {", ostream); + fwrite (secondary, secondarylength, 1, ostream); + fputs ("}{", ostream); + pending = 1; + + /* Record name of most recent secondary. */ + if (lastsecondarylength < secondarylength) + { + lastsecondarylength = secondarylength + 100; + lastsecondary = (char *) xrealloc (lastsecondary, + 1 + lastsecondarylength); + } + strncpy (lastsecondary, secondary, secondarylength); + lastsecondary[secondarylength] = 0; + } + + /* Here to add one more page number to the current entry. */ + if (pending++ != 1) + fputs (", ", ostream); /* Punctuate first, if this is not the first. */ + fwrite (pagenumber, pagelength, 1, ostream); +} + +/* Close out any unfinished output entry. */ + +void +finish_index (ostream) + FILE *ostream; +{ + if (pending) + fputs ("}\n", ostream); + free (lastprimary); + free (lastsecondary); +} + +/* Copy the lines in the sorted order. + Each line is copied out of the input file it was found in. */ + +void +writelines (linearray, nlines, ostream) + char **linearray; + int nlines; + FILE *ostream; +{ + char **stop_line = linearray + nlines; + char **next_line; + + init_index (); + + /* Output the text of the lines, and free the buffer space. */ + + for (next_line = linearray; next_line != stop_line; next_line++) + { + /* If -u was specified, output the line only if distinct from previous one. */ + if (next_line == linearray + /* Compare previous line with this one, using only the + explicitly specd keyfields. */ + || compare_general (*(next_line - 1), *next_line, 0L, 0L, num_keyfields - 1)) + { + char *p = *next_line; + char c; + + while ((c = *p++) && c != '\n') + /* Do nothing. */ ; + *(p - 1) = 0; + indexify (*next_line, ostream); + } + } + + finish_index (ostream); +} + +/* Assume (and optionally verify) that each input file is sorted; + merge them and output the result. + Returns nonzero if any input file fails to be sorted. + + This is the high-level interface that can handle an unlimited + number of files. */ + +#define MAX_DIRECT_MERGE 10 + +int +merge_files (infiles, nfiles, outfile) + char **infiles; + int nfiles; + char *outfile; +{ + char **tempfiles; + int ntemps; + int i; + int value = 0; + int start_tempcount = tempcount; + + if (nfiles <= MAX_DIRECT_MERGE) + return merge_direct (infiles, nfiles, outfile); + + /* Merge groups of MAX_DIRECT_MERGE input files at a time, + making a temporary file to hold each group's result. */ + + ntemps = (nfiles + MAX_DIRECT_MERGE - 1) / MAX_DIRECT_MERGE; + tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); + for (i = 0; i < ntemps; i++) + { + int nf = MAX_DIRECT_MERGE; + if (i + 1 == ntemps) + nf = nfiles - i * MAX_DIRECT_MERGE; + tempfiles[i] = maketempname (++tempcount); + value |= merge_direct (&infiles[i * MAX_DIRECT_MERGE], nf, tempfiles[i]); + } + + /* All temporary files that existed before are no longer needed + since their contents have been merged into our new tempfiles. + So delete them. */ + flush_tempfiles (start_tempcount); + + /* Now merge the temporary files we created. */ + + merge_files (tempfiles, ntemps, outfile); + + free (tempfiles); + + return value; +} + +/* Assume (and optionally verify) that each input file is sorted; + merge them and output the result. + Returns nonzero if any input file fails to be sorted. + + This version of merging will not work if the number of + input files gets too high. Higher level functions + use it only with a bounded number of input files. */ + +int +merge_direct (infiles, nfiles, outfile) + char **infiles; + int nfiles; + char *outfile; +{ + struct linebuffer *lb1, *lb2; + struct linebuffer **thisline, **prevline; + FILE **streams; + int i; + int nleft; + int lossage = 0; + int *file_lossage; + struct linebuffer *prev_out = 0; + FILE *ostream = stdout; + + if (outfile) + { + ostream = fopen (outfile, "w"); + } + if (!ostream) + pfatal_with_name (outfile); + + init_index (); + + if (nfiles == 0) + { + if (outfile) + fclose (ostream); + return 0; + } + + /* For each file, make two line buffers. + Also, for each file, there is an element of `thisline' + which points at any time to one of the file's two buffers, + and an element of `prevline' which points to the other buffer. + `thisline' is supposed to point to the next available line from the file, + while `prevline' holds the last file line used, + which is remembered so that we can verify that the file is properly sorted. */ + + /* lb1 and lb2 contain one buffer each per file. */ + lb1 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); + lb2 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); + + /* thisline[i] points to the linebuffer holding the next available line in file i, + or is zero if there are no lines left in that file. */ + thisline = (struct linebuffer **) + xmalloc (nfiles * sizeof (struct linebuffer *)); + /* prevline[i] points to the linebuffer holding the last used line + from file i. This is just for verifying that file i is properly + sorted. */ + prevline = (struct linebuffer **) + xmalloc (nfiles * sizeof (struct linebuffer *)); + /* streams[i] holds the input stream for file i. */ + streams = (FILE **) xmalloc (nfiles * sizeof (FILE *)); + /* file_lossage[i] is nonzero if we already know file i is not + properly sorted. */ + file_lossage = (int *) xmalloc (nfiles * sizeof (int)); + + /* Allocate and initialize all that storage. */ + + for (i = 0; i < nfiles; i++) + { + initbuffer (&lb1[i]); + initbuffer (&lb2[i]); + thisline[i] = &lb1[i]; + prevline[i] = &lb2[i]; + file_lossage[i] = 0; + streams[i] = fopen (infiles[i], "r"); + if (!streams[i]) + pfatal_with_name (infiles[i]); + + readline (thisline[i], streams[i]); + } + + /* Keep count of number of files not at eof. */ + nleft = nfiles; + + while (nleft) + { + struct linebuffer *best = 0; + struct linebuffer *exch; + int bestfile = -1; + int i; + + /* Look at the next avail line of each file; choose the least one. */ + + for (i = 0; i < nfiles; i++) + { + if (thisline[i] && + (!best || + 0 < compare_general (best->buffer, thisline[i]->buffer, + (long) bestfile, (long) i, num_keyfields))) + { + best = thisline[i]; + bestfile = i; + } + } + + /* Output that line, unless it matches the previous one and we + don't want duplicates. */ + + if (!(prev_out && + !compare_general (prev_out->buffer, + best->buffer, 0L, 1L, num_keyfields - 1))) + indexify (best->buffer, ostream); + prev_out = best; + + /* Now make the line the previous of its file, and fetch a new + line from that file. */ + + exch = prevline[bestfile]; + prevline[bestfile] = thisline[bestfile]; + thisline[bestfile] = exch; + + while (1) + { + /* If the file has no more, mark it empty. */ + + if (feof (streams[bestfile])) + { + thisline[bestfile] = 0; + /* Update the number of files still not empty. */ + nleft--; + break; + } + readline (thisline[bestfile], streams[bestfile]); + if (thisline[bestfile]->buffer[0] || !feof (streams[bestfile])) + break; + } + } + + finish_index (ostream); + + /* Free all storage and close all input streams. */ + + for (i = 0; i < nfiles; i++) + { + fclose (streams[i]); + free (lb1[i].buffer); + free (lb2[i].buffer); + } + free (file_lossage); + free (lb1); + free (lb2); + free (thisline); + free (prevline); + free (streams); + + if (outfile) + fclose (ostream); + + return lossage; +} + +/* Print error message and exit. */ + +void +fatal (s1, s2) + char *s1, *s2; +{ + error (s1, s2); + exit (TI_FATAL_ERROR); +} + +/* Print error message. S1 is printf control string, S2 is arg for it. */ + +void +error (s1, s2) + char *s1, *s2; +{ + printf ("%s: ", program_name); + printf (s1, s2); + printf ("\n"); +} + +void +perror_with_name (name) + char *name; +{ + char *s; + + if (errno < sys_nerr) + s = concat ("", sys_errlist[errno], " for %s"); + else + s = "cannot open %s"; + error (s, name); +} + +void +pfatal_with_name (name) + char *name; +{ + char *s; + + if (errno < sys_nerr) + s = concat ("", sys_errlist[errno], " for %s"); + else + s = "cannot open %s"; + fatal (s, name); +} + +/* Return a newly-allocated string whose contents concatenate those of + S1, S2, S3. */ + +char * +concat (s1, s2, s3) + char *s1, *s2, *s3; +{ + int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); + char *result = (char *) xmalloc (len1 + len2 + len3 + 1); + + strcpy (result, s1); + strcpy (result + len1, s2); + strcpy (result + len1 + len2, s3); + *(result + len1 + len2 + len3) = 0; + + return result; +} + +/* Just like malloc, but kills the program in case of fatal error. */ +void * +xmalloc (nbytes) + int nbytes; +{ + void *temp = (void *) malloc (nbytes); + + if (nbytes && temp == (void *)NULL) + memory_error ("xmalloc", nbytes); + + return (temp); +} + +/* Like realloc (), but barfs if there isn't enough memory. */ +void * +xrealloc (pointer, nbytes) + void *pointer; + int nbytes; +{ + void *temp; + + if (!pointer) + temp = (void *)xmalloc (nbytes); + else + temp = (void *)realloc (pointer, nbytes); + + if (nbytes && !temp) + memory_error ("xrealloc", nbytes); + + return (temp); +} + +memory_error (callers_name, bytes_wanted) + char *callers_name; + int bytes_wanted; +{ + char printable_string[80]; + + sprintf (printable_string, + "Virtual memory exhausted in %s ()! Needed %d bytes.", + callers_name, bytes_wanted); + + error (printable_string); + abort (); +} + +#ifndef STDC_HEADERS +void +bzero (b, length) + register char *b; + register int length; +{ +#ifdef VMS + short zero = 0; + long max_str = 65535; + + while (length > max_str) + { + (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); + length -= max_str; + b += max_str; + } + (void) LIB$MOVC5 (&zero, &zero, &zero, &length, b); +#else + while (length-- > 0) + *b++ = 0; +#endif /* not VMS */ +} +#endif /* not STDC_HEADERS */ diff --git a/Master/texmf-dist/doc/texdraw/txdexamp.latex b/Master/texmf-dist/doc/texdraw/txdexamp.latex new file mode 100644 index 00000000000..c3ea8b4eee9 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/txdexamp.latex @@ -0,0 +1,514 @@ +% TeXdraw examples for latex + +% $Id: txdexamp.latex,v 2.0 1995/12/18 texdraw-V2R0 $ + +% These examples are taken from the TeXdraw manual. + +% Peter Kabal +% Department of Electrical Engineering +% McGill University +% 3480 University +% Montreal, Quebec +% Canada H3A 2A7 + +% kabal@TSP.EE.McGill.CA + +\documentclass [11pt]{article} +\usepackage {texdraw} + +\input txdtools +\let\et=\etexdraw +\def\etexdraw{\drawbb\et} + +\begin{document} + +\noindent +TeXdraw examples using LaTeX. + +\bigskip +\begin{center} +\begin{texdraw} + \avec (0 0.8) \textref h:C v:B \htext (0 0.9){\sl y} + \move (0 0) \avec (0.8 0) \textref h:L v:C \htext(0.9 0){\sl x} + \move (0 1.0) +\end{texdraw} +\end{center} + +\bigskip +\begin{center} +\begin{texdraw} + \drawdim{cm} \linewd 0.02 + \move(2 2) \lvec(3 3) \lvec(2 4) \lvec(1 3) \lvec(2 2) + \textref h:C v:C \htext(2 3){$\sum \rho_n$} +\end{texdraw} +\end{center} + +\bigskip +\begin{center} +\begin{texdraw} + \drawdim in + \linewd 0.03 \setgray 0.6 \arrowheadtype t:F \avec(0.5 0.5) + \linewd 0.01 \setgray 0 \arrowheadtype t:V \avec(1.0 0.5) + \linewd 0.015 \lpatt(0.067 0.1) \lvec (1.5 0) + \linewd 0.02 \lpatt() \arrowheadtype t:T \avec(2.0 0.5) + \arrowheadtype t:H \avec(2.5 0.5) + \setgray 0.4 \arrowheadtype t:W \avec(3.0 0) + \textref h:R v:T \htext (0.35 0.50){\tt t:F} + \textref h:R v:T \htext (1.0 0.43){\tt t:V} + \textref h:R v:T \htext (1.82 0.50){\tt t:T} + \textref h:R v:T \htext (2.5 0.43){\tt t:H} + \textref h:R v:B \htext (2.8 0){\tt t:W} +\end{texdraw} +\end{center} + +\bigskip +\begin{center} +\begin{texdraw} + \newcommand{\bdot}{\bsegment + \fcir f:0 r:0.02 + \esegment} + \newcommand{\Ttext}[1]{\bsegment + \textref h:C v:B \htext (0 +0.06){#1} + \esegment} + \newcommand{\Btext}[1]{\bsegment + \textref h:C v:T \htext (0 -0.06){#1} + \esegment} + \newcommand{\Ltext}[1]{\bsegment + \textref h:R v:C \htext (-0.08 0){#1} + \esegment} + \newcommand{\Rtext}[1]{\bsegment + \textref h:L v:C \htext (+0.08 0){#1} + \esegment} + \move (-1.5 0) + \bsegment + \move (+1.55 +0.45) \move (-1.55 -0.45) \move (0 0) + \Ttext{Horizontal Text} + \bdot \Btext{\tt h:C v:C} + \move (-0.9 0) \bdot \Ltext{\tt h:L v:C} + \move (+0.9 0) \bdot \Rtext{\tt h:R v:C} + \move (0 +0.3) \bdot \Ttext{\tt h:C v:T} + \move (0 -0.3) \bdot \Btext{\tt h:C v:B} + \move (-0.9 -0.3) \bdot \Ltext{\tt h:L v:B} + \lvec (-0.9 +0.3) \bdot \Ltext{\tt h:L v:T} + \lvec (+0.9 +0.3) \bdot \Rtext{\tt h:R v:T} + \lvec (+0.9 -0.3) \bdot \Rtext{\tt h:R v:B} + \lvec (-0.9 -0.3) + \esegment + \newcommand{\atext}{\rtext td:45 } + \newcommand{\ATtext}[1]{\bsegment + \setsegscale 0.707 + \textref h:C v:B \atext (-0.06 +0.06){#1} + \esegment} + \newcommand{\ABtext}[1]{\bsegment + \setsegscale 0.707 + \textref h:C v:T \atext (+0.060 -0.06){#1} + \esegment} + \newcommand{\ALtext}[1]{\bsegment + \setsegscale 0.707 + \textref h:R v:C \atext (-0.08 -0.08){#1} + \esegment} + \newcommand{\ARtext}[1]{\bsegment + \setsegscale 0.707 + \textref h:L v:C \atext (+0.08 +0.08){#1} + \esegment} + \move (+1.5 0) + \bsegment + \move (+1.33 +1.33) \move (-1.33 -1.33) \move (0 0) + \setsegscale 0.707 + \ATtext{Rotated Text} + \bdot \ABtext{\tt h:C v:C} + \move (-0.9 -0.9) \bdot \ALtext{\tt h:L v:C} + \move (+0.9 +0.9) \bdot \ARtext{\tt h:R v:C} + \move (-0.3 +0.3) \bdot \ATtext{\tt h:C v:T} + \move (+0.3 -0.3) \bdot \ABtext{\tt h:C v:B} + \move (-0.6 -1.2) \bdot \ALtext{\tt h:L v:B} + \lvec (-1.2 -0.6) \bdot \ALtext{\tt h:L v:T} + \lvec (+0.6 +1.2) \bdot \ARtext{\tt h:R v:T} + \lvec (+1.2 +0.6) \bdot \ARtext{\tt h:R v:B} + \lvec (-0.6 -1.2) + \esegment +\end{texdraw} +\end{center} + +\vfill +\newpage + + +\bigskip +\begin{center} +\begin{texdraw} + \move(-0.75 -0.25) \lvec (-0.75 +0.5) \lvec (+0.75 +0.5) + \lvec(+0.75 -0.25) \ifill f:0.9 % fill the region + \move(0 0) + \avec(-0.75 -0.25) \textref h:R v:C \htext{H-text} + \move(0 0) \avec(-0.75 +0.25) \textref h:R v:B \htext{H-text} + \move(0 0) \avec(0 +0.5) \textref h:L v:T \vtext{V-text} + \move(0 0) \avec(+0.75 +0.25) \textref h:L v:B \htext{H-text} + \move(0 0) \avec(+0.75 -0.25) \textref h:L v:C \htext{H-text} + \move (-1.15 -0.3) \move (+1.15 +0.92) % increase the size of the drawing +\end{texdraw} +\end{center} + +\bigskip +\begin{center} +\begin{texdraw} + \linewd 0.02 + \fcir f:0.7 r:1 + \larc r:1 sd:45 ed:135 + \lvec ( 0.707 0.707) \move (0 0) \lvec (-0.707 +0.707) +\end{texdraw} +\end{center} + +\bigskip +\begin{center} +\begin{texdraw} + \newcommand{\Ltext}[1]{\bsegment + \textref h:R v:C \htext (-0.08 0){#1} + \esegment} + \newcommand{\Rtext}[1]{\bsegment + \textref h:L v:C \htext (+0.08 0){#1} + \esegment} + \newcommand{\bdot}{\fcir f:0 r:0.02 } + \newcommand{\Ldot}[1]{\bdot \Ltext{#1}} + \newcommand{\Rdot}[1]{\bdot \Rtext{#1}} + \move (-2 0) + \bsegment + \lpatt (0.033) + \move (0 0) \Ldot{0} \lvec (0 1) \Ldot{1} + \lvec (1 1) \Rdot{2} \lvec (1 0) \Rdot{3} + \lpatt () + \move (0 0) \clvec (0 1)(1 1)(1 0) + \esegment + \move (0 0) + \bsegment + \lpatt (0.033) + \move (0 0) \Ldot{0} \lvec (0.5 0.8) \Ldot{1} + \lvec (1.5 0.8) \Rdot{2} \lvec (1 0) \Rdot{3} + \lpatt () + \move (0 0) \clvec (0.5 1)(1.5 1)(1 0) + \esegment + \move ( 2 0) + \bsegment + \lpatt (0.033) + \move (0 0) \Ldot{0} \lvec (0 1) \Ldot{1} + \lvec (1 0) \Rdot{2} \lvec (1 1) \Rdot{3} + \lpatt () + \move (0 0) \clvec (0 1)(1 0)(1 1) + \esegment +\end{texdraw} +\end{center} + +\bigskip +\begin{center} +\begin{texdraw} +\move (0.5 0) +\lvec (0 0.5) \clvec (0.5 0.85)(1 0.65)(1.5 1) +\lvec (2 0.5) \clvec (1.5 0.15)(1 0.35)(0.5 0) +\lfill f:0.8 +\end{texdraw} +\end{center} + +\vfill +\newpage + + +\bigskip +\newcommand{\tbox}[1]{\bsegment + \lvec (0 +0.25) \lvec (0.75 +0.25) + \lvec (0.75 -0.25) \lvec (0 -0.25) \lvec (0 0) + \textref h:C v:C \htext (0.375 0){#1} + \savepos (0.75 0)(*ex *ey) + \esegment + \move (*ex *ey)} +\begin{center} +\begin{texdraw} + \ravec (1 0) \tbox{$H(z)$} \ravec (1 0) +\end{texdraw} +\end{center} + +\bigskip +\def\cavec (#1 #2)(#3 #4)(#5 #6){ + \clvec (#1 #2)(#3 #4)(#5 #6) + \cossin (#3 #4)(#5 #6)\cosa\sina + \rmove (0 0) % stroke the Bezier curve + \bsegment + \drawdim in \setsegscale 0.05 + \move ({-\cosa} -\sina) \avec (0 0) + \esegment} + +\def\caw (#1 #2){ + \currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + +% The nominal wiggly curve is (0 0) (1+dx dy) (-dx -dy) (1 0) +% Find the rotated offset (dx dy) -> (du dv) + \rotatecoord (0.4 0.1)\cosa\sina \du\dv + +% calculate the length of the vector + \vectlen ({\xa} \ya)(#1 #2)\len + +% draw the curve in normalized units + \bsegment + \setsegscale {\len} + \realadd \cosa \du \tmpa \realadd \sina \dv \tmpb + \cavec ({\tmpa} \tmpb)({-\du} -\dv)({\cosa} \sina) + \esegment + + \move (#1 #2)} + +% rotate a coordinate (x y) +% arguments: (x y) cosa sina x' y' +% x' = cosa * x - sina * y; y' = sina * x + cosa * y +\def\rotatecoord (#1 #2)#3#4#5#6{ + \getpos (#1 #2)\xarg\yarg + \realmult \xarg {#3} \tmpa \realmult \yarg {#4} \tmpb + \realadd \tmpa {-\tmpb} #5 + \realmult \xarg {#4} \tmpa \realmult \yarg {#3} \tmpb + \realadd \tmpa \tmpb #6} + +\begin{center} +\begin{texdraw} + \arrowheadtype t:W + \move (0 0) + \cavec (1.4 0.1)(-0.4 -0.1)(1 0) + \move (1 0) \caw (1 1) \htext{tip at \tt (1 1)} + \move (1 0) \caw (2 1) \htext{tip at \tt (2 1)} + \move (1 0) \caw (2 0) \htext{tip at \tt (2 0)} + \move (0 1.13) \move (0 -0.04) +\end{texdraw} +\end{center} + +\vfill +\newpage + + +\bigskip +\def\delay {\bsegment + \setsegscale 0.3 + \lvec (0 +0.5) \lvec (1 +0.5) \lvec (1 -0.5) + \lvec (0 -0.5) \lvec (0 0) + \textref h:C v:C \htext (0.5 0){$z^{-1}$} + \savepos (1 0)(*ex *ey) + \esegment + \move (*ex *ey)} +\def\bdot {\fcir f:0 r:0.02 } +\def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 +0.06){#1} + \esegment} +\def\Btext #1{\bsegment + \textref h:C v:T \htext (0 -0.06){#1} + \esegment} +\def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.06 0){#1} + \esegment} +\def\Rtext #1{\bsegment + \textref h:L v:C \htext (+0.06 0){#1} + \esegment} +\def\cradius {0.08} +\def\pluss {\bsegment + \setsegscale {\cradius} + \move (-0.5 0) \lvec (+0.5 0) + \move (0 -0.5) \lvec (0 +0.5) + \esegment} +\def\pcir {\lcir r:{\cradius} \pluss} +\def\puttext (#1 #2)#3{\bsegment + \setsegscale {\cradius} + \textref h:C v:C \htext (#1 #2){#3} + \esegment} +\def\putwnw #1{\puttext (-1.7 +1.2){#1}} +\def\putwsw #1{\puttext (-1.7 -1.2){#1}} +\def\putn #1{\puttext ( 0 +2 ){#1}} +\def\puts #1{\puttext ( 0 -2 ){#1}} +\def\avectoc (#1 #2){\currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + \savepos (#1 #2)(*tx *ty) + \bsegment + \move (*tx *ty) + \setsegscale {\cradius} + \rmove ({-\cosa} -\sina) + \savecurrpos (*ex *ey) + \esegment + \avec (*ex *ey) + \move (#1 #2)} +\def\avecfrc (#1 #2){\currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + \bsegment + \setsegscale {\cradius} + \move ({\cosa} \sina) + \savecurrpos (*ex *ey) + \esegment + \move (*ex *ey) + \avec (#1 #2)} + +\begin{center} +\begin{texdraw} +\drawdim in +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\pl {$\scriptscriptstyle +$} \def\mn {$\scriptscriptstyle -$} + +\move (0 +0.63) \move (0 -0.60) \move (0 0) % compensate for the text size + +% Input to the first stage +\bsegment + \Ltext{$x(n)$} + \lvec (0.3 0) \bdot \lvec (0.3 +0.4) + \move (0.3 0) \lvec (0.3 -0.4) + \savepos (0.3 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% first lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw{\pl} \puts{\mn} + \avecfrc (2.1 +0.4) + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw{\pl} \putn{\mn} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext {$f_0(n)$} + \move (2.0 +0.42) \Ttext {$f_1(n)$} + \move (0.1 -0.4) \Btext {$b_0(n)$} + \move (2.0 -0.4) \Btext {$b_1(n)$} + \textref h:L v:B \htext (1.15 +0.2){$K_1$} + \textref h:L v:T \htext (1.15 -0.2){$K_1$} + \savepos (2.1 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% center section +\bsegment + \textref h:C v:C + \htext (0.3 +0.4){$\cdots$} + \htext (0.3 -0.4){$\cdots$} + \savepos (0.6 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% last lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw{\pl} \puts{\mn} + \avecfrc (2.3 +0.4) \Rtext{$e(n)$} + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw{\pl} \putn{\mn} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext {$f_{P-1}(n)$} + \move (2.0 +0.42) \Ttext {$f_P(n)$} + \move (0.1 -0.4) \Btext {$b_{P-1}(n)$} + \move (2.0 -0.4) \Btext {$b_P(n)$} + \textref h:L v:B \htext (1.15 +0.2){$K_P$} + \textref h:L v:T \htext (1.15 -0.2){$K_P$} +\esegment +\end{texdraw} +\end{center} + +\bigskip +\begin{center} +\begin{texdraw} +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\ds {\displaystyle} +\def\ticklab (#1 #2)#3{\move(#1 #2) + \bsegment + \lvec (0 0.05) + \textref h:C v:T \htext (0 -0.05){#3} + \esegment} +\def\Rtext #1{\bsegment + \textref h:L v:C \htext ( 0.08 0){#1} + \esegment} + +\move (2.4 -0.32) % move to set the size + +\move (0 0) +% Axes +\avec (0 1.4) +\move (0 0) \avec (2.2 0) \Rtext{$\omega$} +\ticklab (0 0) {0} +\ticklab (0.8 0) {$\ds {\pi \over 2N} $} +\ticklab (1.2 0) {$\omega_s$} +\ticklab (1.6 0) {$\ds {\pi \over N} $} + +\linewd 0.025 +\move (0 1) +\lvec (0.4 1) +\lvec (0.44 0.998) +\lvec (0.48 0.988) +\lvec (0.52 0.973) +\lvec (0.56 0.951) +\lvec (0.60 0.923) +\lvec (0.64 0.891) +\lvec (0.68 0.852) +\lvec (0.72 0.809) +\lvec (0.76 0.760) +\lvec (0.80 0.707) +\lvec (0.84 0.649) +\lvec (0.88 0.587) +\lvec (0.92 0.522) +\lvec (0.96 0.454) +\lvec (1.00 0.382) +\lvec (1.04 0.309) +\lvec (1.08 0.233) +\lvec (1.12 0.156) +\lvec (1.16 0.078) +\lvec (1.20 0) +\lvec (1.9 0) +\end{texdraw} +\end{center} + +\bigskip +\begin{center} +\begin{texdraw} +\arrowheadtype t:V \arrowheadsize l:0.08 w:0.04 +\linewd 0.01 +\setunitscale 1.5 % circle will have radius 1.5 inches + +\def\Btext #1{\bsegment + \textref h:C v:T \htext (0 -0.04){#1} + \esegment} +\def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 0.04){#1} + \esegment} +\def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.04 0){#1} + \esegment} +\def\bdot {\fcir f:0 r:0.0133 } +\def\vtick {\bsegment + \move (0 -0.05) \lvec (0 0.05) + \esegment} +\def\htick {\bsegment + \move (-0.05 0) \lvec ( 0.05 0) + \esegment} +\def\Hlen #1#2{\bsegment + \vtick \avec ({#1} 0) \vtick \avec (0 0) + \relsegscale 0.5 + \move ({#1} 0) \Ttext {#2} + \esegment} +\def\Vlen #1#2{\bsegment + \htick \avec (0 {#1}) \htick \avec (0 0) + \relsegscale 0.5 + \move (0 {#1}) \Ltext {#2} + \esegment} + +\lcir r:1 % circle +\move (-1.05 0) \lvec ( 1.05 0) % axes +\move (0 -1.05) \lvec (0 1.05) + +\move (0 0) \lvec (0.707 0.707) \bdot +\rmove (0.02 0.02) \textref h:L v:B \htext {X} +\move (0.707 -0.707) \bdot +\textref h:R v:T \htext(-0.02 -0.02){O} + +\move (0.5 0) % center of ellipse +\bsegment + \lellip rx:0.435 ry:0.804 + \bdot \Btext {$\beta_2$} + \move (0 0.15) \Hlen {0.435}{$|\beta_1{+}\beta_3|$} + \move (-0.7 0) \Vlen {0.804}{$|\beta_1{-}\beta_3|$} +\esegment +\end{texdraw} +\end{center} + +\end{document} diff --git a/Master/texmf-dist/doc/texdraw/txdexamp.tex b/Master/texmf-dist/doc/texdraw/txdexamp.tex new file mode 100644 index 00000000000..371b0e64969 --- /dev/null +++ b/Master/texmf-dist/doc/texdraw/txdexamp.tex @@ -0,0 +1,485 @@ +% TeXdraw examples + +% $Id: txdexamp.tex,v 2.0 1995/12/18 texdraw-V2R0 $ + +% These examples are taken from the TeXdraw manual. Note that the fonts +% for text will be different from those in the manual -- here we use the +% plain TeX defaults. + +% Peter Kabal +% Department of Electrical Engineering +% McGill University +% 3480 University +% Montreal, Quebec +% Canada H3A 2A7 + +% kabal@TSP.EE.McGill.CA + +\input texdraw +\input txdtools +\let\et=\etexdraw +\def\etexdraw{\drawbb\et} + +\noindent +TeXdraw examples using plain TeX. + +\bigskip +\centertexdraw{ + \avec (0 0.8) \textref h:C v:B \htext (0 0.9){\sl y} + \move (0 0) \avec (0.8 0) \textref h:L v:C \htext(0.9 0){\sl x} + \move (0 1.0)} + +\bigskip +\centertexdraw{ + \drawdim{cm} \linewd 0.02 + \move(2 2) \lvec(3 3) \lvec(2 4) \lvec(1 3) \lvec(2 2) + \textref h:C v:C \htext(2 3){$\sum \rho_n$} +} + +\bigskip +\centertexdraw{ + \drawdim in + \linewd 0.03 \setgray 0.6 \arrowheadtype t:F \avec(0.5 0.5) + \linewd 0.01 \setgray 0 \arrowheadtype t:V \avec(1.0 0.5) + \linewd 0.015 \lpatt(0.067 0.1) \lvec (1.5 0) + \linewd 0.02 \lpatt() \arrowheadtype t:T \avec(2.0 0.5) + \arrowheadtype t:H \avec(2.5 0.5) + \setgray 0.4 \arrowheadtype t:W \avec(3.0 0) + \textref h:R v:T \htext (0.35 0.50){\tt t:F} + \textref h:R v:T \htext (1.0 0.43){\tt t:V} + \textref h:R v:T \htext (1.82 0.50){\tt t:T} + \textref h:R v:T \htext (2.5 0.43){\tt t:H} + \textref h:R v:B \htext (2.8 0){\tt t:W} +} + +\bigskip +\centertexdraw{ + \def\bdot {\bsegment + \fcir f:0 r:0.02 + \esegment} + \def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 +0.06){#1} + \esegment} + \def\Btext #1{\bsegment + \textref h:C v:T \htext (0 -0.06){#1} + \esegment} + \def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.08 0){#1} + \esegment} + \def\Rtext #1{\bsegment + \textref h:L v:C \htext (+0.08 0){#1} + \esegment} + \move (-1.5 0) + \bsegment + \move (+1.55 +0.45) \move (-1.55 -0.45) \move (0 0) + \Ttext{Horizontal Text} + \bdot \Btext{\tt h:C v:C} + \move (-0.9 0) \bdot \Ltext{\tt h:L v:C} + \move (+0.9 0) \bdot \Rtext{\tt h:R v:C} + \move (0 +0.3) \bdot \Ttext{\tt h:C v:T} + \move (0 -0.3) \bdot \Btext{\tt h:C v:B} + \move (-0.9 -0.3) \bdot \Ltext{\tt h:L v:B} + \lvec (-0.9 +0.3) \bdot \Ltext{\tt h:L v:T} + \lvec (+0.9 +0.3) \bdot \Rtext{\tt h:R v:T} + \lvec (+0.9 -0.3) \bdot \Rtext{\tt h:R v:B} + \lvec (-0.9 -0.3) + \esegment + \def\atext {\rtext td:45 } + \def\ATtext #1{\bsegment + \setsegscale 0.707 + \textref h:C v:B \atext (-0.06 +0.06){#1} + \esegment} + \def\ABtext #1{\bsegment + \setsegscale 0.707 + \textref h:C v:T \atext (+0.060 -0.06){#1} + \esegment} + \def\ALtext #1{\bsegment + \setsegscale 0.707 + \textref h:R v:C \atext (-0.08 -0.08){#1} + \esegment} + \def\ARtext #1{\bsegment + \setsegscale 0.707 + \textref h:L v:C \atext (+0.08 +0.08){#1} + \esegment} + \move (+1.5 0) + \bsegment + \move (+1.33 +1.33) \move (-1.33 -1.33) \move (0 0) + \setsegscale 0.707 + \ATtext{Rotated Text} + \bdot \ABtext{\tt h:C v:C} + \move (-0.9 -0.9) \bdot \ALtext{\tt h:L v:C} + \move (+0.9 +0.9) \bdot \ARtext{\tt h:R v:C} + \move (-0.3 +0.3) \bdot \ATtext{\tt h:C v:T} + \move (+0.3 -0.3) \bdot \ABtext{\tt h:C v:B} + \move (-0.6 -1.2) \bdot \ALtext{\tt h:L v:B} + \lvec (-1.2 -0.6) \bdot \ALtext{\tt h:L v:T} + \lvec (+0.6 +1.2) \bdot \ARtext{\tt h:R v:T} + \lvec (+1.2 +0.6) \bdot \ARtext{\tt h:R v:B} + \lvec (-0.6 -1.2) + \esegment +} + +\vfill +\eject + + +\bigskip +\centertexdraw{ + \move(-0.75 -0.25) \lvec (-0.75 +0.5) \lvec (+0.75 +0.5) + \lvec(+0.75 -0.25) \ifill f:0.9 % fill the region + \move(0 0) + \avec(-0.75 -0.25) \textref h:R v:C \htext{H-text} + \move(0 0) \avec(-0.75 +0.25) \textref h:R v:B \htext{H-text} + \move(0 0) \avec(0 +0.5) \textref h:L v:T \vtext{V-text} + \move(0 0) \avec(+0.75 +0.25) \textref h:L v:B \htext{H-text} + \move(0 0) \avec(+0.75 -0.25) \textref h:L v:C \htext{H-text} + \move (-1.15 -0.3) \move (+1.15 +0.92) % increase the size of the drawing +} + +\bigskip +\centertexdraw{ + \linewd 0.02 + \fcir f:0.7 r:1 + \larc r:1 sd:45 ed:135 + \lvec ( 0.707 0.707) \move (0 0) \lvec (-0.707 +0.707) +} + +\bigskip +\centertexdraw{ + \def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.08 0){#1} + \esegment} + \def\Rtext #1{\bsegment + \textref h:L v:C \htext (+0.08 0){#1} + \esegment} + \def\bdot {\fcir f:0 r:0.02 } + \def\Ldot #1{\bdot \Ltext{#1}} + \def\Rdot #1{\bdot \Rtext{#1}} + \move (-2 0) + \bsegment + \lpatt (0.033) + \move (0 0) \Ldot{0} \lvec (0 1) \Ldot{1} + \lvec (1 1) \Rdot{2} \lvec (1 0) \Rdot{3} + \lpatt () + \move (0 0) \clvec (0 1)(1 1)(1 0) + \esegment + \move (0 0) + \bsegment + \lpatt (0.033) + \move (0 0) \Ldot{0} \lvec (0.5 0.8) \Ldot{1} + \lvec (1.5 0.8) \Rdot{2} \lvec (1 0) \Rdot{3} + \lpatt () + \move (0 0) \clvec (0.5 1)(1.5 1)(1 0) + \esegment + \move ( 2 0) + \bsegment + \lpatt (0.033) + \move (0 0) \Ldot{0} \lvec (0 1) \Ldot{1} + \lvec (1 0) \Rdot{2} \lvec (1 1) \Rdot{3} + \lpatt () + \move (0 0) \clvec (0 1)(1 0)(1 1) + \esegment +} + +\bigskip +\centertexdraw{ +\move (0.5 0) +\lvec (0 0.5) \clvec (0.5 0.85)(1 0.65)(1.5 1) +\lvec (2 0.5) \clvec (1.5 0.15)(1 0.35)(0.5 0) +\lfill f:0.8 +} + +\vfill +\eject + + +\bigskip +\def\tbox #1{\bsegment + \lvec (0 +0.25) \lvec (0.75 +0.25) + \lvec (0.75 -0.25) \lvec (0 -0.25) \lvec (0 0) + \textref h:C v:C \htext (0.375 0){#1} + \savepos (0.75 0)(*ex *ey) + \esegment + \move (*ex *ey)} +\centertexdraw{ + \ravec (1 0) \tbox{$H(z)$} \ravec (1 0) +} + +\bigskip +\def\cavec (#1 #2)(#3 #4)(#5 #6){ + \clvec (#1 #2)(#3 #4)(#5 #6) + \cossin (#3 #4)(#5 #6)\cosa\sina + \rmove (0 0) % stroke the Bezier curve + \bsegment + \drawdim in \setsegscale 0.05 + \move ({-\cosa} -\sina) \avec (0 0) + \esegment} + +\def\caw (#1 #2){ + \currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + +% The nominal wiggly curve is (0 0) (1+dx dy) (-dx -dy) (1 0) +% Find the rotated offset (dx dy) -> (du dv) + \rotatecoord (0.4 0.1)\cosa\sina \du\dv + +% calculate the length of the vector + \vectlen ({\xa} \ya)(#1 #2)\len + +% draw the curve in normalized units + \bsegment + \setsegscale {\len} + \realadd \cosa \du \tmpa \realadd \sina \dv \tmpb + \cavec ({\tmpa} \tmpb)({-\du} -\dv)({\cosa} \sina) + \esegment + + \move (#1 #2)} + +% rotate a coordinate (x y) +% arguments: (x y) cosa sina x' y' +% x' = cosa * x - sina * y; y' = sina * x + cosa * y +\def\rotatecoord (#1 #2)#3#4#5#6{ + \getpos (#1 #2)\xarg\yarg + \realmult \xarg {#3} \tmpa \realmult \yarg {#4} \tmpb + \realadd \tmpa {-\tmpb} #5 + \realmult \xarg {#4} \tmpa \realmult \yarg {#3} \tmpb + \realadd \tmpa \tmpb #6} + +\centertexdraw{ + \arrowheadtype t:W + \move (0 0) + \cavec (1.4 0.1)(-0.4 -0.1)(1 0) + \move (1 0) \caw (1 1) \htext{tip at \tt (1 1)} + \move (1 0) \caw (2 1) \htext{tip at \tt (2 1)} + \move (1 0) \caw (2 0) \htext{tip at \tt (2 0)} + \move (0 1.13) \move (0 -0.04) +} + +\vfill +\eject + + +\bigskip +\def\delay {\bsegment + \setsegscale 0.3 + \lvec (0 +0.5) \lvec (1 +0.5) \lvec (1 -0.5) + \lvec (0 -0.5) \lvec (0 0) + \textref h:C v:C \htext (0.5 0){$z^{-1}$} + \savepos (1 0)(*ex *ey) + \esegment + \move (*ex *ey)} +\def\bdot {\fcir f:0 r:0.02 } +\def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 +0.06){#1} + \esegment} +\def\Btext #1{\bsegment + \textref h:C v:T \htext (0 -0.06){#1} + \esegment} +\def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.06 0){#1} + \esegment} +\def\Rtext #1{\bsegment + \textref h:L v:C \htext (+0.06 0){#1} + \esegment} +\def\cradius {0.08} +\def\pluss {\bsegment + \setsegscale {\cradius} + \move (-0.5 0) \lvec (+0.5 0) + \move (0 -0.5) \lvec (0 +0.5) + \esegment} +\def\pcir {\lcir r:{\cradius} \pluss} +\def\puttext (#1 #2)#3{\bsegment + \setsegscale {\cradius} + \textref h:C v:C \htext (#1 #2){#3} + \esegment} +\def\putwnw #1{\puttext (-1.7 +1.2){#1}} +\def\putwsw #1{\puttext (-1.7 -1.2){#1}} +\def\putn #1{\puttext ( 0 +2 ){#1}} +\def\puts #1{\puttext ( 0 -2 ){#1}} +\def\avectoc (#1 #2){\currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + \savepos (#1 #2)(*tx *ty) + \bsegment + \move (*tx *ty) + \setsegscale {\cradius} + \rmove ({-\cosa} -\sina) + \savecurrpos (*ex *ey) + \esegment + \avec (*ex *ey) + \move (#1 #2)} +\def\avecfrc (#1 #2){\currentpos \xa\ya + \cossin ({\xa} \ya)(#1 #2)\cosa\sina + \bsegment + \setsegscale {\cradius} + \move ({\cosa} \sina) + \savecurrpos (*ex *ey) + \esegment + \move (*ex *ey) + \avec (#1 #2)} + +\centertexdraw{ +\drawdim in +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\pl {$\scriptscriptstyle +$} \def\mn {$\scriptscriptstyle -$} + +\move (0 +0.63) \move (0 -0.60) \move (0 0) % compensate for the text size + +% Input to the first stage +\bsegment + \Ltext{$x(n)$} + \lvec (0.3 0) \bdot \lvec (0.3 +0.4) + \move (0.3 0) \lvec (0.3 -0.4) + \savepos (0.3 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% first lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw{\pl} \puts{\mn} + \avecfrc (2.1 +0.4) + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw{\pl} \putn{\mn} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext {$f_0(n)$} + \move (2.0 +0.42) \Ttext {$f_1(n)$} + \move (0.1 -0.4) \Btext {$b_0(n)$} + \move (2.0 -0.4) \Btext {$b_1(n)$} + \textref h:L v:B \htext (1.15 +0.2){$K_1$} + \textref h:L v:T \htext (1.15 -0.2){$K_1$} + \savepos (2.1 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% center section +\bsegment + \textref h:C v:C + \htext (0.3 +0.4){$\cdots$} + \htext (0.3 -0.4){$\cdots$} + \savepos (0.6 0)(*ex *ey) +\esegment +\move (*ex *ey) + +% last lattice stage +\bsegment + \move (0 +0.4) \avectoc (1.7 +0.4) + \pcir \putwnw{\pl} \puts{\mn} + \avecfrc (2.3 +0.4) \Rtext{$e(n)$} + \move (0 -0.4) \avec (0.4 -0.4) \delay \avectoc (1.7 -0.4) + \pcir \putwsw{\pl} \putn{\mn} + \avecfrc (2.1 -0.4) + \move (0.9 +0.4) \bdot \avectoc (1.7 -0.4) + \move (0.9 -0.4) \bdot \avectoc (1.7 +0.4) + \move (0.1 +0.42) \Ttext {$f_{P-1}(n)$} + \move (2.0 +0.42) \Ttext {$f_P(n)$} + \move (0.1 -0.4) \Btext {$b_{P-1}(n)$} + \move (2.0 -0.4) \Btext {$b_P(n)$} + \textref h:L v:B \htext (1.15 +0.2){$K_P$} + \textref h:L v:T \htext (1.15 -0.2){$K_P$} +\esegment +} + +\bigskip +\centertexdraw{ +\arrowheadtype t:F \arrowheadsize l:0.08 w:0.04 +\def\ds {\displaystyle} +\def\ticklab (#1 #2)#3{\move(#1 #2) + \bsegment + \lvec (0 0.05) + \textref h:C v:T \htext (0 -0.05){#3} + \esegment} +\def\Rtext #1{\bsegment + \textref h:L v:C \htext ( 0.08 0){#1} + \esegment} + +\move (2.4 -0.32) % move to set the size + +\move (0 0) +% Axes +\avec (0 1.4) +\move (0 0) \avec (2.2 0) \Rtext{$\omega$} +\ticklab (0 0) {0} +\ticklab (0.8 0) {$\ds {\pi \over 2N} $} +\ticklab (1.2 0) {$\omega_s$} +\ticklab (1.6 0) {$\ds {\pi \over N} $} + +\linewd 0.025 +\move (0 1) +\lvec (0.4 1) +\lvec (0.44 0.998) +\lvec (0.48 0.988) +\lvec (0.52 0.973) +\lvec (0.56 0.951) +\lvec (0.60 0.923) +\lvec (0.64 0.891) +\lvec (0.68 0.852) +\lvec (0.72 0.809) +\lvec (0.76 0.760) +\lvec (0.80 0.707) +\lvec (0.84 0.649) +\lvec (0.88 0.587) +\lvec (0.92 0.522) +\lvec (0.96 0.454) +\lvec (1.00 0.382) +\lvec (1.04 0.309) +\lvec (1.08 0.233) +\lvec (1.12 0.156) +\lvec (1.16 0.078) +\lvec (1.20 0) +\lvec (1.9 0) +} + +\bigskip +\centertexdraw{ +\arrowheadtype t:V \arrowheadsize l:0.08 w:0.04 +\linewd 0.01 +\setunitscale 1.5 % circle will have radius 1.5 inches + +\def\Btext #1{\bsegment + \textref h:C v:T \htext (0 -0.04){#1} + \esegment} +\def\Ttext #1{\bsegment + \textref h:C v:B \htext (0 0.04){#1} + \esegment} +\def\Ltext #1{\bsegment + \textref h:R v:C \htext (-0.04 0){#1} + \esegment} +\def\bdot {\fcir f:0 r:0.0133 } +\def\vtick {\bsegment + \move (0 -0.05) \lvec (0 0.05) + \esegment} +\def\htick {\bsegment + \move (-0.05 0) \lvec ( 0.05 0) + \esegment} +\def\Hlen #1#2{\bsegment + \vtick \avec ({#1} 0) \vtick \avec (0 0) + \relsegscale 0.5 + \move ({#1} 0) \Ttext {#2} + \esegment} +\def\Vlen #1#2{\bsegment + \htick \avec (0 {#1}) \htick \avec (0 0) + \relsegscale 0.5 + \move (0 {#1}) \Ltext {#2} + \esegment} + +\lcir r:1 % circle +\move (-1.05 0) \lvec ( 1.05 0) % axes +\move (0 -1.05) \lvec (0 1.05) + +\move (0 0) \lvec (0.707 0.707) \bdot +\rmove (0.02 0.02) \textref h:L v:B \htext {X} +\move (0.707 -0.707) \bdot +\textref h:R v:T \htext(-0.02 -0.02){O} + +\move (0.5 0) % center of ellipse +\bsegment + \lellip rx:0.435 ry:0.804 + \bdot \Btext {$\beta_2$} + \move (0 0.15) \Hlen {0.435}{$|\beta_1{+}\beta_3|$} + \move (-0.7 0) \Vlen {0.804}{$|\beta_1{-}\beta_3|$} +\esegment +} + +\bye |