summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/texdraw/texdraw_2.html
blob: 25abbb1af0efdfaf64036b810ca2b389650fbdc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
<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>