This is Info file texdraw, produced by Makeinfo-1.64 from the input file texdraw.texi. This file documents TeXdraw, a system for producing PostScript drawings from TeX. Copyright (C) 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. 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.  File: texdraw, Node: Extending TeXdraw, Next: How TeXdraw merges graphics and text, Prev: Errors while using TeXdraw, Up: More Details Extending TeXdraw ================= 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. 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. Included with TeXdraw is a set of macros for directly accessing PostScript functions. These are described in an appendix (*note PostScript Commands::.). 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 (*note TeXdraw Toolbox: TeXdraw Toolbox.). * Menu: * Scaling:: * Resolution:: * Text placement:: * Intermediate PostScript file::  File: texdraw, Node: Scaling, Next: Resolution, Up: Extending TeXdraw Scaling ------- The scaling commands provided in TeXdraw are designed to affect only the coordinate values specified in commands. For instance, changing the `\setunitscale' value changes the interpretation of the coordinate in an `\avec (X Y)' 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 `\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 `\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.  File: texdraw, Node: Resolution, Next: Text placement, Prev: Scaling, Up: Extending TeXdraw Resolution ---------- 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. The position saving mechanism in TeXdraw (*note Saving positions::.) associates the pixel coordinates of a position with the specified name. 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.  File: texdraw, Node: Text placement, Next: Intermediate PostScript file, Prev: Resolution, Up: Extending TeXdraw Text placement -------------- 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 `\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 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. 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 `\special' command. This PostScript code is embedded in the dvi (device independent) file that TeX produces.  File: texdraw, Node: Intermediate PostScript file, Prev: Text placement, Up: Extending TeXdraw The intermediate 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 `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 TeXdraw. 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 `BoundingBox' information may indicate a drawing size larger than the PostScript commands themselves would warrant. 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. If TeXdraw is used only for moves and text, no intermediate PostScript file will be created.  File: texdraw, Node: How TeXdraw merges graphics and text, Prev: Extending TeXdraw, Up: More Details How TeXdraw merges graphics and text ==================================== 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. The LaTeX2e front-end for TeXdraw is enabled by including the `texdraw' package. The `texdraw' package automatically invokes the standard `graphics' package distributed with LaTeX2e. The `graphics' package has support for a number of different printer drivers, including a number for PostScript printers. Any options to the `texdraw' package are passed on to the `graphics' package. Such an option can be used to select a driver other than the default one. Within the `graphics' package, the driver option is used to select definitions for the low-level macros which generate the `\special' commands needed to request insertion of a graphics file and to rotate text.(1) TeXdraw uses the user-level macros defined by the `graphics' package (*note PostScript printer drivers::.). When not used with the LaTeX2e front-end, TeXdraw defines versions of these macros that are suitable for use with the `dvips' printer driver. ---------- Footnotes ---------- (1) Not all PostScript drivers support text rotation.  File: texdraw, Node: PostScript Commands, Next: TeXdraw Toolbox, Prev: More Details, Up: Top 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 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 `PostScript Language Reference Manual, Second Edition', Adobe Systems, Addison-Wesley, 1990. These macros are distributed in file `txdps.tex'. The `\PSsetlinecap' and `\PSsetlinejoin' 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. `\PSsetlinecap TYPE' Set the line cap parameter. The value `0' gives a butt cap; `1' gives a round cap; and `2' gives a projecting square cap. The initial value is corresponds to a round cap. `\PSsetlinejoin TYPE' Set the line join parameter. The value `0' gives a miter join; `1' gives a round join; and `2' gives a bevel join. The initial value corresponds to a round join. 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 `\PSmoveto' command) before invoking basic TeXdraw commands. `\PSstroke' Stroke a PostScript path. The current path is stroked with the current gray level (set with `\setgray') and the current line pattern (set with `\lpatt'). The PostScript current point becomes undefined. `\PSnewpath' Establish a new path. The PostScript current point becomes undefined. `\PSclosepath' Close a subpath. A new subpath is started. `\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 TeXdraw command `\setgray'. 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. `\PSlineto (X Y)' Add a line segment to the current path. This command is identical to the TeXdraw command `\lvec'. The PostScript current point must be defined before this command is issued. `\PSmoveto (X Y)' Move to the coordinate specified by `(X Y)'. The PostScript current point becomes defined. 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. `\PSarc r:RADIUS sd:START-ANGLE ed:END-ANGLE (X Y)' Draw a counterclockwise arc. The center of the arc is at the given position. The radius is specified by RADIUS. The start and end angles (in degrees) are specified by START-ANGLE and 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. `\PSarcn r:RADIUS sd:START-ANGLE ed:END-ANGLE (X Y)' Draw a clockwise arc. The center of the arc is at the given position. The radius is specified by RADIUS. The start and end angles (in degrees) are specified by START-ANGLE and 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. The macro `\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 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. `\writeps {}' 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.  File: texdraw, Node: TeXdraw Toolbox, Next: Examples, Prev: PostScript Commands, Up: Top TeXdraw Toolbox *************** 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 `txdtools.tex'. * Menu: * Coordinate parsing:: * Real arithmetic:: * Arrow curve::  File: texdraw, Node: Coordinate parsing, Next: Real arithmetic, Up: TeXdraw Toolbox Coordinate parsing ================== The coordinate parsing macro `\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 `\currentpos' returns the relative coordinates of the current position. The returned values are relative to the current segment and the current scaling. The macro `\cossin' returns the real-valued cosine and sine of the direction of the line joining two points. The macro `\vectlen' returns the length of a vector. The results appear as the value of user supplied macro names. `\getpos (X Y)\MX\MY' Decode coordinate values. The coordinates specified by `(X 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 `\MX' and `\MY'. `\currentpos \MX\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 `\MX' and `\MY'. `\cossin (X1 Y1)(X2 Y2)\COSA\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 `(X1 Y1)' to `(X2 Y2)'. The character strings representing these real-valued quantities are assigned to the macros specified by `\COSA' and `\SINA'. `\vectlen (X1 Y1)(X2 Y2)\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 `\LEN'.  File: texdraw, Node: Real arithmetic, Next: Arrow curve, Prev: Coordinate parsing, Up: TeXdraw Toolbox Real arithmetic =============== The TeXdraw toolbox supplies macros to perform real arithmetic on coordinate values. The result appears as the value of a user supplied macro name. `\realadd {VALUE1} {VALUE2} \SUM' Add two real quantities, assigning the resultant character string representing the sum to the macro `\SUM'. `\realmult {VALUE1} {VALUE2} \PROD' Multiply two real quantities, assigning the resultant character string representing the product to the macro `\PROD'. `\realdiv {VALUE1} {VALUE2} \RESULT' Divide two real quantities, assigning the resultant character string representing the result of VALUE1/VALUE2 to the macro `\RESULT'.  File: texdraw, Node: Arrow curve, Prev: Real arithmetic, Up: TeXdraw Toolbox Arrow curve =========== 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. The first macro, `\cavec', uses the `\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. \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} Note the use of macros as arguments to a `\move' command. Minus signs are put in front of the macros. However, the value of the macro `\cosa' or `\sina' could be negative. Fortunately, TeX accepts two minus signs in a row and interprets the result as positive. Note that the `\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 `\caw' builds on `\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. \centertexdraw{ \move (0 0) \cavec (1.4 0.1)(-0.4 -0.1)(1 0) } This curve has the appropriate wiggle. Now we want to be able to draw this curve, appropriately scaled and rotated. The macro `\caw' needs to do computations on the coordinates. First, `\caw' uses the macros `\getpos' and `\currentpos' to get the positions of the end and start of the curve. Next, the length of the vector is calculated using the macro `\vectlen'. A local macro `\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. \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} Finally, the new macro can be used as follows. \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)} } Note that the Bezier curve in the macro `\cavec' lies below the arrowhead. The example then draws an arrowhead of type `W' to erase the part of the line below the arrowhead.  File: texdraw, Node: Examples, Next: Command Listing, Prev: TeXdraw Toolbox, Up: Top Examples ******** This appendix shows examples of the use of TeXdraw. * Menu: * Block diagram:: * Filter response graph:: * Geometric construction::  File: texdraw, Node: Block diagram, Next: Filter response graph, Up: Examples Block diagram of a lattice filter ================================= The block diagram of a lattice filter uses a library of extended commands built from the basic TeXdraw commands. 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, `\bdot', draws a "big" dot which is used to mark junctions of lines. The `\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 (`\Btext'), to the left of a point (`\Ltext') and to the right of a point (`\Rtext') are used in the final drawing. \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} 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 `\cradius'. The summing nodes will have enclosed plus signs, appropriately scaled. The plus sign is drawn by the macro `\pluss'. The macro `\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 `\putwnw' places text west by north-west relative to the center of the summing node. \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}} 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 (`\avectoc') and an arrow vector leaving from a circle (`\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 `\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. \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)} 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. \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 } The macros used in this example are similar to the block diagram macros defined in the file `blockdiagram.tex'.  File: texdraw, Node: Filter response graph, Next: Geometric construction, Prev: Block diagram, Up: Examples Filter response graph ===================== 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 X and Y scaling. Nonetheless, for certain simple graphs, TeXdraw is adequate. In this example, macro `\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. \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) }  File: texdraw, Node: Geometric construction, Prev: Filter response graph, Up: Examples Geometric construction ====================== 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. \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 }  File: texdraw, Node: Command Listing, Next: Command Index, Prev: Examples, Up: Top Alphabetic listing of commands ****************************** `\arrowheadsize l:LENGTH w:WIDTH' Set the arrowhead size to be LENGTH units long and WIDTH units wide. The width is measured across the "base" of the arrowhead. The initial arrowhead size has a LENGTH of 0.16 inches and a WIDTH of 0.08 inches. `\arrowheadtype t:TYPE' Set the arrowhead type to TYPE, where TYPE is one of `F', `T', `W', `V', or `H'. There are two kinds of arrowheads. The first kind is a triangle. There are 3 variants: type `T' is an empty triangle, type `F' is a filled triangle (using the current gray level for lines), type `W' is a triangle filled with white. The second kind of arrowhead is an open ended Vee. There are 2 variants: type `V' has the stem continue to the tip, type `H' has the stem stop at the base of the arrowhead. The initial arrowhead type is `T'. `\avec (X Y)' Draw a line with an arrowhead from the current position to `(X Y)'. The new current position is `(X Y)'. The arrowhead is aligned with the line, with the tip at `(X Y)'. `\begin{texdraw}' Start a TeXdraw drawing. The drawing is terminated with an `\end{texdraw}' command. This command is for use with LaTeX. `\bsegment' Start a drawing segment. The coordinate system is shifted such that the current position corresponds to the coordinate `(0 0)'. Changes to scaling, position and line parameters stay local to the drawing segment. `\btexdraw' Start a TeXdraw drawing. The drawing is terminated with an `\etexdraw' command. `\centertexdraw { ... }' Center a TeXdraw box. The argument contains TeXdraw commands. The resulting box has the horizontal size `\hsize' and height equal to the height of the drawing. `\clvec (X1 Y1)(X2 Y2)(X3 Y3)' Draw a Bezier curve from the current position to the coordinate `(X3 Y3)' which becomes the new current position. The coordinates `(X1 Y1)' and `(X2 Y2)' serve as control points for the curve. Only the last coordinate given is used to update the size of the drawing. `\drawbb' Draw a ruled box around the effective size of a drawing produced by TeXdraw commands. `\drawdim DIM' Set the units to DIM. The argument DIM can be any valid TeX dimension unit. The units are used to interpret coordinate values. Examples of valid units: `cm', `mm', `in', `pt', and `bp'. `\end{texdraw}' End a TeXdraw drawing started with a `\begin{texdraw}' 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. `\esegment' End a drawing segment. The current position in effect before the corresponding `\bsegment' command is restored. The scaling and line parameter values revert to those in effect before the corresponding `\bsegment' was invoked. `\etexdraw' End a TeXdraw drawing started with a `\btexdraw' 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. `\everytexdraw { ... }' Specify TeXdraw commands to be executed at the beginning of every TeXdraw drawing. `\fcir f:LEVEL r:RADIUS' Draw a filled circle with center at the current position. The radius is specified by RADIUS. The circle is painted with the gray level specified by 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. `\fellip f:LEVEL rx:X-RADIUS ry:Y-RADIUS' Draw a filled ellipse with center at the current position. The radius in the X direction is specified by X-RADIUS. The radius in the Y direction is specified by Y-RADIUS. The ellipse is painted with the gray level specified by 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. `\htext (X Y){TEXT}' `\htext {TEXT}' The first form of this command places the TeX text TEXT horizontally with the text reference point at the coordinate `(X Y)'. The new current position is `(X Y)'. The second form of this command places the TeX text TEXT horizontally with the text reference point at the current position. The text reference point is set with the `\textref' command. `\ifill f:LEVEL' Close the current path and paint the interior of the region with gray level LEVEL. The line around the path is not drawn. Gray levels are real values from 0 (black) through intermediate values (grays) to 1 (white). `\larc r:RADIUS sd:START-ANGLE ed:END-ANGLE' Draw a counterclockwise arc. The center of the arc is at the current position. The radius is specified by RADIUS. The start and end angles (in degrees) are specified by START-ANGLE and END-ANGLE. This command does not affect the limits (size) of the drawing. `\lcir r:RADIUS' Draw a circle with center at the current position. The radius is specified by RADIUS. This command draws a line along the circumference of the circle. The drawing size is increased if necessary to contain the circle. `\lellip rx:X-RADIUS ry:Y-RADIUS' Draw an ellipse with center at the current position. The radius in the X direction is specified by X-RADIUS. The radius in the Y direction is specified by Y-RADIUS. The drawing size is increased if necessary to contain the ellipse. `\lfill f: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 LEVEL. Gray levels are real values from 0 (black) through intermediate values (grays) to 1 (white). `\linewd WIDTH' Set the line width to WIDTH units. Initially WIDTH is 0.01 inches (corresponding to 3 pixels at 300 pixels to the inch). `\lpatt (PATTERN)' Set lines to have the pattern `(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 `\lpatt ()'. `\lvec (X Y)' Draw a line from the current position to coordinate `(X Y)'. The new current position is `(X Y)'. `\move (X Y)' Move to coordinate `(X Y)'. The new current position is `(X Y)'. `\ravec (DX DY)' Draw a line with an arrowhead from the current position, DX units in the X direction and Y units in the 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. `\relsegscale VALUE' Adjust the segment scale factor by multiplying by 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. `\relunitscale VALUE' Adjust the unit scale factor by multiplying by 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. `\rlvec (DX DY)' Draw a line from the current position, DX units in the X direction and DY units in the Y direction. The final position becomes the new current position. `\rmove (DX DY)' Move from the current position, DX units in the X direction and DY units in the Y direction. The final position becomes the new current position. `\rtext td:ANGLE (x y){TEXT}' `\rtext td:ANGLE {TEXT}' The first form of this command places the TeX text TEXT at an angle with the text reference point at the coordinate `(X Y)'. The new current position is `(X Y)'. The second form of this command places the TeX text 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 ANGLE degrees about the text reference point. The text reference point is set with the `\textref' command. `\savecurrpos (*PX *PY)' Save the current position as the absolute position referenced by `(*PX *PY)'. `\savepos (X Y)(*PX *PY)' Save the coordinate position `(X Y)' as the absolute position referenced by `(*PX *PY)'. The coordinate `(X Y)' is interpreted in the normal fashion as a coordinate relative to the current segment, using the current scaling factors and drawing unit. `\setgray 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. `\setsegscale SCALE' Set the segment scale factor. The argument 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. `\setunitscale SCALE' Set the unit scaling to SCALE. The argument 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. `\texdrawbox { ... }' 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. `\textref h:H-REF v:V-REF' Set the text reference point for subsequent text commands. The horizontal reference point H-REF is one of `L', `C' or `R' (left, center or right). The vertical reference point V-REF is one of `T', `C' or `B' (top, center or bottom). For rotated text, the reference point is determined before rotation. The initial text reference point corresponds to `\textref h:L v:B'. `\vtext (x y){TEXT}' `\vtext {TEXT}' The first form of this command places the TeX text TEXT vertically with the text reference point at the coordinate `(X Y)'. The new current position is `(X Y)'. The second form of this command places the TeX text 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 `\textref' command.  File: texdraw, Node: Command Index, Next: Concept Index, Prev: Command Listing, Up: Top Command Index ************* * Menu: * \arc: Circles and arcs. * \arrowheadsize: Line vectors. * \arrowheadtype: Line vectors. * \avec: Line vectors. * \begin{texdraw}: Accessing TeXdraw. * \bsegment: Drawing segments. * \btexdraw: Accessing TeXdraw. * \centertexdraw: Accessing TeXdraw. * \clvec: Bezier curves. * \cossin: Coordinate parsing. * \currentpos: Coordinate parsing. * \drawbb: Drawing size. * \drawdim: Coordinate specification. * \end{texdraw}: Accessing TeXdraw. * \esegment: Drawing segments. * \etexdraw: Accessing TeXdraw. * \everytexdraw: Accessing TeXdraw. * \fcir: Circles and arcs. * \fellip: Circles and arcs. * \getpos: Coordinate parsing. * \htext: TeX text. * \ifill: Fill commands. * \lcir: Circles and arcs. * \lellip: Circles and arcs. * \lfill: Fill commands. * \linewd: Line vectors. * \lvec: Line vectors. * \move: Line vectors. * \PSarc: PostScript Commands. * \PSarcn: PostScript Commands. * \PSclosepath: PostScript Commands. * \PSfill: PostScript Commands. * \PSlineto: PostScript Commands. * \PSmoveto: PostScript Commands. * \PSnewpath: PostScript Commands. * \PSsetlinecap: PostScript Commands. * \PSsetlinejoin: PostScript Commands. * \PSstroke: PostScript Commands. * \ravec: Line vectors. * \realadd: Real arithmetic. * \realdiv: Real arithmetic. * \realmult: Real arithmetic. * \relsegscale: Scaling coordinates. * \relunitscale: Scaling coordinates. * \rlvec: Line vectors. * \rmove: Line vectors. * \rtext: TeX text. * \savecurrpos: Saving positions. * \savepos: Saving positions. * \setgray: Line vectors. * \setsegscale: Scaling coordinates. * \setunitscale: Scaling coordinates. * \textref: TeX text. * \vectlen: Coordinate parsing. * \vtext: TeX text. * \writeps: PostScript Commands. * arc: PostScript Commands. * arcn: PostScript Commands. * closepath: PostScript Commands. * fill: PostScript Commands. * lineto: PostScript Commands. * moveto: PostScript Commands. * newpath: PostScript Commands. * setlinecap: PostScript Commands. * setlinejoin: PostScript Commands. * stroke: PostScript Commands.