diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /info/metapost |
Initial commit
Diffstat (limited to 'info/metapost')
22 files changed, 18040 insertions, 0 deletions
diff --git a/info/metapost/doc/russian/mpman-ru/Makefile b/info/metapost/doc/russian/mpman-ru/Makefile new file mode 100644 index 0000000000..1df6e24cfc --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/Makefile @@ -0,0 +1,23 @@ +# Makefile for MetaPost documentation. Public domain. + +pdflatex = pdflatex +mpost = TEX=tex mpost + +all: mpman-ru.pdf + +mpman-ru.pdf: mpman-ru.tex mpman-ru.bbl manfig-ru.mp + $(mpost) manfig-ru + $(pdflatex) mpman-ru + $(pdflatex) mpman-ru + $(pdflatex) mpman-ru + makeindex -s mpman.ist mpman-ru + cp mpman-ru.ind mpman-ru.ind.src + awk -f idx1.awk mpman-ru.ind.src | awk -f idx2.awk | sort | awk -f idx3.awk >mpman-ru.ind + awk -f extract-bm.awk mpman-ru.tex >mpman-ru.out.raw + iconv -f koi8-r -t utf-8 mpman-ru.out.raw > mpman-ru.out.utf8 + awk -f bm-to-utf16be.awk mpman-ru.out.utf8 > mpman-ru.out + $(pdflatex) mpman-ru + +clean distclean: + rm -f *.aux *.blg *.dvi *.log *.mpx *.mps *.[0-9] *.[0-9][0-9] *.[0-9][0-9][0-9] + rm -f *.idx *.ilg *.ind *.toc *.utf8 *.raw *.src *.out diff --git a/info/metapost/doc/russian/mpman-ru/README b/info/metapost/doc/russian/mpman-ru/README new file mode 100644 index 0000000000..81bb4ca689 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/README @@ -0,0 +1,38 @@ +This is the translation of MetaPost version 1.004 user's manual to +Russian language. + +It may be distributed and/or modified under the the same conditions +as the original MetaPost manual. These conditions are specified at +the end of `mpman-ru.tex' file. + +You have to use MetaPost version 1.000 or newer to compile pictures. + +If you want to use LH (CM-Super) fonts (this increases size of pdf +upto 30%) then you should set `fontenc' option to `T2A' instead of +'LCYW'. The default fonts are virtual Type 1 CM Cyrillic fonts from +the standard `tetex' (and others) distributions. + +You may take LCYW package at CTAN or http://litwr.narod.ru/tex.html + +Absence of the `cmap-cyr-vf' package produces lack of Unicode mapping +for Russian labels in the MetaPost pictures. + +Index and bookmarks are produced by scripts for `awk' program. Index +is sorted by `sort' program which is depend on the locale settings. + +The directory contains: + bm-to-utf16be.awk + ctabbing.sty + extract-bm.awk + idx1.awk + idx2.awk + idx3.awk + Makefile + manfig-ru.mp + mpman.ist + mpman-optab-ru.tex + mpman-ru.bbl + mpman-ru.pdf + mpman-ru.tex + README + README.ru.koi8-r diff --git a/info/metapost/doc/russian/mpman-ru/README.ru.koi8-r b/info/metapost/doc/russian/mpman-ru/README.ru.koi8-r new file mode 100644 index 0000000000..cad94c9ff8 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/README.ru.koi8-r @@ -0,0 +1,22 @@ +üÔÏ ÐÅÒÅ×ÏÄ ÒÕËÏ×ÏÄÓÔ×Á ÐÏÌØÚÏ×ÁÔÅÌÑ ÄÌÑ MetaPost ×ÅÒÓÉÉ 1.004. + +åÇÏ ÍÏÖÎÏ ÒÁÓÐÒÏÓÔÒÁÎÑÔØ/ÉÚÍÅÎÑÔØ ÎÁ ÔÅÈ ÖÅ ÓÁÍÙÈ ÕÓÌÏ×ÉÑÈ, ÞÔÏ É +ÉÓÈÏÄÎÏÅ ÒÕËÏ×ÏÄÓÔ×Ï ÎÁ ÁÎÇÌÉÊÓËÏÍ. üÔÉ ÕÓÌÏ×ÉÑ ÐÒÉ×ÅÄÅÎÙ × ËÏÎÃÅ +ÆÁÊÌÁ `mpman-ru.tex'. + +÷Ù ÄÏÌÖÎÙ ÉÓÐÏÌØÚÏ×ÁÔØ MetaPost ×ÅÒÓÉÉ 1.000 ÉÌÉ ÎÏ×ÅÅ ÄÌÑ ËÏÍÐÉÌÑÃÉÉ +ÒÉÓÕÎËÏ×. + +åÓÌÉ ×Ù ÈÏÔÉÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ ÛÒÉÆÔÙ LH (CM-Super), ÞÔÏ Õ×ÅÌÉÞÉÔ +ÒÁÚÍÅÒ pdf, ÔÏ ×Ù ÄÏÌÖÎÙ ÕÓÔÁÎÏ×ÉÔØ ÏÐÃÉÀ ÄÌÑ `fontenc' × `T2A' +×ÍÅÓÔÏ `LCYW'. ðÏ-ÕÍÏÌÞÁÎÉÀ ÉÓÐÏÌØÚÕÀÔÓÑ ×ÉÒÔÕÁÌØÎÙÅ ÛÒÉÆÔÙ +Type 1 ÉÚ ÓÔÁÎÄÁÒÔÎÏÇÏ ÄÉÓÔÒÉÂÕÔÉ×Á `tetex' (ÉÌÉ ÄÒÕÇÉÈ). + +ðÁËÅÔ LCYW ÍÏÖÎÏ ×ÚÑÔØ ÎÁ CTAN ÉÌÉ http://litwr.narod.ru/tex.html + +ïÔÓÕÔÓÔ×ÉÅ ÐÁËÅÔÁ `cmap-cyr-vf' ÓÄÅÌÁÅÔ ÎÅ×ÏÚÍÏÖÎÏÊ Ó×ÑÚØ ÍÅÔÏË +MetaPost ÎÁ ÒÕÓÓËÏÍ Ó Unicode × pdf. + +éÎÄÅËÓ É ÚÁËÌÁÄËÉ ÐÒÏÉÚ×ÏÄÑÔÓÑ ÓÃÅÎÁÒÉÑÍÉ ÄÌÑ ÐÒÏÇÒÁÍÍÙ `awk'. +éÎÄÅËÓ ÓÏÒÔÉÒÕÅÔÓÑ ÐÒÏÇÒÁÍÍÏÊ `sort', ËÏÔÏÒÁÑ ÚÁ×ÉÓÉÔ ÏÔ +ÌÏËÁÌØÎÙÈ ÕÓÔÁÎÏ×ÏË. diff --git a/info/metapost/doc/russian/mpman-ru/bm-to-utf16be.awk b/info/metapost/doc/russian/mpman-ru/bm-to-utf16be.awk new file mode 100644 index 0000000000..1b6fc26266 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/bm-to-utf16be.awk @@ -0,0 +1,29 @@ +function to_utf16be(s) { + s1="\\376\\377" + for (i = 1; i <= length(s); i++) { + k = x[substr(s, i, 1)] + if (k == 208) + s1=s1 sprintf("\\004\\%03o", x[substr(s, ++i, 1)] + 128) + else if (k == 209) + s1=s1 sprintf("\\004\\%03o", x[substr(s, ++i, 1)] - 64) + else + s1=s1 sprintf("\\000\\%03o", k) + } + return s1 +} + +BEGIN { + for (i = 0; i < 256; i++) { + x[sprintf("%c", i)] = i + } +} + +{ + p=index($0,"}{") + s1=substr($0,1,p+1) + s=substr($0,p+2) + p=index(s,"}") + s2=substr(s,p) + s=substr(s,1,p-1) + print s1 to_utf16be(s) s2 +} diff --git a/info/metapost/doc/russian/mpman-ru/ctabbing.sty b/info/metapost/doc/russian/mpman-ru/ctabbing.sty new file mode 100644 index 0000000000..b61ec6ed78 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/ctabbing.sty @@ -0,0 +1,18 @@ +% Public domain. +% +% The ctabbing environment is a centered tabbing environment suitable for +% displaying program fragments. The vertical spacing is exactly like that +% for normal text in a center environment. This is achieved by setting +% \@minipagetrue to fool \tabbing into thinking that it starts a minipage +% and should therefore avoid all vertical space at the top. (Note that any +% space at all would defeat the \vtop command in \ctabbing.) The +% \vskip-\lastskip and \prevdepth saving commands avoid extra space after +% \endtabbing + +\newdimen\ct@pd + +\def\ctabbing{\center\leavevmode\vtop\bgroup\@minipagetrue\begingroup\tabbing} + +\def\endctabbing{\endtabbing\endgroup\vskip-\lastskip + \global\ct@pd\prevdepth \egroup + \endcenter \global\prevdepth\ct@pd} diff --git a/info/metapost/doc/russian/mpman-ru/extract-bm.awk b/info/metapost/doc/russian/mpman-ru/extract-bm.awk new file mode 100644 index 0000000000..6518c72b9c --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/extract-bm.awk @@ -0,0 +1,23 @@ +{ + p=index($0,"{") +} + +/^[^%]section\{/ { + noss=0 + nos++ + sub("\\\\MF","Metafont",$0) + s=substr($0,p+1,index($0,"}")-p-1) + printf "\\BOOKMARK [1][-]{section." + if (nos < 16) + print nos "}{" s "}{}" + else + printf "%c%s\n", nos+49, "}{" s "}{}" +} + +/^[^%]subsection\{/ { + noss++ + gsub("\\\\texttt\{|\\\\-|\{\}","",$0) + gsub("\\\\","",$0) + s=substr($0,p,index($0,"}")-p) + print "\\BOOKMARK [2][-]{subsection." nos "." noss "}{" s "}{section." nos "}" +}
\ No newline at end of file diff --git a/info/metapost/doc/russian/mpman-ru/idx1.awk b/info/metapost/doc/russian/mpman-ru/idx1.awk new file mode 100644 index 0000000000..2cea7ac68f --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/idx1.awk @@ -0,0 +1,16 @@ +{ + p=1 +} +/\\indexspace|\\begin\{theindex|\\end\{theindex/ { + p=0 +} +/\\item|\\subitem/ { + p=0 + printf "\n%s", $0 +} +{ + if (p) printf "%s", $0 +} +END { + printf "\n" +} diff --git a/info/metapost/doc/russian/mpman-ru/idx2.awk b/info/metapost/doc/russian/mpman-ru/idx2.awk new file mode 100644 index 0000000000..5777470e97 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/idx2.awk @@ -0,0 +1,125 @@ +BEGIN { +koi8r["\\\\CYRA"]=161 +koi8r["\\\\CYRB"]=162 +koi8r["\\\\CYRV"]=163 +koi8r["\\\\CYRG"]=164 +koi8r["\\\\CYRD"]=165 +koi8r["\\\\CYRE"]=166 +koi8r["\\\\CYRYO"]=167 +koi8r["\\\\CYRZH"]=168 +koi8r["\\\\CYRZ"]=169 +koi8r["\\\\CYRI"]=170 +koi8r["\\\\CYRISHRT"]=171 +koi8r["\\\\CYRK"]=172 +koi8r["\\\\CYRL"]=173 +koi8r["\\\\CYRM"]=174 +koi8r["\\\\CYRN"]=175 +koi8r["\\\\CYRO"]=176 +koi8r["\\\\CYRP"]=177 +koi8r["\\\\CYRR"]=178 +koi8r["\\\\CYRS"]=179 +koi8r["\\\\CYRT"]=180 +koi8r["\\\\CYRU"]=181 +koi8r["\\\\CYRF"]=182 +koi8r["\\\\CYRH"]=183 +koi8r["\\\\CYRC"]=184 +koi8r["\\\\CYRCH"]=185 +koi8r["\\\\CYRSH"]=186 +koi8r["\\\\CYRSHCH"]=187 +koi8r["\\\\CYRHRDSN"]=188 +koi8r["\\\\CYRERY"]=189 +koi8r["\\\\CYRSFTSN"]=190 +koi8r["\\\\CYREREV"]=191 +koi8r["\\\\CYRYU"]=192 +koi8r["\\\\CYRYA"]=193 +koi8r["\\\\cyra"]=161 +koi8r["\\\\cyrb"]=162 +koi8r["\\\\cyrv"]=163 +koi8r["\\\\cyrg"]=164 +koi8r["\\\\cyrd"]=165 +koi8r["\\\\cyre"]=166 +koi8r["\\\\cyryo"]=167 +koi8r["\\\\cyrzh"]=168 +koi8r["\\\\cyrz"]=169 +koi8r["\\\\cyri"]=170 +koi8r["\\\\cyrishrt"]=171 +koi8r["\\\\cyrk"]=172 +koi8r["\\\\cyrl"]=173 +koi8r["\\\\cyrm"]=174 +koi8r["\\\\cyrn"]=175 +koi8r["\\\\cyro"]=176 +koi8r["\\\\cyrp"]=177 +koi8r["\\\\cyrr"]=178 +koi8r["\\\\cyrs"]=179 +koi8r["\\\\cyrt"]=180 +koi8r["\\\\cyru"]=181 +koi8r["\\\\cyrf"]=182 +koi8r["\\\\cyrh"]=183 +koi8r["\\\\cyrc"]=184 +koi8r["\\\\cyrch"]=185 +koi8r["\\\\cyrsh"]=186 +koi8r["\\\\cyrshch"]=187 +koi8r["\\\\cyrhrdsn"]=188 +koi8r["\\\\cyrery"]=189 +koi8r["\\\\cyrsftsn"]=190 +koi8r["\\\\cyrerev"]=191 +koi8r["\\\\cyryu"]=192 +koi8r["\\\\cyrya"]=193 +pascii["\\\\#"]=35 +pascii["\\."]=46 +pascii["\\+"]=43 +pascii["\\-"]=45 +pascii["\\*"]=42 +pascii["\\\\&"]=38 +pascii["\\["]=64 +pascii["\\]"]=64 +pascii[" "]=32 +pascii["@"]=63 +for (i = 58; i < 63; i++) { + pascii[sprintf("%c", i)] = i + } +for (i = 65; i < 91; i++) { + pascii[sprintf("%c", i)] = i + } +for (i = 97; i < 123; i++) { + pascii[sprintf("%c", i)] = i-32 + } +} +{ + t=$0 + gsub("{|}|^ *","",t) + s="" + p=match(t,"\\\\[A-Za-z]+") + while (p>0) { + p=p+RLENGTH + s=s substr(t,1,p-1) + while (substr(t,p,1)==" ") + p++ + t=substr(t,p) + p=match(t,"\\\\[A-Za-z]+") + } + s=s t + p=index(s,",") + if (p) s=substr(s,1,p-1) + xc = length(s)/3 + gsub("\\\\texttt|\\\\IeC|\\\\tt|\\\\tdescr|\\\\string|\\\\ttt","",s) + if (index(s,"\\item")==1) + mode=1 + if (index(s,"\\subitem")==1) + mode=2 + gsub("\\\\item|\\\\subitem","",s) + while (match(s,"^[^A-Za-zá-ñÁ-Ñ0-9\\\\].*[A-Za-zá-ñÁ-Ñ0-9]")) + s=substr(s,2) + for (i in koi8r) + gsub(i,sprintf("%03d",koi8r[i]),s) + for (i in pascii) + gsub(i,sprintf("%03d",pascii[i]),s) + gsub("\\\\","",s) + if (mode==1) + s = idx = s sprintf("%03d",xc) + else if (mode==2) + s = idx "000" s + while (length(s) < 90) + s = s "000" + print s " @@@ " $0 +} diff --git a/info/metapost/doc/russian/mpman-ru/idx3.awk b/info/metapost/doc/russian/mpman-ru/idx3.awk new file mode 100644 index 0000000000..5a911c2087 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/idx3.awk @@ -0,0 +1,16 @@ +BEGIN { + print "\\begin{theindex}" + l=65 +} +{ + if (0+substr($0,1,3)>=l && pl!=l && index($0,"\\subitem")==0) { + print "\\indexspace" + l=0+substr($0,1,3) + pl=l++ + if (l==91) l=161 + } + print substr($0,index($0,"@@@")+4) +} +END { + print "\\end{theindex}" +} diff --git a/info/metapost/doc/russian/mpman-ru/manfig-ru.mp b/info/metapost/doc/russian/mpman-ru/manfig-ru.mp new file mode 100644 index 0000000000..bdbe2e99d9 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/manfig-ru.mp @@ -0,0 +1,956 @@ +% $Id: manfig.mp,v 1.4 2005/03/27 17:29:22 karl Exp $ +% Figures for MetaPost manual, by John Hobby. Public domain. + +filenametemplate "%j-%c.mps"; + +%%% This redefinition of dotlabel draws dots as a closed path +%%% which are rendered more smoothly in Adobe Reader. +vardef dotlabel@#(expr s,z) text t_ = + label@#(s,z) t_; + addto currentpicture + contour (makepath pencircle scaled dotlabeldiam) shifted z t_; +enddef; + +%%% TeX macro \place is only used in figure 0. +verbatimtex +\input texnames.sty +\font\tenrm=kcmr10 +\def\place#1{\vphantom{FiMP}\smash{\tenrm #1}} +etex + +%%% The boxes package is only used in figure 0. +input boxes + +beginfig(0); +ba.dy = bb.dy = d.dy = 12bp; +d.dx = 100bp; +boxit.aa(btex \place{òÉÓÕÎËÉ ÎÁ MetaPost} etex); +boxit.ab(btex \place{äÏËÕÍÅÎÔ \TeX} etex); +boxit.ba(btex \hbox to 75bp {\hfil\place{MetaPost}\hfil} etex); +boxit.bb.(btex \hbox to 75bp {\hfil\place{\TeX\ ÉÌÉ \LaTeX}\hfil} etex); +boxit.ca(btex \place{òÉÓÕÎËÉ ÎÁ PostScript} etex); +boxit.cb(btex \place{{\tt dvi}-ÆÁÊÌ} etex); +boxit.d(btex \place{\tt dvips} etex); +boxit.e(btex PostScript etex); +boxit.f(btex \vbox{ + \hbox to 80bp {\hfil\hbox{\tenrm ïÈ×ÁÔÙ×ÁÀÝÁÑ}\hfil} + \hbox to 80bp {\hfil\hbox{\tenrm ÒÁÍËÁ}\hfil} + } etex scaled .74); +ba.n - aa.s = ca.n - ba.s += bb.n - ab.s = cb.n - bb.s += e.n - d.s = down * 25bp; +ypart cb.s - ypart d.n = 25bp; +e.s = origin; +ypart ca.s = ypart cb.s; +xpart aa.n = xpart 0.1[d.nw,d.ne]; +xpart ab.n = xpart 0.9[d.nw,d.ne]; +drawunboxed(aa,ab,ca,cb,e); +drawboxed(ba,bb,d); +drawarrow aa.s -- top ba.n; drawarrow ab.s -- top bb.n; +drawarrow ba.s -- top ca.n; drawarrow bb.s -- top cb.n; +drawarrow ca.s -- top 0.1[d.nw,d.ne]; +drawarrow cb.s -- top 0.9[d.nw,d.ne]; +drawarrow d.s -- top e.n; +path p; +p = ca.e{right} .. {right}bb.w; +f.c = point .5 of p; +drawunboxed(f); +draw p cutafter bpath f dashed evenly; +drawarrow p cutbefore subpath (1,3) of bpath f dashed evenly; +endfig; + + +beginfig(1); +draw (20,20)--(0,0)--(0,30)--(30,0)--(0,0); +endfig; + + +beginfig(2); numeric u; +u=1cm; +draw (2u,2u)--(0,0)--(0,3u)--(3u,0)--(0,0); +pickup pencircle scaled 4pt; +for i=0 upto 2: + for j=0 upto 2: + drawdot (i*u,j*u); + endfor +endfor +endfig; + + +beginfig(3); +z0 = (0,0); z1 = (60,40); +z2 = (40,90); z3 = (10,70); +z4 = (30,50); +draw z0..z1..z2..z3..z4; +dotlabels.top(0,2,4); +dotlabels.lft(3); +dotlabels.lrt(1); +endfig; + + +beginfig(104); +z0 = (0,0); z1 = (60,40); +z2 = (40,90); z3 = (10,70); +z4 = (30,50); +draw z0..z1..z2..z3..z4..cycle; +dotlabels.top(2,4); +dotlabels.lft(0,3); +dotlabels.lrt(1); +endfig; + + +beginfig(204); +z0 = (0,0); z1 = (60,40); +z2 = (40,90); z3 = (10,70); +z4 = (30,50); +draw z0..z1..z2..z3--z4--cycle; +dotlabels.top(2,4); +dotlabels.lft(0,3); +dotlabels.lrt(1); +endfig; + + +beginfig(5); +z0 = (0,0); z1 = (60,40); +z2 = (40,90); z3 = (10,70); +z4 = (30,50); +path p; p = z0..z1..z2..z3..z4; +draw p; +for t=0 upto 3: + draw point t of p--postcontrol t of p + --precontrol t+1 of p--point t+1 of p + dashed (evenly scaled .5); +endfor +dotlabels.top(0,2,4); +dotlabels.lft(3); +dotlabels.lrt(1); +endfig; + + +beginfig(6); +z0 = (0,0); z1 = (60,40); +z2 = (40,90); z3 = (10,70); +z4 = (30,50); +draw z0..z1{up}..z2{left}..z3..z4; +dotlabels.top(0,2,4); +dotlabels.lft(3); +dotlabels.lrt(1); +endfig; + + +beginfig(7) +for a=0 upto 9: + draw (0,0){dir 45}..{dir -10a}(6cm,0); +endfor +endfig; + +beginfig(8) +for a=0 upto 7: + draw (0,0){dir 45}..{dir 10a}(6cm,0); +endfor +endfig; + + +beginfig(109); +z2=-z0=(1in,0); z1=(0,.2in); +draw z0{up}..z1{right}..z2{down}; +dotlabels.bot(0,1,2); +endfig; + + +beginfig(209); +z2=-z0=(1in,0); z1=(0,.2in); +draw z0{up}...z1{right}...z2{down}; +dotlabels.bot(0,1,2); +endfig; + + +beginfig(110); +numeric u; 10u=1.5in; +-z0=z3=(5u,0); +(-x1,y1)=z2=(3u,2u); +draw z0..z1..z2..z3; +dotlabels.bot(0,1,2,3); +endfig; + + +beginfig(210); +numeric u; 10u=1.5in; +-z0=z3=(5u,0); +(-x1,y1)=z2=(3u,2u); +draw z0..z1..tension 1.3..z2..z3; +dotlabels.bot(0,1,2,3); +endfig; + + +beginfig(310); +numeric u; 10u=1.5in; +-z0=z3=(5u,0); +(-x1,y1)=z2=(3u,2u); +draw z0..z1..tension 1.5 and 1..z2..z3; +dotlabels.bot(0,1,2,3); +endfig; + + +beginfig(111); +numeric u, c; 10u=1.4in; c=0; +z1=(0,0); (x0,-y0)=z2=(2u,5u); +draw z0{curl c}..z1..{curl c}z2; +dotlabels.rt(0,1,2); +endfig; + + +beginfig(211); +numeric u, c; 10u=1.4in; c=1; +z1=(0,0); (x0,-y0)=z2=(2u,5u); +draw z0{curl c}..z1..{curl c}z2; +dotlabels.rt(0,1,2); +endfig; + + +beginfig(311); +numeric u, c; 10u=1.4in; c=2; +z1=(0,0); (x0,-y0)=z2=(2u,5u); +draw z0{curl c}..z1..{curl c}z2; +dotlabels.rt(0,1,2); +endfig; + + +beginfig(411); +numeric u, c; 10u=1.4in; c=infinity; +z1=(0,0); (x0,-y0)=z2=(2u,5u); +draw z0{curl c}..z1..{curl c}z2; +dotlabels.rt(0,1,2); +endfig; + + +beginfig(13); +z1=-z2=(.2in,0); +x3=-x6=.3in; +x3+y3=x6+y6=1.1in; +z4=1/3[z3,z6]; +z5=2/3[z3,z6]; +z20=whatever[z1,z3]=whatever[z2,z4]; +z30=whatever[z1,z4]=whatever[z2,z5]; +z40=whatever[z1,z5]=whatever[z2,z6]; +draw z1--z20--z2--z30--z1--z40--z2; +pickup pencircle scaled 1pt; +draw z1--z2; +draw z3--z6; +% +dotlabels.bot(1,2); +dotlabels.rt(3); +dotlabels.lft(6); +dotlabels.top(20,30,40); +endfig; + + +vardef llet(expr c) = + c infont defaultfont scaled magstep3 +enddef; + +primarydef p centered h = + (p shifted (h - xpart .5[llcorner p,lrcorner p], 0)) +enddef; + +beginfig(14); +string s; s = "abcde"; +numeric u,n, ytop, ybot; +n = 5; +ytop = 3bp + ypart urcorner llet(s); +ybot = -3bp + ypart llcorner llet(s); +ytop - ybot = u; +draw (n*u,ybot)--(0,ybot)--(0,ytop)--(n*u,ytop); +for i=1 upto n: + draw (i*u,ybot)..(i*u,ytop); + draw llet(substring (i-1,i) of s) centered ((i-.5)*u); + label.bot(decimal i, (i*u,ybot)); +endfor +picture llab; llab = btex \llap{$x={}$}0 etex; +z0 = urcorner llab; +draw llab shifted (-.5*x0, ybot-labeloffset-y0); +endfig; + + +beginfig(17); +a=.7in; b=.5in; +z0=(0,0); +z1=-z3=(a,0); +z2=-z4=(0,b); +draw z1..z2..z3..z4..cycle; +draw z1--z0--z2; +label.top("a", .5[z0,z1]); +label.lft("b", .5[z0,z2]); +dotlabel.bot("(0,0)", z0); +endfig; + + +beginfig(18); +numeric u; +u = 1cm; +draw (0,2u)--(0,0)--(4u,0); +pickup pencircle scaled 1pt; +draw (0,0){up} + for i=1 upto 8: ..(i/2,sqrt(i/2))*u endfor; +label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u); +label.bot(btex $x$ etex, (2u,0)); +label.lft(btex $y$ etex, (0,u)); +endfig; + + +beginfig(19); +numeric ux, uy; +120ux=1.2in; 4uy=2.4in; +draw (0,4uy)--(0,0)--(120ux,0); +pickup pencircle scaled 1pt; +draw (0,uy){right} + for ix=1 upto 8: + ..(15ix*ux, uy*2/(1+cosd 15ix)) + endfor; +label.bot(btex $x$ axis etex, (60ux,0)); +label.lft(btex $y$ axis etex rotated 90, + (0,2uy)); +label.lft( + btex $\displaystyle y={2\over1+\cos x}$ etex, + (120ux, 4uy)); +endfig; + + +beginfig(20); +picture p; +p = "testing" infont "ptmr8r" scaled 7; +draw p; +draw llcorner p--lrcorner p--urcorner p--ulcorner p--cycle; +dotlabel.lft(btex \tt llcorner etex, llcorner p); +dotlabel.rt(btex \tt lrcorner etex, lrcorner p); +dotlabel.lft(btex \tt ulcorner etex, ulcorner p); +dotlabel.rt(btex \tt urcorner etex, urcorner p); +endfig; + + +beginfig(21); +path p; +p = (-1cm,0)..(0,-1cm)..(1cm,0); +fill p{up}..(0,0){-1,-2}..{up}cycle; +draw p..(0,1cm)..cycle; +endfig; + + +beginfig(22); +path a, b, aa, ab; +a = fullcircle scaled 2cm; +b = a shifted (0,1cm); +aa = halfcircle scaled 2cm; +ab = buildcycle(aa, b); +picture pa, pb; +pa = thelabel(btex $A$ etex, (0,-.5cm)); +pb = thelabel(btex $B$ etex, (0,1.5cm)); +fill a withcolor .7white; +fill b withcolor .7white; +fill ab withcolor .4white; +unfill bbox pa; +draw pa; +unfill bbox pb; +draw pb; +label.lft(btex $U$ etex, (-1cm,.5cm)); +draw bbox currentpicture; +endfig; + + +beginfig(123); +path aa, b; +b = a shifted (0,1cm); +aa = halfcircle scaled 2cm; +draw aa; +draw b dashed evenly; +z1 = aa intersectionpoint reverse b; +z2 = reverse aa intersectionpoint b; +dotlabel.rt(btex 1 etex, z1); +dotlabel.lft(btex 2 etex, z2); +label.bot(btex \tt aa etex, point 0 of aa); +label.bot(btex \tt b etex, point 2 of b); +endfig; + +beginfig(223); +path aa, b; +b = a shifted (0,1cm); +aa = halfcircle scaled 2cm; +numeric t[], tt[]; +(t1,8-tt1) = aa intersectiontimes reverse b; +(4-t2,tt2) = reverse aa intersectiontimes b; +pickup(pencircle scaled .3); +draw aa; +draw b; +pickup(pencircle scaled .8); +draw subpath (t1,t2) of aa; +draw subpath (tt2,tt1) of b; +dotlabel.rt(btex 1 etex, point t1 of aa); +dotlabel.lft(btex 2 etex, point t2 of aa); +label.bot(btex \tt aa etex, point 0 of aa); +label.bot(btex \tt b etex, point 2 of b); +endfig; + + +beginfig(24); +h=2in; w=2.7in; +path p[], q[], pp; +for i=2 upto 4: ii:=i**2; + p[i] = (w/ii,h){1,-ii}...(w/i,h/i)...(w,h/ii){ii,-1}; +endfor +q0.5 = (0,0)--(w,0.5h); +q1.5 = (0,0)--(w/1.5,h); +pp = buildcycle(q0.5, p2, q1.5, p4); +fill pp withcolor .7white; +z0=center pp; +picture lab; lab=thelabel(btex $f>0$ etex, z0); +unfill bbox lab; draw lab; +draw q0.5; draw p2; draw q1.5; draw p4; +dotlabel.top(btex $P$ etex, p2 intersectionpoint q0.5); +dotlabel.rt(btex $Q$ etex, p2 intersectionpoint q1.5); +dotlabel.lft(btex $R$ etex, p4 intersectionpoint q1.5); +dotlabel.bot(btex $S$ etex, p4 intersectionpoint q0.5); +endfig; + + +beginfig(25); +numeric u; +u = .2in; +path a, b; +a = (0,0){up}..(4u,0)..(8u,0)..(8u,4u); +b = (10u,3u)..(5u,u)..(-u,u); +numeric t; t=0; +forsuffixes $=bot, llft, lrt, lft: + dotlabel$(decimal t, point t of a); + t:=t+1; +endfor +for i=0 upto 2: + dotlabel.top(decimal i, point i of b); +endfor +pickup(pencircle scaled .3); +draw a; +pickup(pencircle scaled .8); +draw b; +% intersections (atime, btime): +% (0.2501,1.77225) +% (2.58316,0.23619) +% (0.75288,1.40094) +endfig; + + +beginfig(26); +numeric scf, #, t[]; +3.2scf = 2.4in; +path fun; +# = .1; % Keep the function single-valued +fun = ((0,-1#)..(1,.5#){right}..(1.9,.2#){right}..{curl .1}(3.2,2#)) + yscaled(1/#) scaled scf; +x1 = 2.5scf; +for i=1 upto 2: + (t[i],whatever) = + fun intersectiontimes ((x[i],-infinity)--(x[i],infinity)); + z[i] = point t[i] of fun; + z[i]-(x[i+1],0) = whatever*direction t[i] of fun; + draw (x[i],0)--z[i]--(x[i+1],0); + fill fullcircle scaled 3bp shifted z[i]; +endfor +label.bot(btex $x_1$ etex, (x1,0)); +label.bot(btex $x_2$ etex, (x2,0)); +label.bot(btex $x_3$ etex, (x3,0)); +draw (0,0)--(3.2scf,0); +pickup pencircle scaled 1pt; +draw fun; +endfig; + + +beginfig(28); +path p[]; +p1 = fullcircle scaled .6in; +z1=(.75in,0)=-z3; +z2=directionpoint left of p1=-z4; +p2 = z1..z2..{curl1}z3..z4..{curl 1}cycle; +fill p2 withcolor .4[white,black]; +unfill p1; +draw p1; +transform T; +z1 transformed T = z2; +z3 transformed T = z4; +xxpart T=yypart T; yxpart T=-xypart T; +picture pic; +pic = currentpicture; +for i=1 upto 2: + pic:=pic transformed T; + draw pic; +endfor +dotlabels.top(1,2,3); dotlabels.bot(4); +endfig; + + +beginfig(29); +if unknown withdots: % So this works w/o MetaPost version 0.5 + picture withdots; withdots=dashpattern(off 2.5 on 0 off 2.5); +fi +z0 = (0,0); +z1 = (2in-2bp,0); +for i=1 upto 4: + z[2i]-z[2i-2] = z[2i+1]-z[2i-1] = (0,14pt); +endfor +draw z0..z1 dashed evenly; +label.rt(btex \tt dashed evenly etex, z1); +draw z2..z3 dashed evenly scaled 2; +label.rt(btex \tt dashed evenly scaled 2 etex, z3); +draw z4..z5 dashed evenly scaled 4; +label.rt(btex \tt dashed evenly scaled 4 etex, z5); +draw z6..z7 dashed withdots; +label.rt(btex \tt dashed withdots etex, z7); +draw z8..z9 dashed withdots scaled 2; +label.rt(btex \tt dashed withdots scaled 2 etex, z9); +endfig; + + +beginfig(30); +picture e[]; e4=evenly scaled 4; +z0 = (0,0); +z1 = (2in,0); +for i=1 upto 3: + z[2i]-z[2i-2] = z[2i+1]-z[2i-1] = (0,14pt); +endfor +dotlabels.lft(0,2,4,6); +draw z0..z1 dashed e4; +dotlabel.rt(btex 1 \tt\ draw z0..z1 dashed e4 etex, z1); +draw z2..z3 dashed e4 shifted (6bp,0); +dotlabel.rt(btex 3 \tt\ draw z2..z3 dashed e4 shifted (6bp,0) etex, z3); +draw z4..z5 dashed e4 shifted (12bp,0); +dotlabel.rt(btex 5 \tt\ draw z4..z5 dashed e4 shifted (12bp,0) etex, z5); +draw z6..z7 dashed e4 shifted (18bp,0); +dotlabel.rt(btex 7 \tt\ draw z6..z7 dashed e4 shifted (18bp,0) etex, z7); +endfig; + + +beginfig(31); +picture d; d = dashpattern(on 6bp off 12bp on 6bp); +draw d; +endfig; + + +beginfig(32); +draw dashpattern(on 15bp off 15bp) dashed evenly; +picture p; +p=currentpicture; +currentpicture:=nullpicture; +draw fullcircle scaled 1cm xscaled 3 dashed p; +endfig; + + +beginfig(33); +for i=0 upto 2: + z[i]=(0,-40i); z[i+3]-z[i]=(100,30); +endfor +pickup pencircle scaled 18; +draw z0..z3 withcolor .8white; +linecap:=butt; +draw z1..z4 withcolor .8white; +linecap:=squared; +draw z2..z5 withcolor .8white; +dotlabels.top(0,1,2,3,4,5); +endfig; linecap:=rounded; + + +beginfig(34); +for i=0 upto 2: + z[i]=(0,-50i); z[i+3]-z[i]=(60,40); + z[i+6]-z[i]=(120,0); +endfor +pickup pencircle scaled 24; +draw z0--z3--z6 withcolor .8white; +linejoin:=mitered; +draw z1..z4--z7 withcolor .8white; +linejoin:=beveled; +draw z2..z5--z8 withcolor .8white; +dotlabels.bot(0,1,2,3,4,5,6,7,8); +endfig; linejoin:=rounded; + + +beginfig(35); +z2a=(0,0); +(-x1a,y1a) = -z3a = .5in*unitvector(6,1); +z1b - z1a = .75*z1a rotated -90; +z2b - z1b = whatever*(z2a-z1a); +z3b - z2b = whatever*(z3a-z2a); +y2b = 0; +z3b - z3a = whatever*(z3a rotated 90); +z0b-z1b = z0a-z1a = z1a; +x4a=x2a; x4b=x2b; +y4a = y4b = 1.3*y3b; +fill z1a--z2a--z3a--z3b--z2b--z1b--cycle withcolor .8 white; +for p= z2a--z4a, z2b--z4b, z0a--z1a, z0b--z1b: + draw p dashed evenly; +endfor +drawdblarrow z4a--z4b; +drawdblarrow z0a--z0b; +label.bot(btex {\tenrm ÄÌÉÎÁ ÏÓÔÒÉÑ} etex, .5[z4a,z4b]); +label.ulft(btex {\tenrm ÔÏÌÝÉÎÁ ÌÉÎÉÉ} etex, .5[z0a,z0b]); +endfig; + + +beginfig(36); +z[-1]=(0,0); z0=(1in,0); +for i=1 upto 6: + z[i]-z[i-2] = (0,-15pt); + if x[i]=0: label.lft(decimal i, z[i]); + fi +endfor +drawarrow z1..z2; +drawarrow reverse(z3..z4); +drawdblarrow z5..z6; +label.rt(btex 2 \tt\ drawarrow z1..z2 etex, z2); +label.rt(btex 4 \tt\ drawarrow reverse(z3..z4) etex, z4); +label.rt(btex 6 \tt\ drawdblarrow z5..z6 etex, z6); +endfig; + + +beginfig(37); +path p, q, r; +ahlength := 1.5cm; +pickup pencircle scaled .2cm; +p = (0,0)..{right}(2.5cm,2cm); +q = counterclockwise arrowhead p; +z0 = directionpoint up of q; +z.a = directionpoint right of q; +z.b = directionpoint (-1,-1) of q; +drawarrow p withcolor .4white; +pickup defaultpen; +undraw p; +undraw q; +ahlength:=4bp; +z.a1-z0 = .3cm*unitvector(z.a-z0) rotated 90; +z.a1-z.a2 = z0-z.a; +z.b1-z0 = .3cm*unitvector(z.b-z0) rotated -90; +z.b1-z.b2 = z0-z.b; +z.ab = whatever[z.a1,z.a2] = whatever[z.b1,z.b2]; +z.a0-z.ab = .4cm*unitvector(z.a1-z.a2); +z.b0-z.ab = .4cm*unitvector(z.b1-z.b2); +drawdblarrow z.a1..z.a2; +label.lrt(btex \tt ahlength etex, .9[z.a1,z.a2]); +draw z.a1..z.a0 dashed evenly; +drawdblarrow z.b1..z.b2; +label.urt(btex \tt ahlength etex, .9[z.b1,z.b2]); +draw z.b1..z.b0 dashed evenly; +r = z.a0{(z.a2-z.a0) rotated 90}..{(z.b2-z.b0)rotated 90}z.b0; +draw r; +label.rt(btex \tt ahangle etex, point .5 of r); +endfig; + + +beginfig(38); +pickup pencircle scaled .2in yscaled .08 rotated 30; +x0=x3=x4; +z1-z0 = .45in*dir 30; +z2-z3 = whatever*(z1-z0); +z6-z5 = whatever*(z1-z0); +z1-z6 = 1.2*(z3-z0); +rt x3 = lft x2; +x5 = .55[x4,x6]; +y4 = y6; +lft x3 = bot y5 = 0; +top y2 = .9in; +draw z0--z1--z2--z3--z4--z5--z6 withcolor .7white; +dotlabels.top(0,1,2,3,4,5,6); +endfig; + + +beginfig(40); +path p[]; +p1 = (0,0){curl 0}..(5pt,-3pt)..{curl 0}(10pt,0); +p2 = p1..(p1 yscaled-1 shifted(10pt,0)); +p0 = p2; +for i=1 upto 3: p0:=p0.. p2 shifted (i*20pt,0); + endfor +for j=0 upto 8: draw p0 shifted (0,j*10pt); + endfor +p3 = fullcircle shifted (.5,.5) scaled 72pt; +clip currentpicture to p3; +draw p3; +endfig; + + +marksize=4pt; +angle_radius=8pt; + +def draw_mark(expr p, a) = + begingroup + save t, dm; pair dm; + t = arctime a of p; + dm = marksize*unitvector direction t of p + rotated 90; + draw (-.5dm.. .5dm) shifted point t of p; + endgroup +enddef; + +def draw_marked(expr p, n) = + begingroup + save amid; + amid = .5*arclength p; + for i=-(n-1)/2 upto (n-1)/2: + draw_mark(p, amid+.6marksize*i); + endfor + draw p; + endgroup +enddef; + +def mark_angle(expr a, b, c, n) = + begingroup + save s, p; path p; + p = unitvector(a-b){(a-b)rotated 90}..unitvector(c-b); + s = .9marksize/length(point 1 of p - point 0 of p); + if s<angle_radius: s:=angle_radius; fi + draw_marked(p scaled s shifted b, n); + endgroup +enddef; + +def mark_rt_angle(expr a, b, c) = + draw ((1,0)--(1,1)--(0,1)) + zscaled (angle_radius*unitvector(a-b)) shifted b +enddef; + +beginfig(42); +pair a,b,c,d; +b=(0,0); c=(1.5in,0); a=(0,.6in); +d-c = (a-b) rotated 25; +dotlabel.lft("a",a); +dotlabel.lft("b",b); +dotlabel.bot("c",c); +dotlabel.llft("d",d); +z0=.5[a,d]; +z1=.5[b,c]; +(z.p-z0) dotprod (d-a) = 0; +(z.p-z1) dotprod (c-b) = 0; +draw a--d; +draw b--c; +draw z0--z.p--z1; +draw_marked(a--b, 1); +draw_marked(c--d, 1); +draw_marked(a--z.p, 2); +draw_marked(d--z.p, 2); +draw_marked(b--z.p, 3); +draw_marked(c--z.p, 3); +mark_angle(z.p, b, a, 1); +mark_angle(z.p, c, d, 1); +mark_angle(z.p, c, b, 2); +mark_angle(c, b, z.p, 2); +mark_rt_angle(z.p, z0, a); +mark_rt_angle(z.p, z1, b); +endfig; + + +def getmid(suffix p) = + pair p.mid[], p.off[], p.dir[]; + for i=0 upto 36: + p.dir[i] = dir(5*i); + p.mid[i]+p.off[i] = directionpoint p.dir[i] of p; + p.mid[i]-p.off[i] = directionpoint -p.dir[i] of p; + endfor +enddef; + +def joinup(suffix pt, d)(expr n) = + begingroup + save res, g; path res; + res = pt[0]{d[0]}; + for i=1 upto n: + g:= if (pt[i]-pt[i-1]) dotprod d[i] <0: - fi 1; + res := res{g*d[i-1]}...{g*d[i]}pt[i]; + endfor + res + endgroup +enddef; + +beginfig(45) +path p, q; +p = ((5,2)...(3,4)...(1,3)...(-2,-3)...(0,-5)...(3,-4) + ...(5,-3)...cycle) scaled .3cm shifted (0,5cm); +getmid(p); +draw p; +draw joinup(p.mid, p.dir, 36)..cycle; +q = joinup(p.off, p.dir, 36); +draw q..(q rotated 180)..cycle; +drawoptions(dashed evenly); +for i=0 upto 3: + draw p.mid[9i]-p.off[9i]..p.mid[9i]+p.off[9i]; + draw -p.off[9i]..p.off[9i]; +endfor +endfig; + + +input boxes + + +\beginfig(48); +fill unitsquare xscaled 1.1in yscaled .7in withcolor .9white; +boxit(currentpicture); +dx = dy = .25in; +clearit; drawboxed(); +forsuffixes $=n,c: makelabel.top(str $, $); endfor +makelabel.bot("s",s); +forsuffixes $=ne,e,se: makelabel.rt(str $, $); endfor +forsuffixes $=nw,w,sw: makelabel.lft(str $, $); endfor +pickup pencircle scaled .3bp; +vardef larrow@#(expr a, da, s) = + drawdblarrow a..a+da; label@#(s,a+.5da); enddef; +larrow.rt(n, (0,-dy), "dy"); +larrow.rt(s, (0,dy), "dy"); +larrow.top(e, (-dx,0), "dx"); +larrow.top(w, (dx,0), "dx"); +endfig; + + +beginfig(49); +boxjoin(a.se=b.sw; a.ne=b.nw); +boxit.a(btex\strut$\cdots$ etex); boxit.ni(btex\strut$n_i$ etex); +boxit.di(btex\strut$d_i$ etex); boxit.ni1(btex\strut$n_{i+1}$ etex); +boxit.di1(btex\strut$d_{i+1}$ etex); boxit.aa(btex\strut$\cdots$ etex); +boxit.nk(btex\strut$n_k$ etex); boxit.dk(btex\strut$d_k$ etex); +drawboxed(di,a,ni,ni1,di1,aa,nk,dk); label.lft("ndtable:", a.w); +interim defaultdy:=7bp; +boxjoin(a.sw=b.nw; a.se=b.ne); +boxit.ba(); boxit.bb(); boxit.bc(); +boxit.bd(btex $\vdots$ etex); boxit.be(); boxit.bf(); +bd.dx=8bp; ba.ne=a.sw-(15bp,10bp); +drawboxed(ba,bb,bc,bd,be,bf); label.lft("hashtab:",ba.w); +vardef ndblock suffix $ = + boxjoin(a.sw=b.nw; a.se=b.ne); + forsuffixes $$=$1,$2,$3: boxit$$(); ($$dx,$$dy)=(5.5bp,4bp); + endfor; enddef; +ndblock nda; ndblock ndb; ndblock ndc; +nda1.c-bb.c = ndb1.c-nda3.c = (whatever,0); +xpart ndb3.se = xpart ndc1.ne = xpart di.c; +ndc1.c - be.c = (whatever,0); +drawboxed(nda1,nda2,nda3, ndb1,ndb2,ndb3, ndc1,ndc2,ndc3); +drawarrow bb.c -- nda1.w; +drawarrow be.c -- ndc1.w; +drawarrow nda3.c -- ndb1.w; +drawarrow nda1.c{right}..{curl0}ni.c cutafter bpath ni; +drawarrow nda2.c{right}..{curl0}di.c cutafter bpath di; +drawarrow ndc1.c{right}..{curl0}ni1.c cutafter bpath ni1; +drawarrow ndc2.c{right}..{curl0}di1.c cutafter bpath di1; +drawarrow ndb1.c{right}..nk.c cutafter bpath nk; +drawarrow ndb2.c{right}..dk.c cutafter bpath dk; +x.ptr=xpart aa.c; y.ptr=ypart ndc1.ne; +drawarrow subpath (0,.7) of (z.ptr..{left}ndc3.c) dashed evenly; +label.rt(btex \strut ndblock etex, z.ptr); endfig; + + +\beginfig(50) +interim circmargin := .07in; +fill unitsquare xscaled 1.1in yscaled .7in withcolor .9white; +circleit(currentpicture); +dx = dy; +clearit; drawboxed(); +forsuffixes $=n,c: makelabel.top(str $, $); endfor +makelabel.bot("s",s); +makelabel.rt("e", e); +makelabel.lft("w", w); +pickup pencircle scaled .3bp; +vardef larrow@#(expr a, da, s) = + drawdblarrow a..a+da; label@#(s,a+.5da); enddef; +larrow.rt(n, (0,-dy), "dy"); +larrow.rt(s, (0,dy), "dy"); +larrow.top(e, (-dx,0), "dx"); +larrow.top(w, (dx,0), "dx"); +endfig; + + + +vardef drawshadowed(text t) = + fixsize(t); + forsuffixes s=t: + fill bpath.s shifted (1pt,-1pt); + unfill bpath.s; + drawboxed(s); + endfor +enddef; + +beginfig(51) +circleit.a(btex Box 1 etex); +circleit.b(btex Box 2 etex); +b.n = a.s - (0,20pt); +drawshadowed(a,b); +drawarrow a.s -- b.n; +endfig; + + +vardef cuta(suffix a,b) expr p = + drawarrow p cutbefore bpath.a cutafter bpath.b; + point .5*length p of p +enddef; + +vardef self@# expr p = + cuta(@#,@#) @#.c{curl0}..@#.c+p..{curl0}@#.c enddef; + +beginfig(52); +verbatimtex \def\stk#1#2{$\displaystyle{\matrix{#1\cr#2\cr}}$} etex +circleit.aa(btex\strut Start etex); aa.dx=aa.dy; +circleit.bb(btex \stk B{(a|b)^*a} etex); +circleit.cc(btex \stk C{b^*} etex); +circleit.dd(btex \stk D{(a|b)^*ab} etex); +circleit.ee(btex\strut Stop etex); ee.dx=ee.dy; +numeric hsep; +bb.c-aa.c = dd.c-bb.c = ee.c-dd.c = (hsep,0); +cc.c-bb.c = (0,.8hsep); +xpart(ee.e - aa.w) = 3.8in; +drawboxed(aa,bb,cc,dd,ee); +label.ulft(btex$b$etex, cuta(aa,cc) aa.c{dir50}..cc.c); +label.top(btex$b$etex, self.cc(0,30pt)); +label.rt(btex$a$etex, cuta(cc,bb) cc.c..bb.c); +label.top(btex$a$etex, cuta(aa,bb) aa.c..bb.c); +label.llft(btex$a$etex, self.bb(-20pt,-35pt)); +label.top(btex$b$etex, cuta(bb,dd) bb.c..dd.c); +label.top(btex$b$etex, cuta(dd,ee) dd.c..ee.c); +label.lrt(btex$a$etex, cuta(dd,bb) dd.c..{dir140}bb.c); +label.bot(btex$a$etex, cuta(ee,bb) ee.c..tension1.3 ..{dir115}bb.c); +label.urt(btex$b$etex, cuta(ee,cc) ee.c{(cc.c-ee.c)rotated-15}..cc.c); +endfig; + + +beginfig(55) +picture wheel, car; +path body; + u := 5bp; + % Use a calligraphic pen. + pickup pencircle scaled .1u yscaled .6 rotated 30; + % Define a wheel object. + wheel := image( + draw fullcircle scaled 2u xscaled .8 rotated 30; + draw fullcircle scaled .1u xscaled .8 rotated 30 + withpen currentpen scaled .5; + ); + % Construct path for car body. + body := (3.2u,0){right}..(4.5u,1.5u){up}..(1.5u,2.5u){dir(-170)} + ..(1.5u,4.25u){up}...(0,5u){left}; + body := body .. reverse body reflectedabout (origin, (0,u)); + % Define a car object. + car := image( + draw wheel shifted (2u, 0);% Draw two wheels. + draw wheel shifted (-2u, 0); + draw (-.8u,0){dir(5)}..(.8u,0);% Draw connection betweeen wheels. + draw body;% Draw body. + % Draw speed indicators. + for i=1.5, 2, 2.5: + draw (5u, u*i){right}..{dir(-10)}(6.5u,u*i*.95); + endfor + ) shifted (0, u) slanted -.2 rotated 1;% Introduce asymmetries. + % Draw two cars and a faster one. + draw car shifted (5u,0); + draw car shifted (20u,0); + draw car slanted -.25 shifted (45u,0); + % Draw motorway. + draw (-5u,-u)...(25u,-.5u)...(60u,-u) + withpen currentpen scaled 4 withcolor .7white; +endfig; + +%%% Title page rule. +beginfig(60); + pickup pencircle scaled 1.1bp; + linecap := rounded; + draw origin--(4.38in,0); +endfig; + +end diff --git a/info/metapost/doc/russian/mpman-ru/mpman-optab-ru.tex b/info/metapost/doc/russian/mpman-ru/mpman-optab-ru.tex new file mode 100644 index 0000000000..05c94c7905 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/mpman-optab-ru.tex @@ -0,0 +1,276 @@ +%%% Two notes on column specification: +%%% (i) Column widths are manually chosen as small as possible to allow +%%% for a wider last X column. +%%% (ii) In the first column \linepenalty=100 prefers shorter paragraphs +%%% (less lines), where plain \raggedright were indifferent and +%%% sometimes caused a dangling line, e.g., for 'directionpoint of' +%%% or 'directiontime of'. +\begin{longtable}{|>{\raggedright\linepenalty=100\ttfamily}p{.793in}*{3}{|>{\raggedright}p{.715in}}|>{\raggedleft}p{1.5em}|>{\raggedright\arraybackslash}X|} +\caption{\strut ïÐÅÒÁÔÏÒÙ}\label{optab}\\ +%%\caption{\strut Operators}\label{optab}\\ +\hline +éÍÑ& \multicolumn3{c|}{áÒÇÕÍÅÎÔ/ÔÉÐÙ ÒÅÚÕÌØÔÁÔÁ}& \makebox[.2in][c]{óÔÒ.}& ïÂßÑÓÎÅÎÉÅ\\\cline{2-4} +%%Name& \multicolumn3{c|}{Argument/result types}& \makebox[.2in][c]{Page}& Explanation\\\cline{2-4} +& \multicolumn1{c|}{ìÅ×ÙÊ}& \multicolumn1{c|}{ðÒÁ×ÙÊ}& \multicolumn1{c|}{òÅÚÕÌØÔÁÔ}& & \\ +%%& \multicolumn1{c|}{Left}& \multicolumn1{c|}{Right}& \multicolumn1{c|}{Result}& & \\ +\hline +\hline +\endfirsthead +\caption[]{\strut ïÐÅÒÁÔÏÒÙ \emph{(ÐÒÏÄÏÌÖÅÎÉÅ)}}\\ +%%\caption[]{\strut Operators \emph{(continued)}}\\ +\hline +éÍÑ& \multicolumn3{c|}{áÒÇÕÍÅÎÔ/ÔÉÐÙ ÒÅÚÕÌØÔÁÔÁ}& \makebox[.2in][c]{óÔÒ.}& ïÂßÑÓÎÅÎÉÅ\\\cline{2-4} +%%Name& \multicolumn3{c|}{Argument/result types}& \makebox[.2in][c]{Page}& Explanation\\\cline{2-4} +& \multicolumn1{c|}{ìÅ×ÙÊ}& \multicolumn1{c|}{ðÒÁ×ÙÊ}& \multicolumn1{c|}{òÅÚÕÌØÔÁÔ}& & \\ +%%& \multicolumn1{c|}{Left}& \multicolumn1{c|}{Right}& \multicolumn1{c|}{Result}& & \\ +\hline +\hline +\endhead +\&\index{&?\texttt{\&}}& string\par path& string\par path & string\par path& \pageref{Damp}& óËÌÅÊËÁ (ÄÌÑ ÐÕÔÅÊ $l\hbox{\tt\&}r$, ÅÓÌÉ $r$ ÎÁÞÉÎÁÅÔÓÑ ÔÏÞÎÏ ÔÁÍ, ÇÄÅ ËÏÎÞÁÅÔÓÑ $l$)\\\hline +%%\&\index{&?\texttt{\&}}& string\par path& string\par path & string\par path& \pageref{Damp}& Concatenation---works for paths $l\hbox{\tt\&}r$ if $r$ starts exactly where the $l$ ends\\\hline +*\index{*?\texttt{*}}& numeric& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& \pageref{Dmldiv}& õÍÎÏÖÅÎÉÅ\\\hline +%%*\index{*?\texttt{*}}& numeric& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& \pageref{Dmldiv}& Multiplication\\\hline +*\index{*?\texttt{*}}& (cmyk)color\par numeric\par pair& numeric& (cmyk)color\par numeric\par pair& \pageref{Dmldiv}& õÍÎÏÖÅÎÉÅ\\\hline +%%*\index{*?\texttt{*}}& (cmyk)color\par numeric\par pair& numeric& (cmyk)color\par numeric\par pair& \pageref{Dmldiv}& Multiplication\\\hline +**\index{**?\texttt{**}}& numeric& numeric& numeric& \pageref{Dpow}& ÷ÏÚ×ÅÄÅÎÉÅ × ÓÔÅÐÅÎØ\\\hline +%%**\index{**?\texttt{**}}& numeric& numeric& numeric& \pageref{Dpow}& Exponentiation\\\hline ++\index{+?\texttt{+}}& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& \pageref{Dadd}& óÌÏÖÅÎÉÅ\\\hline +%%+\index{+?\texttt{+}}& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& \pageref{Dadd}& Addition\\\hline +++\index{++?\texttt{++}}& numeric& numeric& numeric& \pageref{Dpyadd}& ðÉÆÁÇÏÒÏ×Ï ÓÌÏÖÅÎÉÅ $\sqrt{l^2+r^2}$\\\hline +%%++\index{++?\texttt{++}}& numeric& numeric& numeric& \pageref{Dpyadd}& Pythagorean addition $\sqrt{l^2+r^2}$\\\hline ++-+\index{+-+?\texttt{+-+}}& numeric& numeric& numeric& \pageref{Dpysub}& ðÉÆÁÇÏÒÏ×Ï ×ÙÞÉÔÁÎÉÅ $\sqrt{l^2-r^2}$\\\hline +%%+-+\index{+-+?\texttt{+-+}}& numeric& numeric& numeric& \pageref{Dpysub}& Pythagorean subtraction $\sqrt{l^2-r^2}$\\\hline +-\index{-?\texttt{-}}& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& \pageref{Dadd}& ÷ÙÞÉÔÁÎÉÅ\\\hline +%%-\index{-?\texttt{-}}& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& \pageref{Dadd}& Subtraction\\\hline +-\index{-?\texttt{-}}& --& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& \pageref{Dneg}& õÎÁÒÎÙÊ ÍÉÎÕÓ\\\hline +%%-\index{-?\texttt{-}}& --& (cmyk)color\par numeric\par pair& (cmyk)color\par numeric\par pair& \pageref{Dneg}& Negation\\\hline +/\index{/?\texttt{/}}& (cmyk)color\par numeric\par pair& numeric& (cmyk)color\par numeric\par pair& \pageref{Dmldiv}& äÅÌÅÎÉÅ\\\hline +%%/\index{/?\texttt{/}}& (cmyk)color\par numeric\par pair& numeric& (cmyk)color\par numeric\par pair& \pageref{Dmldiv}& Division\\\hline +<\index{<?\texttt{<}} =\index{=?\texttt{=}} >>\index{>?\texttt{>}}\par <=\index{<=?\texttt{<=}} >=\index{=>?\texttt{=>}}\par <>\index{<>?\texttt{<>}}& string\par numeric\par pair\par (cmyk)color\par transform& string\par numeric\par pair\par (cmyk)color\par transform& boolean& \pageref{Dcmpar}& ïÐÅÒÁÃÉÉ ÓÒÁ×ÎÅÎÉÑ\\\hline +%%<\index{<?\texttt{<}} =\index{=?\texttt{=}} >>\index{>?\texttt{>}}\par <=\index{<=?\texttt{<=}} >=\index{=>?\texttt{=>}}\par <>\index{<>?\texttt{<>}}& string\par numeric\par pair\par (cmyk)color\par transform& string\par numeric\par pair\par (cmyk)color\par transform& boolean& \pageref{Dcmpar}& Comparison operators\\\hline +\pl abs\index{abs?\texttt{abs}}& --& numeric\par pair& numeric& \pageref{Dabs}& íÏÄÕÌØ\par å×ËÌÉÄÏ×Á ÄÌÉÎÁ $\sqrt{(\mbox{\ttfamily xpart\ } r)^2+(\mbox{\ttfamily ypart\ } r)^2}$\\\hline +%%\pl abs\index{abs?\texttt{abs}}& --& numeric\par pair& numeric& \pageref{Dabs}& Absolute value\par Euclidean length $\sqrt{(\mbox{\ttfamily xpart\ } r)^2+(\mbox{\ttfamily ypart\ } r)^2}$\\\hline +and\index{and?\texttt{and}}& boolean& boolean& boolean& \pageref{Dand}& ìÏÇÉÞÅÓËÏÅ é\\\hline +%%and\index{and?\texttt{and}}& boolean& boolean& boolean& \pageref{Dand}& Logical and\\\hline +angle\index{angle?\texttt{angle}}& --& pair& numeric& \pageref{Dangle}& 2$-$ÁÒÇÕÍÅÎÔÎÙÊ ÁÒËÔÁÎÇÅÎÓ (× ÇÒÁÄÕÓÁÈ)\\\hline +%%angle\index{angle?\texttt{angle}}& --& pair& numeric& \pageref{Dangle}& 2$-$argument arctangent (in degrees)\\\hline +arclength\index{arclength?\texttt{arclength}}& --& path& numeric& \pageref{Darclng}& äÌÉÎÁ ÄÕÇÉ ÐÕÔÉ\\\hline +%%arclength\index{arclength?\texttt{arclength}}& --& path& numeric& \pageref{Darclng}& Arc length of a path\\\hline +arctime of\index{arctime of?\texttt{arctime of}}& numeric& path& numeric& \pageref{Darctim}& ÷ÒÅÍÑ ÎÁ ÐÕÔÉ, ÇÄÅ ÄÌÉÎÁ ÄÕÇÉ ÏÔ ÎÁÞÁÌÁ ÄÏÓÔÉÇÁÅÔ ÚÁÄÁÎÎÏÊ ×ÅÌÉÞÉÎÙ\\\hline +%%arctime of\index{arctime of?\texttt{arctime of}}& numeric& path& numeric& \pageref{Darctim}& Time on a path where arc length from the start reaches a given value\\\hline +ASCII\index{ASCII?\texttt{ASCII}}& --& string& numeric& --& úÎÁÞÅÎÉÅ ASCII ÐÅÒ×ÏÇÏ ÓÉÍ×ÏÌÁ × ÓÔÒÏËÅ\\\hline +%%ASCII\index{ASCII?\texttt{ASCII}}& --& string& numeric& --& ASCII value of first character in string\\\hline +\pl bbox\index{bbox?\texttt{bbox}}& --& picture\par path\par pen& path& \pageref{Dbbox}& ðÒÑÍÏÕÇÏÌØÎÙÊ ÐÕÔØ ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÉ\\\hline +%%\pl bbox\index{bbox?\texttt{bbox}}& --& picture\par path\par pen& path& \pageref{Dbbox}& A rectangular path for the bounding box\\\hline +blackpart\index{blackpart?\texttt{blackpart}}& --& cmykcolor& numeric& \pageref{Dcmykprt}& ÷ÙÄÅÌÅÎÉÅ ÞÅÔ×ÅÒÔÏÊ ËÏÍÐÏÎÅÎÔÙ\\\hline +%%blackpart\index{blackpart?\texttt{blackpart}}& --& cmykcolor& numeric& \pageref{Dcmykprt}& Extract the fourth component\\\hline +bluepart\index{bluepart?\texttt{bluepart}}& --& color& numeric& \pageref{Drgbprt}& ÷ÙÄÅÌÅÎÉÅ ÔÒÅÔØÅÊ ËÏÍÐÏÎÅÎÔÙ\\\hline +%%bluepart\index{bluepart?\texttt{bluepart}}& --& color& numeric& \pageref{Drgbprt}& Extract the third component\\\hline +boolean\index{boolean?\texttt{boolean}}& --& ÌÀÂÏÊ& boolean& \pageref{Dboolop}& ÷ÙÒÁÖÅÎÉÅ ÌÏÇÉÞÅÓËÏÇÏ ÔÉÐÁ?\\\hline +%%boolean\index{boolean?\texttt{boolean}}& --& any& boolean& \pageref{Dboolop}& Is the expression of type boolean?\\\hline +\pl bot\index{bot?\texttt{bot}}& --& numeric\par pair& numeric\par pair& \pageref{Dbot}& îÉÚ ÔÅËÕÝÅÇÏ ÐÅÒÁ, ÃÅÎÔÒÉÒÏ×ÁÎÎÏÇÏ ÐÏ ÚÁÄÁÎÎÙÍ ËÏÏÒÄÉÎÁÔÁÍ\\\hline +%%\pl bot\index{bot?\texttt{bot}}& --& numeric\par pair& numeric\par pair& \pageref{Dbot}& Bottom of current pen when centered at the given coordinate(s)\\\hline +bounded\index{bounded?\texttt{bounded}}& --& ÌÀÂÏÊ& boolean& \pageref{Dbounded}& áÒÇÕÍÅÎÔ --- ÜÔÏ ËÁÒÔÉÎËÁ × ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÅ?\\\hline +%%bounded\index{bounded?\texttt{bounded}}& --& any& boolean& \pageref{Dbounded}& Is argument a picture with a bounding box?\\\hline +\pl ceiling\index{ceiling?\texttt{ceiling}}& --& numeric& numeric& \pageref{Dceil}& îÁÉÍÅÎØÛÅÅ ÃÅÌÏÅ, ÂÏÌØÛÅÅ ÉÌÉ ÒÁ×ÎÏÅ ÄÁÎÎÏÍÕ\\\hline +%%\pl ceiling\index{ceiling?\texttt{ceiling}}& --& numeric& numeric& \pageref{Dceil}& Least integer greater than or equal to\\\hline +\pl center\index{center?\texttt{center}}& --& picture\par path\par pen& pair& \pageref{Dcenter}& ãÅÎÔÒ ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÉ\\\hline +%%\pl center\index{center?\texttt{center}}& --& picture\par path\par pen& pair& \pageref{Dcenter}& Center of the bounding box\\\hline +char\index{char?\texttt{char}}& --& numeric& string& \pageref{Dchar}& óÉÍ×ÏÌ Ó ÚÁÄÁÎÎÙÍ ËÏÄÏÍ ASCII\\\hline +%%char\index{char?\texttt{char}}& --& numeric& string& \pageref{Dchar}& Character with a given ASCII code\\\hline +clipped\index{clipped?\texttt{clipped}}& --& ÌÀÂÏÊ& boolean& \pageref{Dclipped}& áÒÇÕÍÅÎÔ --- ×ÙÒÅÚËÁ ÉÚ ËÁÒÔÉÎËÉ?\\\hline +%%clipped\index{clipped?\texttt{clipped}}& --& any& boolean& \pageref{Dclipped}& Is argument a clipped picture?\\\hline +cmykcolor\index{cmykcolor?\texttt{cmykcolor}}& --& ÌÀÂÏÊ& boolean& \pageref{Dccolrop}& ÷ÙÒÁÖÅÎÉÅ ÔÉÐÁ cmyk-Ã×ÅÔ?\\\hline +%%cmykcolor\index{cmykcolor?\texttt{cmykcolor}}& --& any& boolean& \pageref{Dccolrop}& Is the expression of type cmykcolor?\\\hline +color\index{color?\texttt{color}}& --& ÌÀÂÏÊ& boolean& \pageref{Dcolrop}& ÷ÙÒÁÖÅÎÉÅ ÔÉÐÁ Ã×ÅÔ?\\\hline +%%color\index{color?\texttt{color}}& --& any& boolean& \pageref{Dcolrop}& Is the expression of type color?\\\hline +colormodel\index{colormodel?\texttt{colormodel}}& --& ÉÚÏÂÒÁÖÅÎÉÅ& numeric& \pageref{Dcolormodel}& ëÁËÁÑ ÍÏÄÅÌØ Ã×ÅÔÁ × ÏÂßÅËÔÅ-ÉÚÏÂÒÁÖÅÎÉÉ?\\\hline +%%colormodel\index{colormodel?\texttt{colormodel}}& --& image object& numeric& \pageref{Dcolormodel}& What is the color model of the image object?\\\hline +\pl colorpart\index{colorpart?\texttt{colorpart}}& --& ÉÚÏÂÒÁÖÅÎÉÅ& +(cmyk)color\par numeric\par boolean& \pageref{Dcolorpart}& ëÁËÏ× Ã×ÅÔ +ÏÂßÅËÔÁ-ÉÚÏÂÒÁÖÅÎÉÑ?\\\hline +%%\pl colorpart\index{colorpart?\texttt{colorpart}}& --& image object& +%%(cmyk)color\par numeric\par boolean& \pageref{Dcolorpart}& What is the +%%color of the image object?\\\hline +cosd\index{cosd?\texttt{cosd}}& --& numeric& numeric& \pageref{Dcosd}& ëÏÓÉÎÕÓ ÕÇÌÁ × ÇÒÁÄÕÓÁÈ\\\hline +%%cosd\index{cosd?\texttt{cosd}}& --& numeric& numeric& \pageref{Dcosd}& Cosine of angle in degrees\\\hline +\pl cutafter\index{cutafter?\texttt{cutafter}}& path& path& path& \pageref{Dcuta}& ìÅ×ÙÊ ÁÒÇÕÍÅÎÔ Ó ÞÁÓÔØÀ, ÏÔÂÒÁÓÙ×ÁÅÍÏÊ ÐÏÓÌÅ ÐÅÒÅÓÅÞÅÎÉÑ\\\hline +%%\pl cutafter\index{cutafter?\texttt{cutafter}}& path& path& path& \pageref{Dcuta}& Left argument with part after the intersection dropped\\\hline +\pl cutbefore\index{cutbefore?\texttt{cutbefore}}& path& path& path& \pageref{Dcutb}& ìÅ×ÙÊ ÁÒÇÕÍÅÎÔ Ó ÞÁÓÔØÀ, ÏÔÂÒÁÓÙ×ÁÅÍÏÊ ÄÏ ÐÅÒÅÓÅÞÅÎÉÑ\\\hline +%%\pl cutbefore\index{cutbefore?\texttt{cutbefore}}& path& path& path& \pageref{Dcutb}& Left argument with part before the intersection dropped\\\hline +cyanpart\index{cyanpart?\texttt{cyanpart}}& --& cmykcolor& numeric& \pageref{Dcmykprt}& éÚ×ÌÅÞØ ÐÅÒ×ÙÊ ÁÒÇÕÍÅÎÔ\\\hline +%%cyanpart\index{cyanpart?\texttt{cyanpart}}& --& cmykcolor& numeric& \pageref{Dcmykprt}& Extract the first component\\\hline +cycle\index{cycle?\texttt{cycle}}& --& path& boolean& \pageref{Dcycop}& ïÐÒÅÄÅÌÑÅÔ ÃÉËÌÉÞÅÎ ÌÉ ÐÕÔØ\\\hline +%%cycle\index{cycle?\texttt{cycle}}& --& path& boolean& \pageref{Dcycop}& Determines whether a path is cyclic\\\hline +dashpart\index{dashpart?\texttt{dashpart}}& --& picture& picture& \pageref{Ddashpart}& ïÂÒÁÚÅà ÐÕÎËÔÉÒÁ ÐÕÔÉ × ÒÉÓÕÅÍÏÊ ËÁÒÔÉÎËÅ\\\hline +%%dashpart\index{dashpart?\texttt{dashpart}}& --& picture& picture& \pageref{Ddashpart}& Dash pattern of a path in a stroked picture\\\hline +decimal\index{decimal?\texttt{decimal}}& --& numeric& string& \pageref{Ddecop}& äÅÓÑÔÉÞÎÏÅ ÐÒÅÄÓÔÁ×ÌÅÎÉÅ\\\hline +%%decimal\index{decimal?\texttt{decimal}}& --& numeric& string& \pageref{Ddecop}& The decimal representation\\\hline +\pl dir\index{dir?\texttt{dir}}& --& numeric& pair& \pageref{Ddirop}& $(\cos\theta,\sin\theta)$ ÐÏ ÚÁÄÁÎÎÏÍÕ $\theta$ × ÇÒÁÄÕÓÁÈ\\\hline +%%\pl dir\index{dir?\texttt{dir}}& --& numeric& pair& \pageref{Ddirop}& $(\cos\theta,\sin\theta)$ given $\theta$ in degrees\\\hline +\pl direction of\index{direction of?\texttt{direction of}}& numeric& path& pair& \pageref{Ddirof}& îÁÐÒÁ×ÌÅÎÉÅ ÐÕÔÉ × ÄÁÎÎÏÅ `×ÒÅÍÑ'\\\hline +%%\pl direction of\index{direction of?\texttt{direction of}}& numeric& path& pair& \pageref{Ddirof}& The direction of a path at a given `time'\\\hline +\pl direction\-point of\index{directionpoint of?\texttt{directionpoint of}}& pair& path& numeric& \pageref{Ddpntof}& ôÏÞËÁ, ÇÄÅ ÐÕÔØ ÉÍÅÅÔ ÚÁÄÁÎÎÏÅ ÎÁÐÒÁ×ÌÅÎÉÅ\\\hline +%%\pl direction\-point of\index{directionpoint of?\texttt{directionpoint of}}& pair& path& numeric& \pageref{Ddpntof}& Point where a path has a given direction\\\hline +direction\-time of\index{directiontime of?\texttt{directiontime of}}& pair& path& numeric& \pageref{Ddtimof}& `÷ÒÅÍÑ', ËÏÇÄÁ ÐÕÔØ ÉÍÅÅÔ ÚÁÄÁÎÎÏÅ ÎÁÐÒÁ×ÌÅÎÉÅ\\\hline +%%direction\-time of\index{directiontime of?\texttt{directiontime of}}& pair& path& numeric& \pageref{Ddtimof}& `Time' when a path has a given direction\\\hline +\pl div\index{div?\texttt{div}}& numeric& numeric& numeric& --& ãÅÌÏÞÉÓÌÅÎÎÏÅ ÄÅÌÅÎÉÅ $\lfloor l/r\rfloor$\\\hline +%%\pl div\index{div?\texttt{div}}& numeric& numeric& numeric& --& Integer division $\lfloor l/r\rfloor$\\\hline +\pl dotprod\index{dotprod?\texttt{dotprod}}& pair& pair& numeric& \pageref{Ddprod}& ÓËÁÌÑÒÎÏÅ ÐÒÏÉÚ×ÅÄÅÎÉÅ ×ÅËÔÏÒÏ×\\\hline +%%\pl dotprod\index{dotprod?\texttt{dotprod}}& pair& pair& numeric& \pageref{Ddprod}& vector dot product\\\hline +filled\index{filled?\texttt{filled}}& --& ÌÀÂÏÊ& boolean& \pageref{Dfilled}& áÒÇÕÍÅÎÔ --- ÜÔÏ ÚÁÐÏÌÎÅÎÎÏÅ ×ÙÄÅÌÅÎÉÅ?\\\hline +%%filled\index{filled?\texttt{filled}}& --& any& boolean& \pageref{Dfilled}& Is argument a filled outline?\\\hline +floor\index{floor?\texttt{floor}}& --& numeric& numeric& \pageref{Dfloor}& îÁÉÂÏÌØÛÅÅ ÃÅÌÏÅ, ÍÅÎØÛÅÅ ÉÌÉ ÒÁ×ÎÏÅ ÄÁÎÎÏÍÕ\\\hline +%%floor\index{floor?\texttt{floor}}& --& numeric& numeric& \pageref{Dfloor}& Greatest integer less than or equal to\\\hline +fontpart\index{fontpart?\texttt{fontpart}}& --& picture& string& \pageref{Dfontpart}& ûÒÉÆÔ ÔÅËÓÔÏ×ÏÊ ËÏÍÐÏÎÅÎÔÙ ËÁÒÔÉÎËÉ\\\hline +%%fontpart\index{fontpart?\texttt{fontpart}}& --& picture& string& \pageref{Dfontpart}& Font of a textual picture component\\\hline +fontsize\index{fontsize?\texttt{fontsize}}& --& string& numeric& \pageref{Dfntsiz}& òÁÚÍÅÒ ÛÒÉÆÔÁ × ÐÕÎËÔÁÈ\\\hline +%%fontsize\index{fontsize?\texttt{fontsize}}& --& string& numeric& \pageref{Dfntsiz}& The point size of a font\\\hline +greenpart\index{greenpart?\texttt{greenpart}}& --& color& numeric& \pageref{Drgbprt}& ÷ÙÄÅÌÉÔØ ×ÔÏÒÏÊ ËÏÍÐÏÎÅÎÔ\\\hline +%%greenpart\index{greenpart?\texttt{greenpart}}& --& color& numeric& \pageref{Drgbprt}& Extract the second component\\\hline +greypart\index{greypart?\texttt{greypart}}& --& numeric& numeric& \pageref{Dgreyprt}& ÷ÙÄÅÌÉÔØ ÐÅÒ×ÙÊ (ÅÄÉÎÓÔ×ÅÎÎÙÊ) ËÏÍÐÏÎÅÎÔ\\\hline +%%greypart\index{greypart?\texttt{greypart}}& --& numeric& numeric& \pageref{Dgreyprt}& Extract the first (only) component\\\hline +hex\index{hex?\texttt{hex}}& --& string& numeric& --& éÎÔÅÒÐÒÅÔÉÒÏ×ÁÔØ ËÁË 16-ÒÉÞÎÏÅ ÞÉÓÌÏ\\\hline +%%hex\index{hex?\texttt{hex}}& --& string& numeric& --& Interpret as a hexadecimal number\\\hline +infont\index{infont?\texttt{infont}}& string& string& picture& \pageref{Sinfont}& ðÅÞÁÔØ ÓÔÒÏËÕ × ÚÁÄÁÎÎÏÍ ÛÒÉÆÔÅ\\\hline +%%infont\index{infont?\texttt{infont}}& string& string& picture& \pageref{Sinfont}& Typeset string in given font\\\hline +\pl intersec\-tionpoint\index{intersectionpoint?\texttt{intersectionpoint}}& path& path& pair& \pageref{Disecpt}& ôÏÞËÁ ÐÅÒÅÓÅÞÅÎÉÑ\\\hline +%%\pl intersec\-tionpoint\index{intersectionpoint?\texttt{intersectionpoint}}& path& path& pair& \pageref{Disecpt}& An intersection point\\\hline +intersec\-tiontimes\index{intersectiontimes?\texttt{intersectiontimes}}& path& path& pair& \pageref{Disectt}& ÷ÒÅÍÅÎÁ ($t_l,t_r)$ ÎÁ ÐÕÔÑÈ $l$ É $r$, ËÏÇÄÁ ÐÕÔÉ ÐÅÒÅÓÅËÁÀÔÓÑ\\\hline +%%intersec\-tiontimes\index{intersectiontimes?\texttt{intersectiontimes}}& path& path& pair& \pageref{Disectt}& Times ($t_l,t_r)$ on paths $l$ and $r$ when the paths intersect\\\hline +\pl inverse\index{inverse?\texttt{inverse}}& --& transform& transform& \pageref{Dinv}& ïÂÒÁÔÉÔØ ÔÒÁÎÓÆÏÒÍÁÃÉÀ\\\hline +%%\pl inverse\index{inverse?\texttt{inverse}}& --& transform& transform& \pageref{Dinv}& Invert a transformation\\\hline +known\index{known?\texttt{known}}& --& ÌÀÂÏÊ& boolean& \pageref{Dknown}& éÍÅÅÔ ÌÉ ÁÒÇÕÍÅÎÔ ÉÚ×ÅÓÔÎÏÅ ÚÎÁÞÅÎÉÅ?\\\hline +%%known\index{known?\texttt{known}}& --& any& boolean& \pageref{Dknown}& Does argument have a known value?\\\hline +length\index{length?\texttt{length}}& --& path\par string\par picture& numeric& \pageref{Dlength}\par \pageref{DlengthString}\par \pageref{DlengthPicture}& þÉÓÌÏ ËÏÍÐÏÎÅÎÔ (ÄÕÇ, ÓÉÍ×ÏÌÏ×, ÎÁÒÉÓÏ×ÁÎÎÙÈ ÏÂßÅËÔÏ×, \ldots) × ÁÒÇÕÍÅÎÔÅ\\\hline +%%length\index{length?\texttt{length}}& --& path\par string\par picture& numeric& \pageref{Dlength}\par \pageref{DlengthString}\par \pageref{DlengthPicture}& Number of components (arcs, characters, strokes, \ldots) in the argument\\\hline +\pl lft\index{lft?\texttt{lft}}& --& numeric\par pair& numeric\par pair& \pageref{Dlft}& ìÅ×ÙÊ ËÒÁÊ ÔÅËÕÝÅÇÏ ÐÅÒÁ Ó ÃÅÎÔÒÏÍ ÐÏ ÚÁÄÁÎÎÙÍ ËÏÏÒÄÉÎÁÔÁÍ\\\hline +%%\pl lft\index{lft?\texttt{lft}}& --& numeric\par pair& numeric\par pair& \pageref{Dlft}& Left side of current pen when its center is at the given coordinate(s)\\\hline +llcorner\index{llcorner?\texttt{llcorner}}& --& picture\par path\par pen& pair& \pageref{Dcornop}& îÉÖÎÉÊ ÌÅ×ÙÊ ÕÇÏÌ ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÉ\\\hline +%%llcorner\index{llcorner?\texttt{llcorner}}& --& picture\par path\par pen& pair& \pageref{Dcornop}& Lower-left corner of bounding box\\\hline +lrcorner\index{lrcorner?\texttt{lrcorner}}& --& picture\par path\par pen& pair& \pageref{Dcornop}& îÉÖÎÉÊ ÐÒÁ×ÙÊ ÕÇÏÌ ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÉ\\\hline +%%lrcorner\index{lrcorner?\texttt{lrcorner}}& --& picture\par path\par pen& pair& \pageref{Dcornop}& Lower-right corner of bounding box\\\hline +magentapart\index{magentapart?\texttt{magentapart}}& --& cmykcolor& numeric& \pageref{Dcmykprt}& éÚ×ÌÅÞØ ×ÔÏÒÏÊ ËÏÍÐÏÎÅÎÔ\\\hline +%%magentapart\index{magentapart?\texttt{magentapart}}& --& cmykcolor& numeric& \pageref{Dcmykprt}& Extract the second component\\\hline +makepath\index{makepath?\texttt{makepath}}& --& pen& path& \pageref{Dmkpath}& úÁÍËÎÕÔÙÊ ÐÕÔØ, ÏÈ×ÁÔÙ×ÁÀÝÉÊ ÆÏÒÍÕ ÐÅÒÁ\\\hline +%%makepath\index{makepath?\texttt{makepath}}& --& pen& path& \pageref{Dmkpath}& Cyclic path bounding the pen shape\\\hline +makepen\index{makepen?\texttt{makepen}}& --& path& pen& \pageref{Dmkpen}& íÎÏÇÏÕÇÏÌØÎÏÅ ÐÅÒÏ ÉÚ ×ÙÐÕËÌÏÊ ÞÁÓÔÉ ÕÚÌÏ× ÐÕÔÉ\\\hline +%%makepen\index{makepen?\texttt{makepen}}& --& path& pen& \pageref{Dmkpen}& A polygonal pen made from the convex hull of the path knots\\\hline +mexp\index{mexp?\texttt{mexp}}& --& numeric& numeric& --& æÕÎËÃÉÑ $\exp(x/256)$\\\hline +%%mexp\index{mexp?\texttt{mexp}}& --& numeric& numeric& --& The function $\exp(x/256)$\\\hline +mlog\index{mlog?\texttt{mlog}}& --& numeric& numeric& --& æÕÎËÃÉÑ $256\ln(x)$\\\hline +%%mlog\index{mlog?\texttt{mlog}}& --& numeric& numeric& --& The function $256\ln(x)$\\\hline +\pl mod\index{mod?\texttt{mod}}& --& numeric& numeric& --& æÕÎËÃÉÑ-ÏÓÔÁÔÏË $l-r\lfloor l/r\rfloor$\\\hline +%%\pl mod\index{mod?\texttt{mod}}& --& numeric& numeric& --& The remainder function $l-r\lfloor l/r\rfloor$\\\hline +normal\-deviate\index{normaldeviate?\texttt{normaldeviate}}& --& --& numeric& --& ÷ÙÂÏÒ ÓÌÕÞÁÊÎÏÇÏ ÞÉÓÌÁ ÓÏ ÓÒÅÄÎÉÍ~0 É ÓÔÁÎÄÁÒÔÎÙÍ ÏÔËÌÏÎÅÎÉÅÍ~1\\\hline +%%normal\-deviate\index{normaldeviate?\texttt{normaldeviate}}& --& --& numeric& --& Choose a random number with mean~0 and standard deviation~1\\\hline +not\index{not?\texttt{not}}& --& boolean& boolean& \pageref{Dnot}& ìÏÇÉÞÅÓËÏÅ îå\\\hline +%%not\index{not?\texttt{not}}& --& boolean& boolean& \pageref{Dnot}& Logical negation\\\hline +numeric\index{numeric?\texttt{numeric}}& --& ÌÀÂÏÊ& boolean& \pageref{Dnumop}& ÷ÙÒÁÖÅÎÉÅ ÞÉÓÌÏ×ÏÇÏ ÔÉÐÁ?\\\hline +%%numeric\index{numeric?\texttt{numeric}}& --& any& boolean& \pageref{Dnumop}& Is the expression of type numeric?\\\hline +oct\index{oct?\texttt{oct}}& --& string& numeric& --& éÎÔÅÒÐÒÅÔÉÒÏ×ÁÔØ ÓÔÒÏËÕ ËÁË 8-ÒÉÞÎÏÅ ÞÉÓÌÏ\\\hline +%%oct\index{oct?\texttt{oct}}& --& string& numeric& --& Interpret string as octal number\\\hline +odd\index{odd?\texttt{odd}}& --& numeric& boolean& --& âÌÉÖÁÊÛÅÅ ÃÅÌÏÅ ÎÅÞÅÔÎÏÅ?\\\hline +%%odd\index{odd?\texttt{odd}}& --& numeric& boolean& --& Is the closest integer odd or even?\\\hline +or\index{or?\texttt{or}}& boolean& boolean& boolean& \pageref{Dor}& ìÏÇÉÞÅÓËÏÅ éìé\\\hline +%%or\index{or?\texttt{or}}& boolean& boolean& boolean& \pageref{Dor}& Logical inclusive or\\\hline +pair\index{pair?\texttt{pair}}& --& ÌÀÂÏÊ& boolean& \pageref{Dpairop}& ÷ÙÒÁÖÅÎÉÅ ÔÉÐÁ ÐÁÒÁ?\\\hline +%%pair\index{pair?\texttt{pair}}& --& any& boolean& \pageref{Dpairop}& Is the expression of type pair?\\\hline +path\index{path?\texttt{path}}& --& ÌÀÂÏÊ& boolean& \pageref{Dpathop}& ÷ÙÒÁÖÅÎÉÅ ÔÉÐÁ ÐÕÔØ?\\\hline +%%path\index{path?\texttt{path}}& --& any& boolean& \pageref{Dpathop}& Is the expression of type path?\\\hline +pathpart\index{pathpart?\texttt{pathpart}}& --& picture& path& \pageref{Dpathpart}& ëÏÍÐÏÎÅÎÔ-ÐÕÔØ ÎÁÒÉÓÏ×ÁÎÎÏÊ ËÁÒÔÉÎËÉ\\\hline +%%pathpart\index{pathpart?\texttt{pathpart}}& --& picture& path& \pageref{Dpathpart}& Path of a stroked picture component\\\hline +pen\index{pen?\texttt{pen}}& --& ÌÀÂÏÊ& boolean& \pageref{Dpenop}& ÷ÙÒÁÖÅÎÉÅ ÔÉÐÁ ÐÅÒÏ?\\\hline +%%pen\index{pen?\texttt{pen}}& --& any& boolean& \pageref{Dpenop}& Is the expression of type pen?\\\hline +penoffset of\index{penoffset?\texttt{penoffset}}& pair& pen& pair& --& ëÒÁÊÎÑÑ ÔÏÞËÁ ÐÅÒÁ Ó ÚÁÄÁÎÎÙÍ ÎÁÐÒÁ×ÌÅÎÉÅÍ\\\hline +%%penoffset of\index{penoffset?\texttt{penoffset}}& pair& pen& pair& --& Point on the pen furthest to the right of the given direction\\\hline +penpart\index{penpart?\texttt{penpart}}& --& picture& pen& \pageref{Dpenpart}& ëÏÍÐÏÎÅÎÔÁ-ÐÅÒÏ ÎÁÒÉÓÏ×ÁÎÎÏÊ ËÁÒÔÉÎËÉ\\\hline +%%penpart\index{penpart?\texttt{penpart}}& --& picture& pen& \pageref{Dpenpart}& Pen of a stroked picture component\\\hline +picture\index{picture?\texttt{picture}}& --& ÌÀÂÏÊ& boolean& \pageref{Dpictop}& ÷ÙÒÁÖÅÎÉÅ ÔÉÐÁ ËÁÒÔÉÎËÁ?\\\hline +%%picture\index{picture?\texttt{picture}}& --& any& boolean& \pageref{Dpictop}& Is the expression of type picture?\\\hline +point of\index{point of?\texttt{point of}}& numeric& path& pair& \pageref{Dpntof}& ôÏÞËÁ ÎÁ ÐÕÔÉ Ó ÚÁÄÁÎÎÙÍ ÚÎÁÞÅÎÉÅÍ ×ÒÅÍÅÎÉ\\\hline +%%point of\index{point of?\texttt{point of}}& numeric& path& pair& \pageref{Dpntof}& Point on a path given a time value\\\hline +postcontrol of\index{postcontrol?\texttt{postcontrol}}& numeric& path& pair& --& ðÅÒ×ÁÑ ÕÐÒÁ×ÌÑÀÝÁÑ ÔÏÞËÁ âÅÚØÅ ÎÁ ÏÔÒÅÚËÅ ÐÕÔÉ, ÎÁÞÉÎÁÀÝÉÍÓÑ × ÄÁÎÎÏÅ ×ÒÅÍÑ\\\hline +%%postcontrol of\index{postcontrol?\texttt{postcontrol}}& numeric& path& pair& --& First B\'ezier control point on path segment starting at the given time\\\hline +precontrol of\index{precontrol?\texttt{precontrol}}& numeric& path& pair& --& ðÏÓÌÅÄÎÑÑ ÕÐÒÁ×ÌÑÀÝÁÑ ÔÏÞËÁ âÅÚØÅ ÎÁ ÏÔÒÅÚËÅ ÐÕÔÉ, ÚÁËÁÎÞÉ×ÁÀÝÉÍÓÑ × ÄÁÎÎÏÅ ×ÒÅÍÑ\\\hline +%%precontrol of\index{precontrol?\texttt{precontrol}}& numeric& path& pair& --& Last B\'ezier control point on path segment ending at the given time\\\hline +readfrom\index{readfrom?\texttt{readfrom}}& --& string& string& \pageref{Dreadfrom}& þÉÔÁÔØ ÓÔÒÏËÕ ÉÚ ÆÁÊÌÁ\\\hline +%%readfrom\index{readfrom?\texttt{readfrom}}& --& string& string& \pageref{Dreadfrom}& Read a line from file\\\hline +redpart\index{redpart?\texttt{redpart}}& --& color& numeric& \pageref{Drgbprt}& ÷ÙÄÅÌÉÔØ ÐÅÒ×ÙÊ ËÏÍÐÏÎÅÎÔ\\\hline +%%redpart\index{redpart?\texttt{redpart}}& --& color& numeric& \pageref{Drgbprt}& Extract the first component\\\hline +reverse\index{reverse?\texttt{reverse}}& --& path& path& \pageref{Drevrse}& ÐÕÔØ × ÏÂÒÁÔÎÏÍ `×ÒÅÍÅÎÉ', ËÏÎÅà ÍÅÎÑÅÔÓÑ Ó ÎÁÞÁÌÏÍ\\\hline +%%reverse\index{reverse?\texttt{reverse}}& --& path& path& \pageref{Drevrse}& `time'-reversed path, beginning swapped with ending\\\hline +rgbcolor\index{rgbcolor?\texttt{rgbcolor}}& --& ÌÀÂÏÊ& boolean& \pageref{Drcolrop}& ÷ÙÒÁÖÅÎÉÅ ÔÉÐÁ Ã×ÅÔ?\\\hline +%%rgbcolor\index{rgbcolor?\texttt{rgbcolor}}& --& any& boolean& \pageref{Drcolrop}& Is the expression of type color?\\\hline +rotated\index{rotated?\texttt{rotated}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& ÷ÒÁÝÅÎÉÅ (× ÇÒÁÄÕÓÁÈ) ÐÒÏÔÉ× ÞÁÓÏ×ÏÊ ÓÔÒÅÌËÉ\\\hline +%%rotated\index{rotated?\texttt{rotated}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& Rotate counterclockwise a given number of degrees\\\hline +\pl round\index{round?\texttt{round}}& --& numeric\par pair& numeric\par pair& \pageref{Dround}& ÏËÒÕÇÌÉÔØ ËÁÖÄÕÀ ËÏÍÐÏÎÅÎÔÕ ÄÏ ÂÌÉÖÁÊÛÅÇÏ ÃÅÌÏÇÏ\\\hline +%%\pl round\index{round?\texttt{round}}& --& numeric\par pair& numeric\par pair& \pageref{Dround}& round each component to the nearest integer\\\hline +\pl rt\index{rt?\texttt{rt}}& --& numeric\par pair& numeric\par pair& \pageref{Drt}& ðÒÁ×ÁÑ ÓÔÏÒÏÎÁ ÔÅËÕÝÅÇÏ ÐÅÒÁ, ÃÅÎÔÒÉÒÏ×ÁÎÎÏÇÏ ÐÏ ÄÁÎÎÙÍ ËÏÏÒÄÉÎÁÔÁÍ\\\hline +%%\pl rt\index{rt?\texttt{rt}}& --& numeric\par pair& numeric\par pair& \pageref{Drt}& Right side of current pen when centered at given coordinate(s)\\\hline +scaled\index{scaled?\texttt{scaled}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& íÁÓÛÔÁÂÉÒÕÊ ×ÓÅ ËÏÏÒÄÉÎÁÔÙ × ÚÁÄÁÎÎÏÅ ÞÉÓÌÏ ÒÁÚ\\\hline +%%scaled\index{scaled?\texttt{scaled}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& Scale all coordinates by the given amount\\\hline +scantokens\index{scantokens?\texttt{scantokens}}& --& string& token sequence& \pageref{Dscantokens}& ðÒÅÏÂÒÁÚÉ ÓÔÒÏËÕ × ÚÎÁË ÉÌÉ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÚÎÁËÏ×. ïÂÅÓÐÅÞÉ×ÁÅÔ ÐÒÅÏÂÒÁÚÏ×ÁÎÉÅ ÓÔÒÏËÉ × ÞÉÓÌÏ É Ô.~Ð.\\\hline +%%scantokens\index{scantokens?\texttt{scantokens}}& --& string& token sequence& \pageref{Dscantokens}& Converts a string to a token or token sequence. Provides string to numeric conversion, etc.\\\hline +shifted\index{shifted?\texttt{shifted}}& picture\par path\par pair\par pen\par transform& pair& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& äÏÂÁ×ÌÑÅÔ ÚÁÄÁÎÎÙÊ ÓÄ×ÉÇ Ë ËÁÖÄÏÊ ÐÁÒÅ ËÏÏÒÄÉÎÁÔ\\\hline +%%shifted\index{shifted?\texttt{shifted}}& picture\par path\par pair\par pen\par transform& pair& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& Add the given shift amount to each pair of coordinates\\\hline +sind\index{sind?\texttt{sind}}& --& numeric& numeric& \pageref{Dsind}& óÉÎÕÓ ÕÇÌÁ × ÇÒÁÄÕÓÁÈ\\\hline +%%sind\index{sind?\texttt{sind}}& --& numeric& numeric& \pageref{Dsind}& Sine of an angle in degrees\\\hline +slanted\index{slanted?\texttt{slanted}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& ðÒÉÍÅÎÅÎÉÅ ÔÒÁÎÓÆÏÒÍÁÃÉÉ-ÎÁËÌÏÎÁ, ÐÅÒÅ×ÏÄÑÝÅÊ $(x,y)$ × $(x+sy,y)$, ÇÄÅ~$s$ --- ÁÒÇÕÍÅÎÔ-ÞÉÓÌÏ\\\hline +%%slanted\index{slanted?\texttt{slanted}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& Apply the slanting transformation that maps $(x,y)$ into $(x+sy,y)$, where~$s$ is the numeric argument\\\hline +sqrt\index{sqrt?\texttt{sqrt}}& --& numeric& numeric& \pageref{Dsqrt}& ë×ÁÄÒÁÔÎÙÊ ËÏÒÅÎØ\\\hline +%%sqrt\index{sqrt?\texttt{sqrt}}& --& numeric& numeric& \pageref{Dsqrt}& Square root\\\hline +str\index{str?\texttt{str}}& --& suffix& string& \pageref{Dstr}& óÔÒÏËÏ×ÏÅ ÐÒÅÄÓÔÁ×ÌÅÎÉÅ ÓÕÆÆÉËÓÁ\\\hline +%%str\index{str?\texttt{str}}& --& suffix& string& \pageref{Dstr}& String representation for a suffix\\\hline +string\index{string?\texttt{string}}& --& ÌÀÂÏÊ& boolean& \pageref{Dstrgop}& ÷ÙÒÁÖÅÎÉÅ ÔÉÐÁ ÓÔÒÏËÁ?\\\hline +%%string& --& any& boolean& \pageref{Dstrgop}& Is the expression of type string?\\\hline +stroked\index{stroked?\texttt{stroked}}& --& ÌÀÂÏÊ& boolean& \pageref{Dstroked}& áÒÇÕÍÅÎÔ --- ÜÔÏ ÎÁÒÉÓÏ×ÁÎÎÁÑ ÌÉÎÉÑ?\\\hline +%%stroked\index{stroked?\texttt{stroked}}& --& any& boolean& \pageref{Dstroked}& Is argument a stroked line?\\\hline +subpath of\index{subpath?\texttt{subpath}}& pair& path& path& \pageref{Dsubpth}& þÁÓÔØ ÐÕÔÉ ÄÌÑ ÚÁÄÁÎÎÏÇÏ ÄÉÁÐÁÚÏÎÁ ×ÒÅÍÅÎÉ\\\hline +%%subpath of\index{subpath?\texttt{subpath}}& pair& path& path& \pageref{Dsubpth}& Portion of a path for given range of time values\\\hline +substring of\index{substring +of?\texttt{substring of}}& pair& string& string& \pageref{Dsubstr}& ðÏÄÓÔÒÏËÁ, ÏÇÒÁÎÉÞÅÎÎÁÑ ÉÎÄÅËÓÁÍÉ\\\hline +%%substring of\index{substring of?\texttt{substring of}}& pair& string& string& \pageref{Dsubstr}& Substring bounded by given indices\\\hline +textpart\index{textpart?\texttt{textpart}}& --& picture& string& \pageref{Dtextpart}& ôÅËÓÔ ÔÅËÓÔÏ×ÏÊ ËÏÍÐÏÎÅÎÔÙ ËÁÒÔÉÎËÉ\\\hline +%%textpart\index{textpart?\texttt{textpart}}& --& picture& string& \pageref{Dtextpart}& Text of a textual picture component\\\hline +textual\index{textual?\texttt{textual}}& --& ÌÀÂÏÊ& boolean& \pageref{Dtextual}& áÒÇÕÍÅÎÔ --- ÜÔÏ ÔÅËÓÔ?\\\hline +%%textual\index{textual?\texttt{textual}}& --& any& boolean& \pageref{Dtextual}& Is argument typeset text?\\\hline +\pl top\index{top?\texttt{top}}& --& numeric\par pair& numeric\par pair& \pageref{Dtop}& ÷ÅÒÈ ÔÅËÕÝÅÇÏ ÐÅÒÁ, ÃÅÎÔÒÉÒÏ×ÁÎÎÏÇÏ ÐÏ ÚÁÄÁÎÎÙÍ ËÏÏÒÄÉÎÁÔÁÍ\\\hline +%%\pl top\index{top?\texttt{top}}& --& numeric\par pair& numeric\par pair& \pageref{Dtop}& Top of current pen when centered at the given coordinate(s)\\\hline +transform\index{transform?\texttt{transform}}& --& ÌÀÂÏÊ& boolean& \pageref{Dtrnfop}& áÒÇÕÍÅÎÔ ÔÉÐÁ ÔÒÁÎÓÆÏÒÍÁÃÉÑ?\\\hline +%%transform\index{transform?\texttt{transform}}& --& any& boolean& \pageref{Dtrnfop}& Is the argument of type transform?\\\hline +transformed\index{transformed?\texttt{transformed}}& picture\par path\par pair\par pen\par transform& transform& picture\par path\par pair\par pen\par transform& \pageref{Dtrfrmd}& ðÒÉÍÅÎÉ ÄÁÎÎÕÀ ÔÒÁÎÓÆÏÒÍÁÃÉÀ ËÏ ×ÓÅÍ ËÏÏÒÄÉÎÁÔÁÍ\\\hline +%%transformed\index{transformed?\texttt{transformed}}& picture\par path\par pair\par pen\par transform& transform& picture\par path\par pair\par pen\par transform& \pageref{Dtrfrmd}& Apply the given transform to all coordinates\\\hline +ulcorner\index{ulcorner?\texttt{ulcorner}}& --& picture\par path\par pen& pair& \pageref{Dcornop}& ÷ÅÒÈÎÉÊ ÌÅ×ÙÊ ÕÇÏÌ ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÉ\\\hline +%%ulcorner\index{ulcorner?\texttt{ulcorner}}& --& picture\par path\par pen& pair& \pageref{Dcornop}& Upper-left corner of bounding box\\\hline +uniform\-deviate\index{uniformdeviate?\texttt{uniformdeviate}}& --& numeric& numeric& --& óÌÕÞÁÊÎÏÅ ÞÉÓÌÏ ÏÔ ÎÕÌÑ ÄÏ ÚÎÁÞÅÎÉÑ ÁÒÇÕÍÅÎÔÁ\\\hline +%%uniform\-deviate\index{uniformdeviate?\texttt{uniformdeviate}}& --& numeric& numeric& --& Random number between zero and the value of the argument\\\hline +\pl unitvector\index{unitvector?\texttt{unitvector}}& --& pair& pair& \pageref{Duvec}& íÁÓÛÔÁÂÉÒÕÊ ×ÅËÔÏÒ Ë ÄÌÉÎÅ~1\\\hline +%%\pl unitvector\index{unitvector?\texttt{unitvector}}& --& pair& pair& \pageref{Duvec}& Rescale a vector so its length is~1\\\hline +unknown\index{unknown?\texttt{unknown}}& --& ÌÀÂÏÊ& boolean& \pageref{Dunknwn}& úÎÁÞÅÎÉÅ ÎÅÉÚ×ÅÓÔÎÏ?\\\hline +%%unknown\index{unknown?\texttt{unknown}}& --& any& boolean& \pageref{Dunknwn}& Is the value unknown?\\\hline +urcorner\index{urcorner?\texttt{urcorner}}& --& picture\par path\par pen& pair& \pageref{Dcornop}& ÷ÅÒÈÎÉÊ ÐÒÁ×ÙÊ ÕÇÏÌ ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÉ\\\hline +%%urcorner\index{urcorner?\texttt{urcorner}}& --& picture\par path\par pen& pair& \pageref{Dcornop}& Upper-right corner of bounding box\\\hline +\pl whatever\index{whatever?\texttt{whatever}}& --& --& numeric& \pageref{Dwhatev}& óÏÚÄÁÊ ÎÏ×ÕÀ ÁÎÏÎÉÍÎÕÀ ÎÅÉÚ×ÅÓÔÎÕÀ\\\hline +%%\pl whatever\index{whatever?\texttt{whatever}}& --& --& numeric& \pageref{Dwhatev}& Create a new anonymous unknown\\\hline +xpart\index{xpart?\texttt{xpart}}& --& pair\par transform& number& \pageref{Dxprt}& $x$ ÉÌÉ $t_x$ ËÏÍÐÏÎÅÎÔÁ\\\hline +%%xpart\index{xpart?\texttt{xpart}}& --& pair\par transform& number& \pageref{Dxprt}& $x$ or $t_x$ component\\\hline +xscaled\index{xscaled?\texttt{xscaled}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& íÁÓÛÔÁÂÉÒÕÊ ×ÓÅ ËÏÏÒÄÉÎÁÔÙ $x$ × ÚÁÄÁÎÎÏÅ ÞÉÓÌÏ ÒÁÚ\\\hline +%%xscaled\index{xscaled?\texttt{xscaled}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& Scale all $x$ coordinates by the given amount\\\hline +xxpart\index{xxpart?\texttt{xxpart}}& --& transform& number& \pageref{Dtrprt}& $t_{xx}$ × ÍÁÔÒÉÃÅ ÔÒÁÎÓÆÏÒÍÁÃÉÉ\\\hline +%%xxpart\index{xxpart?\texttt{xxpart}}& --& transform& number& \pageref{Dtrprt}& $t_{xx}$ entry in transformation matrix\\\hline +xypart\index{xypart?\texttt{xypart}}& --& transform& number& \pageref{Dtrprt}& $t_{xy}$ × ÍÁÔÒÉÃÅ ÔÒÁÎÓÆÏÒÍÁÃÉÉ\\\hline +%%xypart\index{xypart?\texttt{xypart}}& --& transform& number& \pageref{Dtrprt}& $t_{xy}$ entry in transformation matrix\\\hline +yellowpart\index{yellowpart?\texttt{yellowpart}}& --& cmykcolor& numeric& \pageref{Dcmykprt}& ÷ÙÄÅÌÉÔØ ÔÒÅÔØÀ ËÏÍÐÏÎÅÎÔÕ\\\hline +%%yellowpart\index{yellowpart?\texttt{yellowpart}}& --& cmykcolor& numeric& \pageref{Dcmykprt}& Extract the third component\\\hline +ypart\index{ypart?\texttt{ypart}}& --& pair\par transform& number& \pageref{Dyprt}& ëÏÍÐÏÎÅÎÔÁ $y$ ÉÌÉ $t_y$\\\hline +%%ypart\index{ypart?\texttt{ypart}}& --& pair\par transform& number& \pageref{Dyprt}& $y$ or $t_y$ component\\\hline +yscaled\index{yscaled?\texttt{yscaled}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& íÁÓÛÔÁÂÉÒÕÊ ×ÓÅ ËÏÏÒÄÉÎÁÔÙ $y$ × ÚÁÄÁÎÎÏÅ ÞÉÓÌÏ ÒÁÚ\\\hline +%%yscaled\index{yscaled?\texttt{yscaled}}& picture\par path\par pair\par pen\par transform& numeric& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& Scale all $y$ coordinates by the given amount\\\hline +yxpart\index{yxpart?\texttt{yxpart}}& --& transform& number& \pageref{Dtrprt}& $t_{yx}$ × ÍÁÔÒÉÃÅ ÔÒÁÎÓÆÏÒÍÁÃÉÉ\\\hline +%%yxpart\index{yxpart?\texttt{yxpart}}& --& transform& number& \pageref{Dtrprt}& $t_{yx}$ entry in transformation matrix\\\hline +yypart\index{yypart?\texttt{yypart}}& --& transform& number& \pageref{Dtrprt}& $t_{yy}$ × ÍÁÔÒÉÃÅ ÔÒÁÎÓÆÏÒÍÁÃÉÉ\\\hline +%%yypart\index{yypart?\texttt{yypart}}& --& transform& number& \pageref{Dtrprt}& $t_{yy}$ entry in transformation matrix\\\hline +zscaled\index{zscaled?\texttt{zscaled}}& picture\par path\par pair\par pen\par transform& pair& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& ÷ÒÁÝÁÔØ É ÍÁÓÛÔÁÂÉÒÏ×ÁÔØ ×ÓÅ ËÏÏÒÄÉÎÁÔÙ ÔÁË, ÞÔÏ $(1,0)$ ÓÔÁÎÏ×ÉÔÓÑ ÚÁÄÁÎÎÏÊ ÐÁÒÏÊ, Ô.~Å. ÐÒÏÉÚ×ÅÓÔÉ ËÏÍÐÌÅËÓÎÏÅ ÕÍÎÏÖÅÎÉÅ.\\\hline +%%zscaled\index{zscaled?\texttt{zscaled}}& picture\par path\par pair\par pen\par transform& pair& picture\par path\par pair\par pen\par transform& \pageref{Dtranop}& Rotate and scale all coordinates so that $(1,0)$ is mapped into the given pair; i.e., do complex multiplication.\\\hline +\end{longtable} diff --git a/info/metapost/doc/russian/mpman-ru/mpman-ru.bbl b/info/metapost/doc/russian/mpman-ru/mpman-ru.bbl new file mode 100644 index 0000000000..ce473d73fc --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/mpman-ru.bbl @@ -0,0 +1,45 @@ +\begin{thebibliography}{1} + +\bibitem{ad:red2} +{Adobe Systems Inc.} +\newblock {\em {P}ost{S}cript Language Reference Manual}. +\newblock Addison Wesley, Reading, Massachusetts, second edition, 1990. + +\bibitem{ho:splin} +J.~D. Hobby. +\newblock Smooth, easy to compute interpolating splines. +\newblock {\em Discrete and Computational Geometry}, 1(2), 1986. + +\bibitem{ke:pic} +Brian~W. Kernighan. +\newblock Pic---a graphics language for typesetting. +\newblock In {\em Unix Research System Papers, Tenth Edition}, pages 53--77. + AT\&T Bell Laboratories, 1990. + +\bibitem{kn:c} +D.~E. Knuth. +\newblock {\em The {\MF}book}. +\newblock Addison Wesley, Reading, Massachusetts, 1986. +\newblock Volume C of {\it Computers and Typesetting}. +\newblock ä.~å.~ëÎÕÔ {\em ÷ÓÅ ÐÒÏ \MF}. --- ôä ``÷ÉÌØÑÍÓ'', 2003. + +\bibitem{kn:a} +D.~E. Knuth. +\newblock {\em The {\TeX}book}. +\newblock Addison Wesley, Reading, Massachusetts, 1986. +\newblock Volume A of {\it Computers and Typesetting}. +\newblock ä.~å.~ëÎÕÔ {\em ÷ÓÅ ÐÒÏ \TeX}. --- ðÒÏÔ×ÉÎÏ: áï RD\TeX, 1993. + +\bibitem{kn:e} +D.~E. Knuth. +\newblock {\em Computer Modern Typefaces}. +\newblock Addison Wesley, Reading, Massachusetts, 1986. +\newblock Volume E of {\it Computers and Typesetting}. + +\bibitem{kn:mf3} +D.~E. Knuth. +\newblock The new versions of {\TeX} and {\MF}. +\newblock {\em {TUG}boat, the\/ {\TeX} User's Group Newsletter}, + 10(3):325--328, November 1989. + +\end{thebibliography} diff --git a/info/metapost/doc/russian/mpman-ru/mpman-ru.pdf b/info/metapost/doc/russian/mpman-ru/mpman-ru.pdf Binary files differnew file mode 100644 index 0000000000..333b7f0b65 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/mpman-ru.pdf diff --git a/info/metapost/doc/russian/mpman-ru/mpman-ru.tex b/info/metapost/doc/russian/mpman-ru/mpman-ru.tex new file mode 100644 index 0000000000..2551a65a04 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/mpman-ru.tex @@ -0,0 +1,11308 @@ +% $Id: mpman.tex 513 2008-04-29 12:03:53Z stephanhennig $ +% MetaPost manual, by John Hobby. License at end. +% Russian translation, 2008/05/10 +\listfiles +\RequirePackage{ifpdf} +\ifpdf +\ifnum\pdftexversion<140 +\else +\pdfminorversion=5 +\pdfobjcompresslevel=1% Use compressed object streams. +\fi +\RequirePackage{cmap} +\documentclass{article} % article is NOT the original style +%%\usepackage[nofancy]{svninfo}% Access VCS information. +%%\svnInfo $Id: mpman.tex 513 2008-04-29 12:03:53Z stephanhennig $ +\newcommand*{\mpversion}{1.004} + +%%\usepackage[T1]{fontenc} +%%\usepackage{lmodern} +%%\usepackage{textcomp} +\usepackage{mflogo} +\usepackage{makeidx} +\usepackage{fancyvrb} +\usepackage{ctabbing} +\RecustomVerbatimEnvironment + {verbatim}{BVerbatim}{baseline=c} +\usepackage{graphicx} +\newcommand\qq{"} % quotation mark is active in Russian Babel! +\usepackage{amssymb} +\usepackage{cmap-cyr-vf} +\usepackage[LCYW]{fontenc} +\usepackage[koi8-r]{inputenc} +\usepackage[english,russian]{babel} +%%\usepackage[latin1]{inputenc} +\usepackage[textwidth=6in,textheight=8.65in]{geometry} +\usepackage{tocloft} + \setlength\cftbeforesecskip{1.3ex plus 0.3ex minus 0.3ex} +\usepackage{ltxtable} + + +\def\ttindex#1{{\tt #1}\index{#1?\texttt{#1}}} +\def\ttt{\texttt} % I get tired of typing this out + +\def\ConTeXt{Con\TeX t} + +\newcommand\descr[1]{{\langle\hbox{#1}\rangle}} +\newcommand\invisgap{\nobreak\hskip0pt\relax} +\newcommand\tdescr[1]{$\langle$\invisgap#1\invisgap$\rangle$} + +\newcommand\pl{\dag} +\newcommand\bx{$*$} + + +\newcommand\mathcenter[1]{\vcenter{\hbox{#1}}} + +\renewcommand{\topfraction}{.85} +\renewcommand{\bottomfraction}{.7} +\renewcommand{\textfraction}{.15} +\renewcommand{\floatpagefraction}{.5} +\renewcommand{\dbltopfraction}{.66} +\renewcommand{\dblfloatpagefraction}{.66} +\setcounter{topnumber}{9} +\setcounter{bottomnumber}{9} +\setcounter{totalnumber}{20} +\setcounter{dbltopnumber}{9} + +\makeindex + +\usepackage{multicol} +\usepackage[rgb,x11names]{xcolor}% Optimize for screen reading. +\usepackage{hyperxmp} +\usepackage{hyperref} +\hypersetup{ + pdftitle={A User's Manual for MetaPost (translated to Russian)}, +%% pdftitle={A User's Manual for MetaPost}, + pdfauthor={John D. Hobby and the MetaPost development team}, + pdfkeywords={MetaPost, PostScript, vector graphics language, MetaFont, TeX, Russian} +%% pdfkeywords={MetaPost, PostScript, vector graphics language, MetaFont, TeX} +} +\hypersetup{ + pdfstartview={XYZ null null null},% Zoom factor is determined by viewer. + colorlinks, + linkcolor=RoyalBlue3, + urlcolor=Chocolate4, + citecolor=SpringGreen3 +} +\usepackage[all]{hypcap} + +\begin{document} +\VerbatimFootnotes +%%% Title page layout documentation is missing. +\begin{titlepage} + \vbox to \textheight {% + \vskip0pt + \vfil + \vfil + \vfil + \centerline{\resizebox{3.5in}{!}{\fontseries{b}\selectfont\MP}} + \vskip10bp% actually 21bp (-11bp) + \centerline{\includegraphics{manfig-ru-60.mps}} + \vskip15bp% actually 21bp (-6bp) + \centerline{% + \resizebox{3.5in}{!}{% + \scshape% + \fontsize{28bp}{28bp}\selectfont + \strut\lowercase{òõëï÷ïäóô÷ï ðïìøúï÷áôåìñ}% +%% \strut\lowercase{A USER\kern-2bp\lower3bp\hbox{'}S MANUAL}% + }% + } + \vskip-11bp + \vfil + \vfil + \centerline{\large John D. Hobby} + \vskip3bp + \centerline{É ËÏÍÁÎÄÁ ÒÁÚÒÁÂÏÔËÉ MetaPost} +%% \centerline{and the MetaPost development team} + \vskip20.8bp% actually 31.8bp (-11bp) + \centerline{\large ×ÅÒÓÉÑ ÄÏËÕÍÅÎÔÁ: \mpversion} +%% \centerline{\large documented version: \mpversion} + \vskip3bp +%% \centerline{\svnToday} + \vfil + \vfil + \vfil + } +\end{titlepage} + +\section*{ðÒÉÍÅÞÁÎÉÑ ÐÅÒÅ×ÏÄÞÉËÁ} + +÷ ×ÅÒÓÉÉ 1.004 MetaPost +ÒÕËÏ×ÏÄÓÔ×Ï ÐÏÌØÚÏ×ÁÔÅÌÑ ÄÌÑ ÐÁËÅÔÁ \texttt{boxes} ÂÙÌÏ ×ÙÎÅÓÅÎÏ × ÏÔÄÅÌØÎÙÊ ÄÏËÕÍÅÎÔ. +÷ ÐÅÒÅ×ÏÄÅ ÜÔÏÇÏ ÒÁÚÄÅÌÅÎÉÑ ÎÅ ÐÒÏÉÚÏÛÌÏ, ÎÏ ÄÏÂÁ×ÌÅÎÉÑ Ë ÄÏËÕÍÅÎÔÁÃÉÉ ÂÙÌÉ ÕÞÔÅÎÙ. +óÏÚÄÁÎÉÑ ÜÔÏÇÏ ÐÅÒÅ×ÏÄÁ ÂÙÌÏ ÂÙ ÎÅ×ÏÚÍÏÖÎÙÍ ÂÅÚ ïÌØÇÉ çÁÇÁÒËÉÎÏÊ. + +\begin{flushright}÷ÌÁÄÉÍÉÒ ìÉÄÏ×ÓËÉÊ, \url{litwr@yandex.ru}\end{flushright} +\thispagestyle{empty} +\newpage + +\setlength{\columnsep}{2.5em} +\begin{multicols}{2} +\tableofcontents +\end{multicols} + +\section{÷×ÅÄÅÎÉÅ} +%%\section{Introduction} +\label{intro} + +MetaPost --- ÜÔÏ ÑÚÙË ÐÒÏÇÒÁÍÍÉÒÏ×ÁÎÉÑ, ÏÞÅÎØ ÐÏÈÏÖÉÊ ÎÁ \MF\footnote{\MF\ +--- ÜÔÏ ÔÏÒÇÏ×ÁÑ ÍÁÒËÁ ËÏÍÐÁÎÉÉ Addison Wesley +Publishing.}\index{metafont?\MF}~\cite{kn:c} ëÎÕÔÁ Ó ÔÅÍ ÉÓËÌÀÞÅÎÉÅÍ, ÞÔÏ +ÏÎ ÐÒÏÉÚ×ÏÄÉÔ PostScript-ÐÒÏÇÒÁÍÍÙ ×ÍÅÓÔÏ ÒÁÓÔÒÏ×ÙÈ ËÁÒÔÉÎÏË. +%%MetaPost is a programming language much like Knuth's \MF\footnote{\MF\ +%%is a trademark of Addison Wesley Publishing +%%company.}\index{metafont?\MF}~\cite{kn:c} except that it outputs +%%PostScript programs instead of bitmaps. +úÁÉÍÓÔ×Ï×ÁÎÉÑ ÉÚ \MF --- ÜÔÏ ÂÁÚÏ×ÙÅ ÓÒÅÄÓÔ×Á ÄÌÑ ÓÏÚÄÁÎÉÑ É +ÍÁÎÉÐÕÌÉÒÏ×ÁÎÉÑ ËÁÒÔÉÎËÁÍÉ. +%%Borrowed from \MF\ are the +%%basic tools for creating and manipulating pictures. +ïÎÉ ×ËÌÀÞÁÀÔ ÞÉÓÌÁ, ËÏÏÒÄÉÎÁÔÎÙÅ ÐÁÒÙ, ËÕÂÉÞÅÓËÉÅ ÓÐÌÁÊÎÙ, ÁÆÆÉÎÎÙÅ +ÔÒÁÎÓÆÏÒÍÁÃÉÉ, ÔÅËÓÔÏ×ÙÅ ÓÔÒÏËÉ É ÂÕÌÅ×Ù ×ÅÌÉÞÉÎÙ. +%%These include +%%numbers, coordinate pairs, cubic splines, affine transformations, text +%%strings, and boolean quantities. +äÏÐÏÌÎÉÔÅÌØÎÙÅ ÓÒÅÄÓÔ×Á ÄÅÌÁÀÔ ×ÏÚÍÏÖÎÙÍÉ ÓÏÅÄÉÎÅÎÉÅ ÔÅËÓÔÁ É ÇÒÁÆÉËÉ É +ÄÏÓÔÕÐ Ë ÓÐÅÃÉÁÌØÎÙÍ ×ÏÚÍÏÖÎÏÓÔÑÍ PostScript\footnote{PostScript --- +ÜÔÏ ÔÏÒÇÏ×ÁÑ ÍÁÒËÁ Adobe Systems.}\index{PostScript} ÔÁËÉÍ ËÁË +×ÙÒÅÚËÁ, ÚÁÔÅÎÅÎÉÅ, ÐÕÎËÔÉÒÎÙÅ ÌÉÎÉÉ. +%%Additional features facilitate +%%integrating text and graphics and accessing special features of +%%PostScript\footnote{PostScript is a trademark of Adobe Systems +%%Inc.}\index{PostScript} such as clipping, shading, and dashed lines. +äÒÕÇÏÅ Ó×ÏÊÓÔ×Ï, ÚÁÉÍÓÔ×Ï×ÁÎÎÏÅ Õ \MF, --- ÜÔÏ ÓÐÏÓÏÂÎÏÓÔØ ÒÅÛÁÔØ +ÚÁÄÁÎÎÙÅ ÎÅÑ×ÎÏ ÌÉÎÅÊÎÙÅ ÕÒÁ×ÎÅÎÉÑ, ÞÔÏ ÐÏÚ×ÏÌÑÅÔ ÐÉÓÁÔØ ÍÎÏÇÉÅ +ÐÒÏÇÒÁÍÍÙ × ÚÎÁÞÉÔÅÌØÎÏÊ ÍÅÒÅ × ÄÅËÌÁÒÁÔÉ×ÎÏÍ ÓÔÉÌÅ. +%%Another feature borrowed from \MF\ is the ability to solve linear +%%equations that are given implicitly, thus allowing many programs to be +%%written in a largely declarative style. +íÏÝØ É ÇÉÂËÏÓÔØ MetaPost ÄÏÓÔÉÇÁÀÔÓÑ ÐÏÓÔÒÏÅÎÉÅÍ ÓÌÏÖÎÙÈ ÏÐÅÒÁÃÉÊ +ÉÚ ÂÏÌÅÅ ÐÒÏÓÔÙÈ. +%%By building complex operations +%%from simpler ones, MetaPost achieves both power and flexibility. + +MetaPost ÏÓÏÂÅÎÎÏ ÈÏÒÏÛÏ ÐÒÉÓÐÏÓÏÂÌÅÎ ÄÌÑ ÇÅÎÅÒÁÃÉÉ ËÁÒÔÉÎÏË ÄÌÑ +ÔÅÈÎÉÞÅÓËÉÈ ÄÏËÕÍÅÎÔÏ×, ÇÄÅ ÎÅËÏÔÏÒÙÅ Ó×ÏÊÓÔ×Á ÒÉÓÕÎËÁ ÍÏÇÕÔ +ËÏÎÔÒÏÌÉÒÏ×ÁÔØÓÑ ÍÁÔÅÍÁÔÉÞÅÓËÉÍÉ ÉÌÉ ÇÅÏÍÅÔÒÉÞÅÓËÉÍÉ ÏÇÒÁÎÉÞÅÎÉÑÍÉ, +ËÏÔÏÒÙÅ ÎÁÉÌÕÞÛÉÍ ÏÂÒÁÚÏÍ ×ÙÒÁÖÁÀÔÓÑ × ÓÉÍ×ÏÌØÎÏÊ ÆÏÒÍÅ. +%%MetaPost is particularly well-suited to generating figures for technical +%%documents where some aspects of a picture may be controlled by +%%mathematical or geometrical constraints that are best expressed +%%symbolically. +äÒÕÇÉÍÉ ÓÌÏ×ÁÍÉ, MetaPost ÎÅ ÚÁÎÉÍÁÅÔ ÍÅÓÔÏ ÓÒÅÄÓÔ× ÄÌÑ ÒÕÞÎÏÇÏ +ÒÉÓÏ×ÁÎÉÑ ÉÌÉ ÄÁÖÅ ÉÎÔÅÒÁËÔÉ×ÎÙÈ ÇÒÁÆÉÞÅÓËÉÈ ÒÅÄÁËÔÏÒÏ×. +%%In other words, MetaPost is not meant to take the place +%%of a freehand drawing tool or even an interactive graphics editor. +üÔÏ ÎÁÓÔÏÑÝÉÊ ÑÚÙË ÐÒÏÇÒÁÍÍÉÒÏ×ÁÎÉÑ ÄÌÑ ÇÅÎÅÒÁÃÉÉ ÇÒÁÆÉËÉ É, ÏÓÏÂÅÎÎÏ, +ÉÌÌÀÓÔÒÁÃÉÊ ÄÌÑ ÄÏËÕÍÅÎÔÏ× \TeX\footnote{\TeX\ --- ÜÔÏ ÔÏÒÇÏ×ÁÑ ÍÁÒËÁ American +Mathematical Society.}\index{TeX?\TeX} É troff\index{troff}. +%%It +%%is really a programming language for generating graphics, especially +%%figures for \TeX\footnote{\TeX\ is a trademark of the American +%%Mathematical Society.}\index{TeX?\TeX} and troff\index{troff} documents. + +äÌÑ ÉÓÐÏÌØÚÏ×ÁÎÉÑ MetaPost ×Ù ÄÏÌÖÎÙ ÐÒÉÇÏÔÏ×ÉÔØ ×ÈÏÄÎÏÊ ÆÁÊÌ +Ó Metapost-ËÏÄÏÍ É ÚÁÔÅÍ ×ÙÚ×ÁÔØ ÓÁÍ MetaPost ÐÒÉ ÐÏÍÏÝÉ, ËÁË ÐÒÁ×ÉÌÏ, +ËÏÍÁÎÄÙ × ÆÏÒÍÅ \index{mpost?\texttt{mpost}} +$$ {\tt mpost}\, \descr{ÉÍÑ ÆÁÊÌÁ} $$ +%%To use MetaPost, you prepare an input file containing MetaPost code and +%%then invoke MetaPost, usually by giving a command of the +%%form\index{mpost?\texttt{mpost}} +%%$$ {\tt mpost}\, \descr{filename} $$ +óÉÎÔÁËÓÉÓ É ÉÍÑ ÐÒÏÇÒÁÍÍÙ Ñ×ÌÑÀÔÓÑ ÓÉÓÔÅÍÏ-ÚÁ×ÉÓÉÍÙÍÉ, ÉÎÏÇÄÁ ÏÎÁ +ÚÏ×ÅÔÓÑ \texttt{mp}. +%%The syntax and program name itself are system-dependent; sometimes it is +%%named \texttt{mp}. +÷ÈÏÄÎÙÅ ÆÁÊÌÙ ÄÌÑ MetaPost\index{ÆÁÊÌÙ!××ÏÄ} ÏÂÙÞÎÏ ÉÍÅÀÔ ÉÍÅÎÁ, +ÚÁËÁÎÞÉ×ÁÀÝÉÅÓÑ ÎÁ ``{\tt .mp}'', É ÜÔÁ ÞÁÓÔØ ÉÍÅÎÉ ÍÏÖÅÔ ÏÐÕÓËÁÔØÓÑ ÐÒÉ +×ÙÚÏ×Å MetaPost. +%%MetaPost input +%%files\index{files!input} normally have names ending ``{\tt .mp}'' but +%%this part of the name can be omitted when invoking MetaPost. +îÁÐÒÉÍÅÒ, ÄÌÑ ×ÈÏÄÎÏÇÏ ÆÁÊÌÁ {\tt foo.mp} +$$ \hbox{\tt mpost foo} $$ +×ÙÚÏ×ÅÔ MetaPost É ÐÒÏÉÚ×ÅÄÅÔ ×ÙÈÏÄÎÙÅ ÆÁÊÌÙ Ó ÉÍÅÎÁÍÉ ÔÉÐÁ {\tt foo.1} +É {\tt foo.2}. +%%For an +%%input file {\tt foo.mp} +%%$$ \hbox{\tt mpost foo} $$ +%%invokes MetaPost and produces output files with names like {\tt foo.1} +%%and {\tt foo.2}. +÷ÓÅ ÓÏÏÂÝÅÎÉÑ, ÐÏÑ×ÌÑÀÝÉÅÓÑ ÎÁ ÔÅÒÍÉÎÁÌÅ, ÓÏÂÉÒÁÀÔÓÑ × +ÆÁÊÌ-ÄÕÂÌÉËÁÔ\index{ÆÁÊÌÙ!ÄÕÂÌÉËÁÔ}\index{ÆÁÊÌ-ÄÕÂÌÉËÁÔ} Ó ÉÍÅÎÅÍ +{\tt foo.log}. +%%Any terminal I/O is summarized in a +%%transcript\index{files!transcript}\index{transcript file} file called +%%{\tt foo.log}. +ôÕÄÁ ×ËÌÀÞÁÀÔÓÑ ÓÏÏÂÝÅÎÉÑ Ï ÏÛÉÂËÁÈ É ×ÓÅ ËÏÍÁÎÄÙ MetaPost, ××ÅÄÅÎÎÙÅ +ÉÎÔÅÒÁËÔÉ×ÎÏ.\footnote{úÎÁË {\tt *}\index{*?\texttt{*}} ÉÓÐÏÌØÚÕÅÔÓÑ +ÄÌÑ ÐÒÉÇÌÁÛÅÎÉÑ Ë ÉÎÔÅÒÁËÔÉ×ÎÏÍÕ ××ÏÄÕ É ÚÎÁË {\tt **}\index{**?\texttt{**}} +ÐÏËÁÚÙ×ÁÅÔ, ÞÔÏ ÏÖÉÄÁÅÔÓÑ ÉÍÑ ×ÈÏÄÎÏÇÏ ÆÁÊÌÁ. äÉÁÌÏÇÁ ÍÏÖÎÏ ÉÚÂÅÖÁÔØ +×ÙÚÏ×ÏÍ MetaPost Ó ÆÁÊÌÏÍ, ËÏÔÏÒÙÊ ÚÁËÁÎÞÉ×ÁÅÔÓÑ ËÏÍÁÎÄÏÊ {\tt +end}\index{end?\texttt{end}}.} +%%This includes error messages and any MetaPost commands +%%entered interactively.\footnote{A {\tt *}\index{*?\texttt{*}} prompt is +%%used for interactive input and a {\tt **}\index{**?\texttt{**}} prompt +%%indicates that an input file name is expected. This can be avoided by +%%invoking MetaPost on a file that ends with an {\tt +%%end}\index{end?\texttt{end}} command.} + +\label{Dmpversion}æÁÊÌ-ÄÕÂÌÉËÁÔ ÎÁÞÉÎÁÅÔÓÑ Ó ÚÁÇÏÌÏ×ÏÞÎÏÊ ÓÔÒÏËÉ, +ÉÄÅÎÔÉÆÉÃÉÒÕÀÝÅÊ ÉÓÐÏÌØÚÕÅÍÕÀ ×ÁÍÉ ×ÅÒÓÉÀ MetaPost. +%%\label{Dmpversion}The transcript file starts with a banner line that +%%identifies the version of MetaPost you are using. +÷Ù ÍÏÖÅÔÅ ÔÁËÖÅ ÏÐÒÅÄÅÌÉÔØ ÔÅËÕÝÕÀ ×ÅÒÓÉÀ ÉÚ ÐÒÏÇÒÁÍÍÙ MetaPost ÞÅÒÅÚ +ÓÔÒÏËÏ×ÕÀ ËÏÎÓÔÁÎÔÕ \texttt{mpversion} (ÜÔÏ ÓÔÁÌÏ ×ÏÚÍÏÖÎÙÍ Ó ×ÅÒÓÉÉ 0.9). +%%You can also determine +%%the current version from within a MetaPost program via the +%%\texttt{mpversion} predefined constant string (this was introduced in +%%version 0.9). +îÁÐÒÉÍÅÒ, +%%For instance: +$$\begin{verbatim} +if known mpversion: + message "mp = " & mpversion; + if scantokens(mpversion) < 1: message "ðÏÄÄÅÒÖËÁ Ã×ÅÔÏ× CMYK ÎÅÄÏÓÔÕÐÎÁ!" fi +fi +\end{verbatim} +$$ +ÐÅÞÁÔÁÅÔ +%%prints +$$\begin{verbatim}[commandchars=\\\{\}] +mp = \mpversion +\end{verbatim} +$$ +ëÏÍÁÎÄÁ {\tt scantokens} ÏÐÉÓÁÎÁ ÎÁ Ó.~\pageref{Dscantokens} É +ÍÏÖÅÔ ÂÙÔØ ÕÐÏÔÒÅÂÌÅÎÁ ÄÌÑ ËÏÎ×ÅÒÔÉÒÏ×ÁÎÉÑ ÓÔÒÏË × ÞÉÓÌÁ. +\index{ëÏÍÍÅÎÔÁÒÉÊ Creator × ×Ù×ÏÄÅ PostScript}% +%%The {\tt scantokens} command is described on p.~\pageref{Dscantokens} +%%and can be utilized to convert strings to numbers. +%%\index{Creator comment in PostScript output}% +îÏÍÅÒ ×ÅÒÓÉÉ ÔÁËÖÅ ×ËÌÀÞÁÅÔÓÑ × ËÏÍÍÅÎÔÁÒÉÊ \texttt{Creator} × +Postscript-×Ù×ÏÄÅ. +%%The version number is also included in the \texttt{Creator} comment in +%%the PostScript output. + +üÔÏÔ ÄÏËÕÍÅÎÔ ÐÒÅÄÓÔÁ×ÌÑÅÔ ÑÚÙË MetaPost, ÎÁÞÉÎÁÑ Ó ÐÒÏÓÔÅÊÛÉÈ ÄÌÑ +ÉÓÐÏÌØÚÏ×ÁÎÉÑ É ÎÁÉÂÏÌÅÅ ×ÁÖÎÙÈ ÄÌÑ ÐÒÏÓÔÙÈ ÐÒÉÌÏÖÅÎÉÊ Ó×ÏÊÓÔ×. +%%This document introduces the MetaPost language, beginning with the +%%features that are easiest to use and most important for simple +%%applications. +þÔÅÎÉÅ ÒÕËÏ×ÏÄÓÔ×Á ÎÅ ÔÒÅÂÕÅÔ ÚÎÁÎÉÑ \MF\ ÉÌÉ ÄÏÓÔÕÐÁ Ë {\sl The \MF book}, +ÎÏ ÏÂÅ ×ÏÚÍÏÖÎÏÓÔÉ ÂÕÄÕÔ ÐÏÌÅÚÎÙÍÉ. +%%Reading the manual does not require knowledge of \MF\ or +%%access to {\sl The \MF book}, but both are beneficial. +ðÅÒ×ÙÅ ÎÅÓËÏÌØËÏ ÒÁÚÄÅÌÏ× ÏÐÉÓÙ×ÁÀÔ ÑÚÙË ÔÁËÉÍ, ËÁËÉÍ ÏÎ ËÁÖÅÔÓÑ +ÐÏÌØÚÏ×ÁÔÅÌÀ-ÎÏ×ÉÞËÕ Ó ËÌÀÞÅ×ÙÍÉ ÐÁÒÁÍÅÔÒÁÍÉ, ÚÁÆÉËÓÉÒÏ×ÁÎÎÙÍÉ ÎÁ +ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÈ ÚÎÁÞÅÎÉÑÈ. +%%The first few sections describe the language as it +%%appears to the novice user with key parameters at their default values. +îÅËÏÔÏÒÙÅ Ó×ÏÊÓÔ×Á, ÏÐÒÅÄÅÌÑÅÍÙÅ × ÜÔÉÈ ÒÁÚÄÅÌÁÈ, --- ÞÁÓÔØ ÍÁËÒÏÐÁËÅÔÁ +Ó ÉÍÅÎÅÍ Plain. +%%Some features described in these sections are part of a predefined macro +%%package called Plain. +óÌÅÄÕÀÝÉÅ ÒÁÚÄÅÌÙ ÏÈ×ÁÔÙ×ÁÀÔ ×ÅÓØ ÑÚÙË É ÏÔÌÉÞÁÀÔ ÐÒÉÍÉÔÉ×Ù ÏÔ ÍÁËÒÏÓÏ× +ÉÚ Á×ÔÏÍÁÔÉÞÅÓËÉ ÚÁÇÒÕÖÁÅÍÏÇÏ ÍÁËÒÏÐÁËÅÔÁ Plain\index{ÍÁËÒÏÓÙ Plain}. +%%Later sections summarize the complete language +%%and distinguish between primitives and preloaded macros from the Plain +%%macro package\index{Plain macros}. +÷ÓÌÅÄÓÔ×ÉÅ ÔÏÇÏ, ÞÔÏ ÂÏÌØÛÁÑ ÞÁÓÔØ ÑÚÙËÁ ÉÄÅÎÔÉÞÎÁ \MF\ ëÎÕÔÁ, ÐÒÉÌÏÖÅÎÉÅ +ÄÁÅÔ ÄÅÔÁÌØÎÏÅ ÓÒÁ×ÎÅÎÉÅ ÔÁËÉÍ ÏÂÒÁÚÏÍ, ÞÔÏ ÏÐÙÔÎÙÅ ÐÏÌØÚÏ×ÁÔÅÌÉ ÓÍÏÇÕÔ +ÕÚÎÁÔØ ÂÏÌØÛÅ Ï MetaPost, ÞÉÔÁÑ {\sl The \MF book\/} \cite{kn:c}. +%%Since much of the language is +%%identical to Knuth's \MF, the appendix gives a detailed comparison so +%%that advanced users can learn more about MetaPost by reading {\sl The +%%\MF book\/} \cite{kn:c}. + +äÏËÕÍÅÎÔÁÃÉÑ Ë MetaPost ÄÏÐÏÌÎÑÅÔÓÑ ``Drawing Boxes with MetaPost'' --- +ÒÕËÏ×ÏÄÓÔ×ÏÍ Ë ÐÁËÅÔÕ \texttt{graph}, ÉÚÎÁÞÁÌØÎÏ ÒÁÚÒÁÂÏÔÁÎÎÏÍÕ +äÖÏÎÏÍ~ä. èÏÂÂÉ. +%%MetaPost documentation is completed by ``Drawing Boxes with MetaPost'' +%%and ``Drawing Graphs with MetaPost''---the manuals of the \texttt{boxes} +%%and \texttt{graph} packages originally developed by John~D. Hobby. + +äÏÍÁÛÎÑÑ ÓÔÒÁÎÉÃÁ MetaPost --- \url{http://tug.org/metapost}. +%%The MetaPost home page is \url{http://tug.org/metapost}. +ïÎÁ ÓÏÄÅÒÖÉÔ ÓÓÙÌËÉ ÎÁ ÍÎÏÇÏ ÄÏÐÏÌÎÉÔÅÌØÎÏÊ ÉÎÆÏÒÍÁÃÉÉ, ×ËÌÀÞÁÑ ÍÎÏÖÅÓÔ×Ï +ÓÔÁÔÅÊ, ËÏÔÏÒÙÅ ÎÁÐÉÓÁÎÙ Ï MetaPost. +%%It has links +%%to much additional information, including many articles that have been +%%written about MetaPost. +ðÒÉ ÐÏÉÓËÅ ÐÏÄÓËÁÚËÉ ÐÏÐÒÏÂÕÊÔÅ ÒÁÓÓÙÌËÕ ÎÁ \url{metapost@tug.org}; ×Ù +ÍÏÖÅÔÅ ÐÏÄÐÉÓÁÔØÓÑ ÔÕÄÁ ÎÁ \url{http://tug.org/mailman/listinfo/metapost}. +%%For general help, try the +%%\url{metapost@tug.org} mailing list; you can subscribe to this list at +%%\url{http://tug.org/mailman/listinfo/metapost}. + +ôÅËÕÝÁÑ ÒÁÚÒÁÂÏÔËÁ ÒÁÚÍÅÝÅÎÁ ÎÁ \url{https://foundry.supelec.fr/projects/metapost/}; ÐÏÓÅÔÉÔÅ ÜÔÏÔ +ÓÁÊÔ ÄÌÑ ËÏÎÔÁËÔÏ× Ó ÞÌÅÎÁÍÉ ÔÅËÕÝÅÊ ËÏÍÁÎÄÙ ÒÁÚÒÁÂÏÔÞÉËÏ×, ÚÁÇÒÕÚËÉ +ÉÓÈÏÄÎÉËÏ× É ÍÎÏÇÏÇÏ ÄÒÕÇÏÇÏ. +%%The development is currently hosted at +%%\url{https://foundry.supelec.fr/projects/metapost/}; visit this site +%%for the current development team members, sources, and much else. + +ðÏÖÁÌÕÊÓÔÁ, ÓÏÏÂÝÁÊÔÅ Ï ÏÛÉÂËÁÈ É ÔÒÅÂÕÅÍÙÈ ÕÌÕÞÛÅÎÉÑÈ × ÓÐÉÓÏË ÎÁ +\url{metapost@tug.org} ÉÌÉ ÞÅÒÅÚ ÁÄÒÅÓÁ, ÐÒÉ×ÅÄÅÎÎÙÅ ×ÙÛÅ. +%%Please report bugs and request enhancements either on the +%%\url{metapost@tug.org} list, or through the address given above. +ðÏÖÁÌÕÊÓÔÁ, ÎÅ ÐÏÓÙÌÁÊÔÅ ÂÏÌØÛÅ ÏÔÞÅÔÙ ÎÁÐÒÑÍÕÀ Dr.\ Hobby. +%%(Please do not send reports directly to Dr.\ Hobby any more.) + +\section{âÁÚÏ×ÙÅ ËÏÍÁÎÄÙ ÄÌÑ ÒÉÓÏ×ÁÎÉÑ} +%%\section{Basic Drawing Statements} +\label{basic} + +ðÒÏÓÔÅÊÛÉÅ ËÏÍÁÎÄÙ ÒÉÓÏ×ÁÎÉÑ --- ÄÌÑ ÇÅÎÅÒÁÃÉÉ ÐÒÑÍÙÈ ÌÉÎÉÊ. +%The simplest drawing statements are the ones that generate straight lines. +ôÁËÉÍ ÏÂÒÁÚÏÍ\index{draw?\texttt{draw}}\index{-{}-?\texttt{-{}-}}, +%%Thus\index{draw?\texttt{draw}}\index{-{}-?\texttt{-{}-}} +$$ \hbox{\verb|draw (20,20)--(0,0)|} $$ +ÒÉÓÕÅÔ\index{draw?\texttt{draw}} ÄÉÁÇÏÎÁÌØÎÕÀ ÌÉÎÉÀ É +%%draws\index{draw?\texttt{draw}} a diagonal line and +$$ \hbox{\verb|draw (20,20)--(0,0)--(0,30)--(30,0)--(0,0)|} $$ +ÒÉÓÕÅÔ ÌÏÍÁÎÕÀ ÌÉÎÉÀ, ÐÏÄÏÂÎÕÀ ÜÔÏÊ: +%%draws a polygonal line like this: +$$ \includegraphics{manfig-ru-1} $$ + +\label{Ddrawdot}MetaPost ÔÁËÖÅ ÉÍÅÅÔ ËÏÍÁÎÄÕ \ttt{drawdot} ÄÌÑ ÐÅÞÁÔÉ +ÏÄÎÏÊ ÔÏÞËÉ, ÎÁÐÒÉÍÅÒ, \ttt{drawdot(30,0)}. +%%\label{Ddrawdot}MetaPost also has a \ttt{drawdot} command to print a +%%single point, as in \ttt{drawdot(30,0)}. + +þÔÏ ÏÚÎÁÞÁÅÔÓÑ ËÏÏÒÄÉÎÁÔÁÍÉ ÐÏÄÏÂÎÙÍÉ \verb|(30,0)|? +%%What is meant by coordinates like \verb|(30,0)|? +MetaPost ÉÓÐÏÌØÚÕÅÔ ÔÕ ÖÅ ÓÁÍÕÀ ÔÉÐÏ×ÕÀ ÓÉÓÔÅÍÕ ËÏÏÒÄÉÎÁÔ, ÞÔÏ É +PostScript\index{PostScript!ÓÉÓÔÅÍÁ ËÏÏÒÄÉÎÁÔ}. +%%MetaPost uses the same +%%default coordinate system that PostScript\index{PostScript!coordinate +%%system} does. +üÔÏ ÚÎÁÞÉÔ, ÞÔÏ \verb|(30,0)| --- ÜÔÏ 30 ÅÄÉÎÉà ×ÐÒÁ×Ï ÏÔ ÎÁÞÁÌÁ +ËÏÏÒÄÉÎÁÔ, ÇÄÅ ÅÄÉÎÉÃÁ --- ÜÔÏ $1\over72$ ÄÀÊÍÁ. +%%This +%%means that \verb|(30,0)| is 30 units to the right of the origin, where a +%%unit is $1\over72$ of an inch. +íÙ ÂÕÄÅÍ ÓÓÙÌÁÔØÓÑ ÎÁ ÜÔÕ ÅÄÉÎÉÃÕ ÉÚÍÅÒÅÎÉÑ ÐÏ-ÕÍÏÌÞÁÎÉÀ ËÁË ÎÁ +{\sl PostScript-ÐÕÎËÔ}\index{PostScript!ÐÕÎËÔ}\index{ÐÕÎËÔ!PostScript} +ÄÌÑ ÏÔÌÉÞÅÎÉÑ ÅÇÏ ÏÔ ÓÔÁÎÄÁÒÔÎÏÇÏ ÄÌÑ ÐÒÉÎÔÅÒÏ× +ÐÕÎËÔÁ\index{ÐÕÎËÔ!ÐÒÉÎÔÅÒÁ}, ËÏÔÏÒÙÊ ÒÁ×ÅÎ $1\over72.27$ ÄÀÊÍÁ. +%We shall refer to this default unit as a +%{\sl PostScript point\/}\index{PostScript!point}\index{point!PostScript} +%to distinguish it from the standard printer's +%point\index{point!printer's} which is $1\over72.27$ inches. + +MetaPost ÉÓÐÏÌØÚÕÅÔ ÔÅ ÖÅ ÉÍÅÎÁ ÄÌÑ ÅÄÉÎÉà ÉÚÍÅÒÅÎÉÑ, ÞÔÏ É \TeX\ É \MF. +%%MetaPost uses the same names for units of measure that \TeX\ and \MF\ +%%do. +ôÁËÉÍ ÏÂÒÁÚÏÍ, \verb|bp|\index{bp?\texttt{bp}}\label{Dbp} ÓÓÙÌÁÅÔÓÑ ÎÁ PostScript-ÐÕÎËÔÙ (``ÂÏÌØÛÉÅ ÐÕÎËÔÙ''), Á \verb|pt|\index{pt?\texttt{pt}}\label{Dpt} --- ÎÁ ÐÕÎËÔÙ ÐÒÉÎÔÅÒÁ. +%%Thus \verb|bp|\index{bp?\texttt{bp}}\label{Dbp} refers to +%%PostScript points (``big points'') and +%%\verb|pt|\index{pt?\texttt{pt}}\label{Dpt} refers to printer's points. +äÒÕÇÉÅ ÅÄÉÎÉÃÙ ÉÚÍÅÒÅÎÉÑ ×ËÌÀÞÁÀÔ +\verb|in|\index{in?\texttt{in}}\label{Din} ÄÌÑ ÄÀÊÍÏ×, +\verb|cm|\index{cm?\texttt{cm}}\label{Dcm} ÄÌÑ ÓÁÎÔÉÍÅÔÒÏ× É \verb|mm|\index{mm?\texttt{mm}}\label{Dmm} ÄÌÑ ÍÉÌÌÉÍÅÔÒÏ×. +%%Other units of measure include +%%\verb|in|\index{in?\texttt{in}}\label{Din} for inches, +%%\verb|cm|\index{cm?\texttt{cm}}\label{Dcm} for centimeters, and +%%\verb|mm|\index{mm?\texttt{mm}}\label{Dmm} for millimeters. +îÁÐÒÉÍÅÒ, +%%For example, +$$ \hbox{\verb|(2cm,2cm)--(0,0)--(0,3cm)--(3cm,0)--(0,0)|} $$ +ÇÅÎÅÒÉÒÕÅÔ ÂÏÌØÛÉÊ ×ÁÒÉÁÎÔ ÄÉÁÇÒÁÍÍÙ ×ÙÛÅ. +%%generates a larger version of the above diagram. +âÕÄÅÔ ×ÅÒÎÏ ÓËÁÚÁÔØ \verb|0| ×ÍÅÓÔÏ \verb|0cm|, ÐÏÔÏÍÕ ÞÔÏ {\tt cm} +× ÄÅÊÓÔ×ÉÔÅÌØÎÏÓÔÉ ÔÏÌØËÏ ÍÎÏÖÉÔÅÌØ ÐÒÅÏÂÒÁÚÏ×ÁÎÉÑ É {\tt 0cm} ÔÏÌØËÏ +ÕÍÎÏÖÁÅÔ ÜÔÏÔ ÍÎÏÖÉÔÅÌØ ÎÁ ÎÏÌØ. +%%It is OK to say +%%\verb|0| instead \verb|0cm| because {\tt cm} is really just a conversion +%%factor and {\tt 0cm} just multiplies the conversion factor by zero. +(MetaPost ÐÏÎÉÍÁÅÔ ËÏÎÓÔÒÕËÃÉÉ ÐÏÄÏÂÎÙÅ +{\tt 2cm}\index{ÕÍÎÏÖÅÎÉÅ, ÎÅÑ×ÎÏÅ} ËÁË ÓÏËÒÁÝÅÎÉÅ ÄÌÑ \verb|2*cm|). +%%(MetaPost understands constructions like {\tt +%%2cm}\index{multiplication, implicit} as shorthand for \verb|2*cm|). + +õÄÏÂÎÏ ××ÅÓÔÉ Ó×ÏÊ ÓÏÂÓÔ×ÅÎÎÙÊ ÍÁÓÛÔÁÂÉÒÕÀÝÉÊ ÍÎÏÖÉÔÅÌØ, ÓËÁÖÅÍ $u$. +%%It is convenient to introduce your own scale factor, say $u$. +úÁÔÅÍ ×Ù ÍÏÖÅÔÅ ÏÐÒÅÄÅÌÉÔØ ËÏÏÒÄÉÎÁÔÙ ÏÔÎÏÓÉÔÅÌØÎÏ $u$ É ÐÏÚÖÅ ÒÅÛÁÔØ, +ÈÏÔÉÔÅ ÌÉ ×Ù ÎÁÞÁÔØ Ó \verb|u=1cm| ÉÌÉ \verb|u=0.5cm|. +%%Then you +%%can define coordinates in terms of $u$ and decide later whether you want +%%to begin with \verb|u=1cm| or \verb|u=0.5cm|. +üÔÏ ÄÁÓÔ ×ÁÍ ËÏÎÔÒÏÌØ ÎÁÄ ÔÅÍ, ÞÔÏ ÍÁÓÛÔÁÂÉÒÕÅÍÏ É ÎÁÄ ÔÅÍ, ÞÔÏ ÎÅÔ, Ô.~Ë. +ÉÚÍÅÎÅÎÉÅ $u$ ÎÅ ÐÏ×ÌÉÑÅÔ ÎÁ ÔÁËÉÅ Ó×ÏÊÓÔ×Á ËÁË ÔÏÌÝÉÎÁ ÌÉÎÉÊ. +%%This gives you control +%%over what gets scaled and what does not so that changing $u$ will not +%%affect features such as line widths. + +åÓÔØ ÍÎÏÇÏ ÐÕÔÅÊ ÉÚÍÅÎÑÔØ ×ÉÄ ÌÉÎÉÉ Ó×ÅÒÈ ÐÒÏÓÔÏÇÏ +ÉÚÍÅÎÅÎÉÑ ÅÅ ÔÏÌÝÉÎÙ, ÏÄÎÁËÏ ÍÅÈÁÎÉÚÍÙ ÕÐÒÁ×ÌÅÎÉÑ ÛÉÒÉÎÏÊ ××ÏÄÑÔ +ÍÎÏÇÏ ÏÂÝÉÈ ÐÏÎÑÔÉÊ, ËÏÔÏÒÙt ÎÁÍ ÐÏËÁ ÅÝÅ ÎÅ ÎÕÖÎÙ. +%%There are many ways to affect the appearance of a line besides just +%%changing its width, so the width-control mechanisms allow a lot of +%%generality that we do not need yet. +óÏÏÔ×ÅÔÓÔ×ÕÀÝÉÅ ËÏÍÁÎÄÙ ÍÏÇÕÔ ÓÔÒÁÎÎÏ ×ÙÇÌÑÄÅÔØ, ÎÁÐÒÉÍÅÒ, +ËÏÍÁÎÄÁ\index{pickup?\texttt{pickup}}\index{pencircle?\texttt{pencircle}}% +\index{scaled?\texttt{scaled}} +%%This leads to the strange looking +%%statement\index{pickup?\texttt{pickup}}\index{pencircle?\texttt{pencircle}}% +%%\index{scaled?\texttt{scaled}} +$$ \hbox{\verb|pickup pencircle scaled 4pt|} $$ +ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ ÔÏÌÝÉÎÕ ÌÉÎÉÉ × 4 ÐÕÎËÔÁ ÄÌÑ ÐÏÓÌÅÄÕÀÝÅÊ ËÏÍÁÎÄÙ \verb|draw|. +%%for setting the line width for subsequent \verb|draw| statements to 4 points. +(üÔÏ ÐÒÉÍÅÒÎÏ × 8 ÒÁÚ ÂÏÌØÛÅ ÓÔÁÎÄÁÒÔÎÏÊ ÔÏÌÝÉÎÙ ÌÉÎÉÉ). +%%(This is about eight times the default line width). + +ó ÔÁËÏÊ ÂÏÌØÛÏÊ ÔÏÌÝÉÎÏÊ ÄÁÖÅ ÌÉÎÉÑ ÄÌÉÎÙ ÎÏÌØ ×ÙÇÌÑÄÉÔ ËÁË ÂÏÌØÛÁÑ ÖÉÒÎÁÑ +ÔÏÞËÁ\index{ÔÏÞËÉ}. +%%With such a wide line width, even a line of zero length comes out as a big bold +%%dot\index{dots}. +íÙ ÍÏÖÅÍ ÜÔÏ ÉÓÐÏÌØÚÏ×ÁÔØ ÄÌÑ ÓÏÚÄÁÎÉÑ ÒÅÛÅÔËÉ ÉÚ ÖÉÒÎÙÈ ÔÏÞÅË, ÉÍÅÑ ÏÄÎÕ +ËÏÍÁÎÄÕ \verb|drawdot| ÄÌÑ ËÁÖÄÏÇÏ ÕÚÌÁ ÒÅÛÅÔËÉ. +%%We can use this to make a grid of bold dots by having one +%%\verb|drawdot| statement for each grid point. +ôÁËÁÑ ÐÏ×ÔÏÒÑÀÝÁÑÓÑ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ËÏÍÁÎÄ \verb|draw| ÚÁÐÉÓÙ×ÁÅÔÓÑ +ÎÁÉÌÕÞÛÉÍ ÏÂÒÁÚÏÍ ËÁË ÐÁÒÁ ×ÌÏÖÅÎÎÙÈ ÃÉËÌÏ×:\index{ÃÉËÌÙ}% +\index{for?\texttt{for}}\index{endfor?\texttt{endfor}} +%%Such a repetitive sequence of \verb|draw| statements is +%%best written as a pair of nested loops:\index{loops}% +%%\index{for?\texttt{for}}\index{endfor?\texttt{endfor}} +$$\begin{verbatim} +for i=0 upto 2: + for j=0 upto 2: drawdot (i*u,j*u); endfor +endfor +\end{verbatim} +$$ +÷ÎÅÛÎÉÊ ÃÉËÌ ÉÓÐÏÌÎÑÅÔÓÑ ÄÌÑ $i=0,1,2$, Á ×ÎÕÔÒÅÎÎÉÊ --- ÄÌÑ $j=0,1,2$. +%%The outer loop runs for $i=0,1,2$ and the inner loop runs for $j=0,1,2$. +òÅÚÕÌØÔÁÔ --- ÒÅÛÅÔËÁ ÔÒÉ ÎÁ ÔÒÉ ÉÚ ÖÉÒÎÙÈ ÔÏÞÅË, ËÁË ÐÏËÁÚÁÎÏ ÎÁ +ÒÉÓ.~\ref{fig1}. +%%The result is a three-by-three grid of bold dots as shown in Figure~\ref{fig1}. +üÔÏÔ ÒÉÓÕÎÏË ×ËÌÀÞÁÅÔ ÔÁËÖÅ ÂÏÌØÛÉÊ ×ÁÒÉÁÎÔ ÌÏÍÁÎÏÊ ÌÉÎÉÉ, ËÏÔÏÒÕÀ ÍÙ +×ÉÄÅÌÉ ÒÁÎØÛÅ. +%%The figure also includes a larger version of the polygonal line diagram that we +%%saw before. + +\begin{figure}[htp] +$$ \begin{verbatim} +beginfig(2); +u=1cm; +draw (2u,2u)--(0,0)--(0,3u)--(3u,0)--(0,0); +pickup pencircle scaled 4pt; +for i=0 upto 2: + for j=0 upto 2: drawdot (i*u,j*u); endfor +endfor +endfig; +\end{verbatim} +\quad \mathcenter{\includegraphics{manfig-ru-2}} +$$ +\caption{ëÏÍÁÎÄÙ MetaPost É ÒÅÚÕÌØÔÉÒÕÀÝÉÊ ×Ù×ÏÄ} +%%\caption{MetaPost commands and the resulting output} +\label{fig1} +\end{figure} + +úÁÍÅÔØÔÅ, ÞÔÏ ÐÒÏÇÒÁÍÍÁ ÎÁ ÒÉÓ.~\ref{fig1} ÎÁÞÉÎÁÅÔÓÑ Ó +\verb|beginfig(2)|\index{beginfig?\texttt{beginfig}} É ÚÁËÁÎÞÉ×ÁÅÔÓÑ Ó +\verb|endfig|\index{endfig?\texttt{endfig}}. +%%Note that the program in Figure~\ref{fig1} starts with +%%\verb|beginfig(2)|\index{beginfig?\texttt{beginfig}} and ends with +%%\verb|endfig|\index{endfig?\texttt{endfig}}. +üÔÉ ÍÁËÒÏÓÙ, ×ÙÐÏÌÎÑÀÝÉÅ ÁÄÍÉÎÉÓÔÒÁÔÉ×ÎÙÅ ÆÕÎËÃÉÉ, ÇÁÒÁÎÔÉÒÕÀÔ, ÞÔÏ +ÒÅÚÕÌØÔÁÔÙ ×ÓÅÈ ËÏÍÁÎÄ \verb|draw| ÓÏÂÉÒÁÀÔÓÑ ×ÍÅÓÔÅ É ÔÒÁÎÓÌÉÒÕÀÔÓÑ × +PostScript. +%%These are macros that +%%perform various administrative functions and ensure that the results of +%%all the \verb|draw| statements get packaged up and translated into +%%PostScript. +÷ÈÏÄÎÏÊ ÆÁÊÌ ÄÌÑ MetaPost ÏÂÙÞÎÏ ÓÏÄÅÒÖÉÔ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÐÁÒ +\verb|beginfig| É \verb|endfig| Ó ËÏÍÁÎÄÏÊ {\tt end}\index{end?\texttt{end}} +ÐÏÓÌÅ ÐÏÓÌÅÄÎÅÊ ÐÁÒÙ. +%%A MetaPost input file normally contains a sequence of +%%\verb|beginfig|, \verb|endfig| pairs with an {\tt +%%end}\index{end?\texttt{end}} statement after the last one. +åÓÌÉ ÜÔÏÔ ÆÁÊÌ ÉÍÅÎÏ×ÁÎ {\tt fig.mp}, ÔÏ ×Ù×ÏÄ ÏÔ ËÏÍÁÎÄ \verb|draw| +ÍÅÖÄÕ \verb|beginfig(1)| É ÓÌÅÄÕÀÝÅÊ \verb|endfig| ÐÉÛÅÔÓÑ × ÆÁÊÌ +{\tt fig.1}\index{ÆÁÊÌÙ!×Ù×ÏÄ}. +%%If this file +%%is named {\tt fig.mp}, the output from \verb|draw| statements between +%%\verb|beginfig(1)| and the next \verb|endfig| is written in a file {\tt +%%fig.1}\index{files!output}. +äÒÕÇÉÍÉ ÓÌÏ×ÁÍÉ, ÞÉÓÌÏ×ÏÊ ÁÒÇÕÍÅÎÔ × ÍÁËÒÏÓÅ \verb|beginfig| ÏÐÒÅÄÅÌÑÅÔ +ÉÍÑ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÇÏ ×ÙÈÏÄÎÏÇÏ ÆÁÊÌÁ. +%%In other words, the numeric argument to the +%%\verb|beginfig| macro determines the name of the corresponding output +%%file. + +þÔÏ ÄÅÌÁÔØ ÓÏ ×ÓÅÍÉ ÜÔÉÍÉ PostScript-ÆÁÊÌÁÍÉ? +%%What does one do with all the PostScript files? +ïÎÉ ÍÏÇÕÔ ÂÙÔØ ×ËÌÀÞÅÎÙ ËÁË ÒÉÓÕÎËÉ × ÄÏËÕÍÅÎÔÙ \TeX\index{TeX?\TeX} ÉÌÉ +troff\index{troff}, ÅÓÌÉ ×Ù ÉÍÅÅÔÅ ÄÒÁÊ×ÅÒ, ËÏÔÏÒÙÊ ÍÏÖÅÔ ÒÁÂÏÔÁÔØ Ó +PostScript-ËÁÒÔÉÎËÁÍÉ. +%%They can be included as +%%figures in a \TeX\index{TeX?\TeX} or troff\index{troff} document if you +%%have an output driver that can handle encapsulated PostScript figures. +ïÎÉ ÔÁËÖÅ ÍÏÇÕÔ ÂÙÔØ ÐÒÅÄ×ÁÒÉÔÅÌØÎÏ ÐÒÏÓÍÏÔÒÅÎÙ ÄÏ ÉÈ ×ËÌÀÞÅÎÉÑ × ÄÏËÕÍÅÎÔ +Ó ÔÙÓÑÞÅÊ ÓÔÒÁÎÉÃ. +%%They can also be previewed before they are included in a thousand pages +%%document. +óÌÅÄÕÀÝÉÅ ÒÁÚÄÅÌÙ ÄÁÀÔ ÂÏÌØÛÅ ÉÎÆÏÒÍÁÃÉÉ. +%%The next sections give some more information. + +\section{õÐÒÁ×ÌÅÎÉÅ ×Ù×ÏÄÏÍ MetaPost} +%%\section{Handling MetaPost output} +\label{Dmpoutput} + +÷ÚÁÉÍÏÄÅÊÓÔ×ÉÅ ÍÅÖÄÕ \TeX\ É MetaPost ÍÏÖÅÔ ÂÙÔØ Ä×ÏÑËÉÍ. +%%There can be a two-fold interaction between \TeX\ and MetaPost. +ó ÏÄÎÏÊ ÓÔÏÒÏÎÙ, ÇÒÁÆÉËÁ MetaPost ÍÏÖÅÔ ÉÍÐÏÒÔÉÒÏ×ÁÔØÓÑ × ÄÏËÕÍÅÎÔÙ, +ÎÁÂÉÒÁÅÍÙÅ \TeX\ É ÅÇÏ ÄÒÕÚØÑÍÉ. +%%On one +%%hand, MetaPost graphics can be imported into documents typeset by \TeX\ +%%and friends. +ó ÄÒÕÇÏÊ ÓÔÏÒÏÎÙ, MetaPost ÍÏÖÅÔ ÐÏÒÕÞÉÔØ ÎÁÂÏÒ ÔÅËÓÔÏ×ÙÈ ÜÌÅÍÅÎÔÏ× \TeX, +\LaTeX\ ÉÌÉ \emph{troff}, ÎÁÐÒÉÍÅÒ, ÔÅËÓÔÏ×ÙÈ ÍÅÔÏË ÉÌÉ ÍÁÔÅÍÁÔÉÞÅÓËÉÈ +ÆÏÒÍÕÌ × ÇÒÁÆÉËÅ. +%%On the other hand, MetaPost can delegate typesetting +%%textual elements to \TeX, \LaTeX\ or \emph{troff}, e.g., text labels or +%%mathematical formulas in a graphic. +ôÁËÉÍ ÓÐÏÓÏÂÏÍ ÇÒÁÆÉËÁ MetaPost ÍÏÖÅÔ ÌÅÇËÏ ÐÒÉÎÑÔØ ÓÔÉÌØ ÄÏËÕÍÅÎÔÁ +(ÛÒÉÆÔ, ÒÁÚÍÅÒ ÛÒÉÆÔÁ É Ô.~Ð.) É ÓÏÏÔ×ÅÔÓÔ×Ï×ÁÔØ ËÁÞÅÓÔ×Õ ÅÇÏ ÎÁÂÏÒÁ +(ÉÓÐÏÌØÚÏ×ÁÔØ ËÅÒÎÉÎÇ, ÌÉÇÁÔÕÒÙ É Ô.~Ð.). +%%That way, MetaPost graphics can +%%easily adopt the style of a document (type, type size, etc.) and fit its +%%typesetting quality (use kerning, ligatures, etc.) +üÔÏ ÄÅÌÁÅÔ MetaPost ÉÄÅÁÌØÎÙÍ ÉÎÓÔÒÕÍÅÎÔÏÍ ÄÌÑ ÐÒÉÇÏÔÏ×ÌÅÎÉÑ ×ÙÓÏËÏËÁÞÅÓÔ×ÅÎÎÏÊ +ÇÒÁÆÉËÉ ÄÌÑ ÄÏËÕÍÅÎÔÏ× \TeX\ ÉÌÉ \emph{troff}. +%%This makes MetaPost +%%an ideal tool for preparing high-quality graphics for \TeX\ or +%%\emph{troff} documents. + +üÔÏÔ ÒÁÚÄÅÌ ÏÔÎÏÓÉÔÓÑ Ë ÐÅÒ×ÏÊ ÓÔÏÒÏÎÅ ×ÚÁÉÍÏÄÅÊÓÔ×ÉÑ \TeX--MetaPost: +ÉÍÐÏÒÔÕ ÇÒÁÆÉËÉ MetaPost × \TeX\ É ÅÇÏ ÄÒÕÚÅÊ. +%%This section deals with the first aspect of \TeX--MetaPost interaction, +%%the import of MetaPost graphics into \TeX\ and friends. +îÁÂÏÒ ÔÅËÓÔÏ× × MetaPost ÏÂÓÕÖÄÁÅÔÓÑ × ÒÁÚÄÅÌÅ~\ref{text}. +%%Typesetting +%%text in MetaPost is discussed in section~\ref{text}. + +\subsection{ðÒÅÄ×ÁÒÉÔÅÌØÎÙÊ ÐÒÏÓÍÏÔÒ ÇÒÁÆÉËÉ MetaPost} +%%\subsection{Previewing MetaPost graphics} + +\label{Dpreview} +\index{ÐÒÅÄÐÒÏÓÍÏÔÒ} +%%\index{previewing} + +÷Ù×ÏÄ MetaPost --- ÜÔÏ ×ÁÒÉÁÎÔ PostScript, ÎÁÚÙ×ÁÅÍÙÊ Encapsulated +PostScript\index{PostScript!ÓÔÒÕËÔÕÒÎÙÊ} (EPSF\index{EPSF}). +%%The output of MetaPost is a variant of PostScript, called Encapsulated +%%PostScript\index{PostScript!structured} (EPSF\index{EPSF}). +çÒÁÆÉËÁ MetaPost ÍÏÖÅÔ, ÓÌÅÄÏ×ÁÔÅÌØÎÏ, ÂÙÔØ ÐÒÏÓÍÏÔÒÅÎÁ × ÌÀÂÏÍ +PostScript-ÐÒÏÓÍÏÔÒÝÉËÅ, ÎÁÐÒÉÍÅÒ, GSview\index{GSview}. +%%MetaPost +%%graphics can therefore be previewed with any decent PostScript viewer, +%%e.\,g., GSview\index{GSview}. + +óÉÔÕÁÃÉÑ ÓÔÁÎÏ×ÉÔÓÑ ÔÏÌØËÏ ÎÅÍÎÏÇÏ ÓÌÏÖÎÅÅ, ËÏÇÄÁ ×Ù×ÏÄ MetaPost ÓÏÄÅÒÖÉÔ +ÔÅËÓÔ. +%%The situation becomes only a little bit fussy when MetaPost output +%%contains text. +ïÂÙÞÎÏ MetaPost ÎÅ ÐÒÏÉÚ×ÏÄÉÔ ÓÁÍÏÄÏÓÔÁÔÏÞÎÙÅ EPS-ÆÁÊÌÙ, ÎÁÐÒÉÍÅÒ, +ÛÒÉÆÔÙ É ÔÁÂÌÉÃÙ ËÏÄÉÒÏ×ÏË ÎÅ ÐÏÍÅÝÁÀÔÓÑ × ×Ù×ÏÄ. +%%By default, MetaPost doesn't produce self-contained EPS +%%files, e.\,g., font resources and encoding vectors are not stored in +%%the output. +ðÏÜÔÏÍÕ ×Ù×ÏÄ MetaPost, ÓÏÄÅÒÖÁÝÉÊ ÔÅËÓÔ, ÍÏÖÅÔ ÂÙÔØ ÐÏËÁÚÁÎ Ó ÎÅ×ÅÒÎÙÍÉ +ÛÒÉÆÔÁÍÉ, ÎÅ×ÅÒÎÙÍÉ ÓÉÍ×ÏÌÁÍÉ ÉÌÉ ×ÏÏÂÝÅ ÂÅÚ ÔÅËÓÔÁ × +PostScript-ÐÒÏÓÍÏÔÒÝÉËÅ. +%%For that reason MetaPost output containing text may be +%%rendered with wrong fonts, wrong glyphs or with no text at all in a +%%PostScript viewer. +äÏÌÇÏÅ ×ÒÅÍÑ, ÎÁÉÂÏÌÅÅ ÎÁÄÅÖÎÙÊ ÐÕÔØ ÄÌÑ ÐÒÏÓÍÏÔÒÁ ÂÙÌ × ÐÏÄÇÏÔÏ×ËÅ +ÔÅÓÔ-ÄÏËÕÍÅÎÔÁ, ×ËÌÀÞÁÀÝÅÇÏ ×ÓÅ ËÁÒÔÉÎËÉ MetaPost, ÏÂÒÁÂÏÔËÅ ÅÇÏ ÌÉÂÏ +\TeX, ÌÉÂÏ \LaTeX, ÚÁÔÅÍ \ttindex{dvips} É ÐÏËÁÚÕ ÒÅÚÕÌØÔÉÒÕÀÝÅÇÏ +\ttt{ps}-ÆÁÊÌÁ × PostScript-ÐÒÏÓÍÏÔÒÝÉËÅ.\footnote{èÏÔÑ ÅÓÔØ É +ÁÌØÔÅÒÎÁÔÉ×Ù: \ttindex{mpstoeps} --- ÜÔÏ Perl-ÓÃÅÎÁÒÉÊ, ËÏÔÏÒÙÊ +Á×ÔÏÍÁÔÉÚÉÒÕÅÔ ÐÒÏÃÅÓÓ, ÏÂÏÚÎÁÞÅÎÎÙÊ ×ÙÛÅ, Á +\ttindex{mptopdf} --- ÜÔÏ ÄÒÕÇÏÅ ÓÒÅÄÓÔ×Ï, ËÏÔÏÒÏÅ ËÏÎ×ÅÒÔÉÒÕÅÔ +MetaPost-ÆÁÊÌÙ × PDF.} +%%For a long time, the most reliable way for +%%previewing was to prepare a test document that includes all MetaPost +%%figures, process that with \TeX\ or \LaTeX\ and \ttindex{dvips} and +%%display the resulting \ttt{ps} file in a PostScript +%%viewer.\footnote{There are alternatives, though. \ttindex{mpstoeps} is +%%a Perl script that automates the process outlined above. +%%\ttindex{mptopdf} is another tools that converts MetaPost files to +%%PDF.} + +ïÄÎÁËÏ, Ó ×ÅÒÓÉÉ 1.000 MetaPost ÓÉÔÕÁÃÉÑ ÉÚÍÅÎÉÌÁÓØ. ó ÜÔÏÊ ×ÅÒÓÉÉ +MetaPost ÓÐÏÓÏÂÅÎ ÐÒÏÉÚ×ÏÄÉÔØ ÓÁÍÏÄÏÓÔÁÔÏÞÎÙÅ ÆÁÊÌÙ EPS, ËÏÔÏÒÙÅ +ÍÏÇÕÔ ÂÙÔØ ÄÏÓÔÏ×ÅÒÎÏ ÐÒÏÓÍÏÔÒÅÎÙ × ÎÅÚÁ×ÉÓÉÍÏÓÔÉ ÏÔ ÔÏÇÏ, ÅÓÔØ ÌÉ × ÎÉÈ +ÔÅËÓÔ ÉÌÉ ÎÅÔ. +%%However, with MetaPost version~1.000 the situation changed. Since that +%%version MetaPost is able to produce self-contained EPS files, that can +%%reliably be previewed, may they contain text or not. +îÏ×ÙÅ ×ÏÚÍÏÖÎÏÓÔÉ ÍÏÇÕÔ ÂÙÔØ ×ËÌÀÞÅÎÙ ÕÓÔÁÎÏ×ËÏÊ ×ÎÕÔÒÅÎÎÅÊ ÐÅÒÅÍÅÎÎÏÊ +MetaPost \ttt{prologues}\index{prologues?\texttt{prologues}} ×~3. +%%The +%%new behaviour can be triggered by setting MetaPost's internal variable +%%\ttt{prologues}\index{prologues?\texttt{prologues}} to~3. +óÍÏÔÒÉ ÒÁÚÄÅÌ~\ref{Dbtex} ÄÌÑ ÂÏÌØÛÅÊ ÉÎÆÏÒÍÁÃÉÉ Ï \ttt{prologues}. +%%See +%%section~\ref{Dbtex} for more information on \ttt{prologues}. + +\subsection{éÓÐÏÌØÚÏ×ÁÎÉÅ ÇÒÁÆÉËÉ MetaPost × \TeX, \LaTeX, pdf\LaTeX, pdf\TeX, Con\TeX{}t É troff} +%\subsection{Using MetaPost graphics in \TeX, \LaTeX, pdf\LaTeX, pdf\TeX, Con\TeX{}t and troff} +\label{Dteximport} +\index{TeX?\TeX!ÉÍÐÏÒÔ ÆÁÊÌÏ× MetaPost} +\index{LaTeX?\LaTeX!ÉÍÐÏÒÔ ÆÁÊÌÏ× MetaPost} +\index{pdfLaTeX?pdf\LaTeX!ÉÍÐÏÒÔ ÆÁÊÌÏ× MetaPost} +\index{pdfTeX?pdf\TeX!ÉÍÐÏÒÔ ÆÁÊÌÏ× MetaPost} +\index{ConTeXt?Con\TeX t!ÉÍÐÏÒÔ ÆÁÊÌÏ× MetaPost} +\index{troff!ÉÍÐÏÒÔ ÆÁÊÌÏ× MetaPost} +%%\index{TeX?\TeX!importing MetaPost files} +%%\index{LaTeX?\LaTeX!importing MetaPost files} +%%\index{pdfLaTeX?pdf\LaTeX!importing MetaPost files} +%%\index{pdfTeX?pdf\TeX!importing MetaPost files} +%%\index{ConTeXt?Con\TeX t!importing MetaPost files} +%%\index{troff!importing MetaPost files} + +ôÏ ËÁË ÒÉÓÕÎËÉ MetaPost ÍÏÇÕÔ ÂÙÔØ ÉÎÔÅÇÒÉÒÏ×ÁÎÙ Ó ÄÏËÕÍÅÎÔÁÍÉ, +ÐÏÄÇÏÔÏ×ÌÅÎÎÙÍÉ × \TeX\ É ÒÏÄÓÔ×ÅÎÎÙÈ \TeX\ ÐÒÏÇÒÁÍÍÁÈ, ÚÁ×ÉÓÉÔ ÏÔ +ÆÏÒÍÁÔÁ ÄÏËÕÍÅÎÔÏ× É ÄÒÁÊ×ÅÒÁ ×Ù×ÏÄÁ. +%%How MetaPost figures can be integrated into documents prepared with +%%\TeX\ and friends depends on the exact format and output driver. +òÉÓ.~\ref{fig0} ÐÏËÁÚÙ×ÁÅÔ ÐÒÏÃÅÓÓ ÒÁÂÏÔÙ ÄÌÑ plain \TeX, \LaTeX\ É +Ó×ÏÂÏÄÎÏ ÄÏÓÔÕÐÎÏÊ ÐÒÏÇÒÁÍÍÙ \ttindex{dvips}\footnote{éÓÈÏÄÎÉËÉ ÎÁ C ÄÌÑ +\ttt{dvips} ÎÁÈÏÄÑÔÓÑ ×ÍÅÓÔÅ Ó web2c \TeX-ÄÉÓÔÒÉÂÕÔÉ×ÏÍ. ðÏÄÏÂÎÙÅ +ÐÒÏÇÒÁÍÍÙ ÄÏÓÔÕÐÎÙ É × ÄÒÕÇÉÈ ÍÅÓÔÁÈ.}. +%%Figure~\ref{fig0} shows the workflow for plain \TeX, \LaTeX\ and the +%%freely available program \ttindex{dvips}.\footnote{The C source for +%%\ttt{dvips} comes with the web2c \TeX\ distribution. Similar programs +%%are available from other sources.} +óÈÏÖÁÑ ÐÒÏÃÅÄÕÒÁ ÒÁÂÏÔÁÅÔ Ó troff: ÐÒÏÃÅÓÓÏÒ ×Ù×ÏÄÁ \ttt{grops} ×ËÌÀÞÁÅÔ ÒÉÓÕÎËÉ ÎÁ PostScript, ËÏÇÄÁ ÏÎÉ ÚÁÐÒÁÛÉ×ÁÀÔÓÑ ÞÅÒÅÚ ËÏÍÁÎÄÕ troff +\ttt{\string\X}. +%%A similar procedure works with +%%troff: the \ttt{grops} output processor includes PostScript figures when +%%they are requested via troff's \ttt{\string\X} command. +ó ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ PDF Ó \TeX\ É \LaTeX\ ÓÉÔÕÁÃÉÑ ÎÅÓËÏÌØËÏ ÉÎÁÑ. +%%For the PDF +%%flavour of \TeX\ and \LaTeX\ the situation is a little bit different. +óÌÅÄÕÀÝÉÅ ÁÂÚÁÃÙ ÄÁÀÔ ËÒÁÔËÕÀ ÉÎÆÏÒÍÁÃÉÀ ÐÏ ÎÅËÏÔÏÒÙÍ ÐÏÐÕÌÑÒÎÙÍ +\TeX-ÆÏÒÍÁÔÁÍ É ÄÒÁÊ×ÅÒÁÍ ×Ù×ÏÄÁ. +%%The next paragraphs give brief information on some popular \TeX\ formats +%%and output drivers. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-0} $$ +\caption[äÉÁÇÒÁÍÍÁ ÏÂÒÁÂÏÔËÉ ÄÌÑ ÄÏËÕÍÅÎÔÁ Ó ÒÉÓÕÎËÁÍÉ MetaPost] + {äÉÁÇÒÁÍÍÁ ÏÂÒÁÂÏÔËÉ ÄÌÑ \TeX-ÄÏËÕÍÅÎÔÁ Ó ÒÉÓÕÎËÁÍÉ × MetaPost} +%%\caption[A diagram of the processing for a document with MetaPost figures] +%% {A diagram of the processing for a \TeX\ document with figures +%% in MetaPost} +\label{fig0} +\end{figure} + +\paragraph{\TeX} +ðÏÌØÚÏ×ÁÔÅÌÉ \TeX\ ÍÏÇÕÔ ÉÍÐÏÒÔÉÒÏ×ÁÔØ ÇÒÁÆÉËÕ, ÚÁÇÒÕÚÉ× ÓÎÁÞÁÌÁ ÐÁËÅÔ +\ttt{epsf}\index{epsf.tex?\texttt{epsf.tex}} ÞÅÒÅÚ \verb+\input epsf+ É +ÚÁÔÅÍ ××ÅÄÑ ËÏÍÁÎÄÕ +$$ \verb+\epsfbox{+\descr{ÉÍÑ ÆÁÊÌÁ}\verb+}+ $$% +\index{epsfbox?\texttt{\string\epsfbox}} +ÄÌÑ ÚÁÇÒÕÚËÉ EPS-ÆÁÊÌÁ, ÎÁÐÒÉÍÅÒ, \verb+\epsfbox{fig.1}+. +%%\TeX\ users can import EPS graphics by first loading package +%%\ttt{epsf}\index{epsf.tex?\texttt{epsf.tex}} via \verb+\input epsf+ and +%%then issuing the command +%%$$ \verb+\epsfbox{+\descr{filename}\verb+}+ $$% +%%\index{epsfbox?\texttt{\string\epsfbox}} +%%to load an EPS file, e.\,g., \verb+\epsfbox{fig.1}+. + +\paragraph{\LaTeX} +äÌÑ ÄÏËÕÍÅÎÔÏ× \LaTeX\ ÐÒÏÃÅÄÕÒÁ ÐÏÈÏÖÁÑ: ÐÅÒ×ÙÊ ÐÁËÅÔ +\ttindex{graphicx} ÄÏÌÖÅÎ ÂÙÔØ ÚÁÇÒÕÖÅÎ ÒÁÚÍÅÝÅÎÉÅÍ +\verb+\usepackage{graphicx}+ × ÐÒÅÁÍÂÕÌÕ ÄÏËÕÍÅÎÔÁ É ÚÁÔÅÍ +EPS-ÆÁÊÌÙ ÍÏÇÕÔ ÂÙÔØ ÚÁÇÒÕÖÅÎÙ ÞÅÒÅÚ +$$ \verb+\includegraphics{+\descr{ÉÍÑ ÆÁÊÌÁ}\verb+}+, $$% +\index{includegraphics?\texttt{\string\includegraphics}}% +ÎÁÐÒÉÍÅÒ, \verb+\includegraphics{fig.1}+. +%%For \LaTeX\ documents the procedure is similar: first package +%%\ttindex{graphicx} has to be loaded by putting +%%\verb+\usepackage{graphicx}+ into the document preamble and then EPS +%%files can be loaded via +%%$$ \verb+\includegraphics{+\descr{filename}\verb+}+ $$% +%%e.\,g., \verb+\includegraphics{fig.1}+. + +ëÁË ÍÏÖÎÏ ÚÁÍÅÔÉÔØ ÎÁ ÒÉÓ.~\ref{fig0} ÇÒÁÆÉÞÅÓËÉÅ ÆÁÊÌÙ ÎÉËÏÇÄÁ ÎÅ +×ËÌÀÞÁÀÔÓÑ ÐÒÉ ÉÓÐÏÌÎÅÎÉÉ \TeX\index{TeX?\TeX!ÉÍÐÏÒÔ ÆÁÊÌÏ× MetaPost} ÉÌÉ +\LaTeX\index{LaTeX?\LaTeX!ÉÍÐÏÒÔ ÆÁÊÌÏ× MetaPost}. +%%As can be seen in figure~\ref{fig0} graphic files are never included in a +%%\TeX\index{TeX?\TeX!importing MetaPost files} or +%%\LaTeX\index{LaTeX?\LaTeX!importing MetaPost files} run. +÷ÍÅÓÔÏ ÜÔÏÇÏ \TeX\ É \LaTeX\ ÔÏÌØËÏ ÞÉÔÁÀÔ ÉÎÆÏÒÍÁÃÉÀ Ï ÏÈ×ÁÔÙ×ÁÀÝÉÈ +ÒÁÍËÁÈ ÉÚ PostScript-ÆÁÊÌÁ, ÒÅÚÅÒ×ÉÒÕÑ ÓÔÏÌØËÏ ÍÅÓÔÁ ÎÁ ÓÔÒÁÎÉÃÅ, ÓËÏÌØËÏ +ÚÁÎÉÍÁÅÔ ÇÒÁÆÉËÁ É ÚÁÐÉÓÙ×ÁÑ ÓÓÙÌËÕ ÎÁ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ÆÁÊÌ × +\ttt{dvi}-×Ù×ÏÄÅ. +%%Instead, +%%\TeX\ and \LaTeX\ only read bounding box information off the PostScript +%%file, reserve as much space on a page as the graphic +%%occupies and write a reference to the corresponding file into the +%%\ttt{dvi} output. +çÒÁÆÉÞÅÓËÉÊ ÆÁÊÌ ×ËÌÀÞÁÅÔÓÑ ÔÏÌØËÏ ÐÒÉ ÐÏÓÌÅÄÕÀÝÅÍ ÉÓÐÏÌÎÅÎÉÉ ÄÒÁÊ×ÅÒÁ +×Ù×ÏÄÁ, ËÏÔÏÒÙÊ ÍÏÖÅÔ ÏÂÒÁÂÁÔÙ×ÁÔØ PostScript-ÆÁÊÌÙ, +ÎÁÐÒÉÍÅÒ, \ttindex{dvips}. +%%The graphic file is only included in the subsequent +%%run of an output driver, that can handle PostScript files, e.\,g., +%%\ttindex{dvips}. + +\paragraph{pdf\LaTeX} +ðÒÉÌÏÖÅÎÉÅ pdf\LaTeX, ËÏÇÄÁ ÉÓÐÏÌÎÑÅÔÓÑ × ÒÅÖÉÍÅ PDF, Ñ×ÌÑÅÔÓÑ ÓÒÁÚÕ É +\LaTeX-ÉÎÔÅÒÐÒÅÔÁÔÏÒÏÍ, É ÄÒÁÊ×ÅÒÏÍ ×Ù×ÏÄÁ ÄÌÑ ÄÏËÕÍÅÎÔÁ × PDF-ÆÏÒÍÁÔ. +%%The application pdf\LaTeX, when run in PDF mode, is both, a +%%\LaTeX\ interpreter and an output driver for the PDF document format. +ðÏÜÔÏÍÕ ÇÒÁÆÉÞÅÓËÉÅ ÆÁÊÌÙ ×ËÌÀÞÁÀÔÓÑ ×Ï ×ÒÅÍÑ ÉÓÐÏÌÎÅÎÉÑ pdf\LaTeX, ÚÁ +ÏÄÉÎ ÐÒÏÈÏÄ. +%%For that reason graphic files are included in a single +%%pdf\LaTeX\ run. +÷ ÏÔÌÉÞÉÅ ÏÔ \ttt{dvips}, pdf\LaTeX\ ÎÅ ÍÏÖÅÔ ÏÂÒÁÂÁÔÙ×ÁÔØ ÏÂÙÞÎÙÅ +PostScript-ÆÁÊÌÙ --- ÏÎ ÍÏÖÅÔ ÒÁÂÏÔÁÔØ ÔÏÌØËÏ Ó ÔÁË ÎÁÚÙ×ÁÅÍÙÍÉ ÏÞÉÝÅÎÎÙÍÉ +EPS\index{PostScript!ÏÞÉÝÅÎÎÙÊ}-ÆÁÊÌÁÍÉ, ËÏÔÏÒÙÅ ÍÏÇÕÔ ÉÓÐÏÌØÚÏ×ÁÔØ ÔÏÌØËÏ +ÏÇÒÁÎÉÞÅÎÎÏÅ ÍÎÏÖÅÓÔ×Ï ×ÏÚÍÏÖÎÏÓÔÅÊ ÑÚÙËÁ PostScript. +%%In contrast to \ttt{dvips}, pdf\LaTeX\ can't process +%%general PostScript files, but only so-called purified +%%EPS\index{PostScript!purified} files, which may only use a restricted +%%set of PostScript language features. +ë ÓÞÁÓÔØÀ, ×Ù×ÏÄ MetaPost --- ÜÔÏ É \emph{ÅÓÔØ} ÏÞÉÝÅÎÎÙÊ EPS, ÔÁË ÞÔÏ ÔÕÔ +ÎÁÍ ÐÏ×ÅÚÌÏ. +%%Fortunately, MetaPost output +%%\emph{is} purified EPS, so we are in luck. +éÚ ÔÏÇÏ, ÞÔÏ \ttt{mps}\index{ÆÁÊÌÙ!mps?\texttt{mps}} --- ÜÔÏ +ÔÉÐÏ×ÏÅ ÒÁÓÛÉÒÅÎÉÅ pdf\LaTeX\ ÄÌÑ ÏÞÉÝÅÎÎÙÈ EPS-ÆÁÊÌÏ×, Á ×Ù×ÏÄ +MetaPost ÏÂÙÞÎÏ ÉÍÅÅÔ ÒÁÓÛÉÒÅÎÉÑ-ÞÉÓÌÁ, ÍÙ ÄÏÌÖÎÙ +%%Since +%%pdf\LaTeX's default extension for purified EPS files is +%%\ttt{mps}\index{files!mps?\texttt{mps}}, but MetaPost output by +%%default has a number as extensions, we either have to +\begin{itemize} +\item ÓËÁÚÁÔØ pdf\LaTeX\ ÏÂÒÁÂÁÔÙ×ÁÔØ ÚÁÎÕÍÅÒÏ×ÁÎÎÙÅ ÆÁÊÌÙ MetaPost +ÓÏÇÌÁÓÎÏ ÐÒÁ×ÉÌÁÍ ÄÌÑ ÆÁÊÌÏ× \ttt{mps} ÉÌÉ +%%\item tell pdf\LaTeX\ to handle MetaPost's numbered files according to +%%\ttt{mps} file rules, or +\item ÉÚÍÅÎÉÔØ ÒÁÓÛÉÒÅÎÉÅ ÆÁÊÌÁ ×Ù×ÏÄÁ MetaPost ÎÁ \ttt{mps}. +%%\item change the file extension of MetaPost output to \ttt{mps}. +\end{itemize} + +ðÒÉ ÐÅÒ×ÏÍ ÐÏÄÈÏÄÅ ÍÙ ÄÏÌÖÎÙ ÄÏÂÁ×ÉÔØ ÓÔÒÏËÕ +%%For the conventional first approach we have to add the line +$$ \verb+\DeclareGraphicsRule{*}{mps}{*}{}+ $$% +\index{DeclareGraphicsRule?\texttt{\string\DeclareGraphicsRule}}% +Ë ÐÒÅÁÍÂÕÌÅ ÄÏËÕÍÅÎÔÁ ÐÏÓÌÅ ÚÁÇÒÕÚËÉ ÐÁËÅÔÁ \ttt{graphicx}. +%%to the document preamble after loading package \ttt{graphicx}. +üÔÁ ÄÅËÌÁÒÁÃÉÑ ÓËÁÖÅÔ pdf\LaTeX\ ÚÁÇÒÕÖÁÔØ \emph{×ÓÅ} ÆÁÊÌÙ Ó +ÎÅÉÚ×ÅÓÔÎÙÍ ÒÁÓÛÉÒÅÎÉÅÍ ËÁË \ttt{mps}-ÆÁÊÌÙ. +%%That +%%declaration tells pdf\LaTeX\ to load \emph{all} files with unknown file +%%extensions as \ttt{mps} files. +óÍ. ÄÏËÕÍÅÎÔÁÃÉÀ ÐÏ ÐÁËÅÔÁÍ \ttt{graphicx} É \ttt{graphics} ÄÌÑ +ÄÏÐÏÌÎÉÔÅÌØÎÏÊ ÉÎÆÏÒÍÁÃÉÉ. +%%Refer to the documentation of the +%%\ttt{graphicx} and \ttt{graphics} packages for more details. + +ó ×ÅÒÓÉÉ MetaPost 1.000 ÒÅËÏÍÅÎÄÏ×ÁÎ ×ÔÏÒÏÊ ÐÏÄÈÏÄ.\footnote{äÌÑ ÏÂÒÁÂÏÔËÉ +ÒÁÓÛÉÒÅÎÉÊ MetaPost-ÆÁÊÌÏ× ÐÒÅÄÐÏÌÏÖÉÔÅÌØÎÏ ÂÏÌÅÅ ÅÓÔÅÓÔ×ÅÎÎÏ ×ÍÅÓÔÏ +\LaTeX-ÉÓÈÏÄÎÉËÏ× ÉÓÐÏÌØÚÏ×ÁÔØ ÉÓÈÏÄÎÉËÉ MetaPost. +ôÅÍ ÂÏÌÅÅ, ÞÔÏ ÕÓÔÁÎÏ×ËÁ ÒÁÓÛÉÒÅÎÉÑ MetaPost-ÆÁÊÌÁ × \ttt{mps} ÐÒÅÄÏÈÒÁÎÑÅÔ +ÏÔ ÚÁÇÒÑÚÎÅÎÉÑ ÉÚÂÙÔËÏÍ ÒÁÓÛÉÒÅÎÉÊ --- ×ÁÍ ÂÕÄÅÔ ÎÕÖÎÏ ÚÁÒÅÇÉÓÔÒÉÒÏ×ÁÔØ ÔÏÌØËÏ +ÏÄÎÏ ÒÁÓÛÉÒÅÎÉÅ ÄÌÑ ×ÁÛÅÇÏ PostScript-ÐÒÏÓÍÏÔÒÝÉËÁ --- \ttt{.mps}, ×ÍÅÓÔÏ \ttt{.0}, \ttt{.1}, +\ttt{.2} É Ô.~Ä.} +%%Since MetaPost version~1.000 the second approach is +%%recommended.\footnote{For handling MetaPost file extensions in MetaPost +%%source files seems to be the more natural place than \LaTeX\ sources. +%%Moreover, setting the MetaPost file extension to \ttt{mps} prevents from +%%file extension pollution and you only have to register one new extension +%%with your PostScript viewer, \ttt{.mps}, instead of \ttt{.0}, \ttt{.1}, +%%\ttt{.2}, etc.} +ðÒÉÍÉÔÉ× MetaPost \verb+filenametemplate+ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎ ÄÌÑ +ÕÓÔÁÎÏ×ËÉ ÒÁÓÛÉÒÅÎÉÑ ÆÁÊÌÁ ×Ù×ÏÄÁ MetaPost × \ttt{mps} (ÓÍ. +ÒÁÚÄÅÌ~\ref{Dfilenametemplate}) +%%The MetaPost primitive \verb+filenametemplate+ can be +%%used to set the file extension of MetaPost output to \ttt{mps} (see +%%section~\ref{Dfilenametemplate}). +ðÏÜÔÏÍÕ ÄÅËÌÁÒÁÃÉÑ \verb+\DeclareGraphicsRule+ ÚÄÅÓØ ÎÅ ÎÕÖÎÁ. +%%Hence, no \verb+\DeclareGraphicsRule+ +%%declaration is needed. +âÏÌÅÅ ÔÏÇÏ, ÒÁÓÛÉÒÅÎÉÅ ÍÏÖÅÔ ÏÐÕÓËÁÔØÓÑ × ËÏÍÁÎÄÅ \verb+\includegraphics+. +%%Moreover, the file extension can then be omitted +%%in the \verb+\includegraphics+ command. + +\paragraph{\LaTeX\ É pdf\LaTeX} +åÓÌÉ ×Ù ÈÏÔÉÔÅ ÓÏÈÒÁÎÉÔØ ÇÉÂËÏÓÔØ É ×ÏÚÍÏÖÎÏÓÔØ ËÏÍÐÉÌÉÒÏ×ÁÔØ ËÁË \LaTeX, +ÔÁË É pdf\LaTeX, ÔÏ ÎÕÖÎÏ ÐÏÚÁÂÏÔÉÔØÓÑ Ï ÎÅËÏÔÏÒÙÈ ×ÅÝÁÈ. +%%If you want to keep flexible and be able to compile your documents with +%%both, \LaTeX\ and pdf\LaTeX, there are some things to take care of. +óÔÁÎÄÁÒÔÎÁÑ ÄÅËÌÁÒÁÃÉÑ \verb+\DeclareGraphicsRule+ ÍÏÖÅÔ ÂÙÔØ ÁËÔÉ×ÉÒÏ×ÁÎÁ +ÔÏÌØËÏ, ÅÓÌÉ pdf\LaTeX\ ÉÓÐÏÌÎÑÅÔÓÑ × PDF-ÒÅÖÉÍÅ. +%%If +%%you're using the conventional \verb+\DeclareGraphicsRule+ declaration, +%%that may only be activated if pdf\LaTeX\ runs in PDF mode. +ðÏÜÔÏÍÕ ÕÎÉ×ÅÒÓÁÌØÎÁÑ ÄÅËÌÁÒÁÃÉÑ ÄÏÌÖÎÁ ×ÙÇÌÑÄÅÔØ ÐÏÄÏÂÎÏ ÜÔÏÊ: +%%A fully-featured declaration should therefore look like this: + +$$ +\begin{verbatim} +\usepackage{graphicx} +\usepackage{ifpdf} +\ifpdf + \DeclareGraphicsRule{*}{mps}{*}{} +\fi +\end{verbatim} +$$ + +åÓÌÉ ×Ù ÉÓÐÏÌØÚÕÅÔÅ ÍÅÔÏÄ \ttt{filenametemplate}, ÔÏ ÒÁÓÛÉÒÅÎÉÅ ÆÁÊÌÁ +\ttt{mps} ÎÅ ÓÌÅÄÕÅÔ ÏÐÕÓËÁÔØ × ËÏÍÁÎÄÅ \verb+\includegraphics+, Ô.~Ë. +\ttt{mps} --- ÜÔÏ ÎÅ ÞÁÓÔØ ÉÍÅÎÉ \LaTeX-ÆÁÊÌÁ, ÚÁÐÏÌÎÑÅÍÁÑ ÐÏ-ÕÍÏÌÞÁÎÉÀ. +%%If you're using the \ttt{filenametemplate} method the \ttt{mps} file +%%extension should not be omitted in \verb+\includegraphics+ commands, +%%since \ttt{mps} is not part of \LaTeX's file name completion scheme, by +%%default. +åÓÌÉ ÒÁÓÛÉÒÅÎÉÅ \ttt{mps} ÐÒÉÓÕÔÓÔ×ÕÅÔ, ÔÏ \LaTeX\ ÏÂÒÁÂÁÔÙ×ÁÅÔ ÜÔÉ +ÆÁÊÌÙ ËÁË \ttt{eps}-ÆÁÊÌÙ, ÞÔÏ ÏÞÅ×ÉÄÎÏ Ñ×ÌÑÅÔÓÑ ËÏÒÒÅËÔÎÙÍ. +%%If the \ttt{mps} extension is present, \LaTeX\ handles those +%%files as \ttt{eps} files, which is obviously correct. +äÌÑ ÄÏÐÏÌÎÉÔÅÌØÎÏÊ ÉÎÆÏÒÍÁÃÉÉ ÓÍ. ÏÐÉÓÁÎÉÅ \verb+\DeclareGraphicsExtensions+% +\index{DeclareGraphicsExtensions?\texttt{\string\DeclareGraphicsExtensions}} +É \verb+\DeclareGraphicsRule+ × ÄÏËÕÍÅÎÔÁÃÉÉ ÐÁËÅÔÏ× \ttt{graphicx} É +\ttt{graphics}. +%%For more +%%information see the description of \verb+\DeclareGraphicsExtensions+% +%%\index{DeclareGraphicsExtensions?\texttt{\string\DeclareGraphicsExtensions}} +%%and \verb+\DeclareGraphicsRule+ in the documentation of packages +%%\ttt{graphicx} and \ttt{graphics}. + +\paragraph{pdf\TeX} +ðÏÌØÚÏ×ÁÔÅÌÉ plain pdf\TeX\ ÄÏÌÖÎÙ ÏÚÎÁËÏÍÉÔØÓÑ Ó ÏÔÄÅÌØÎÏÊ ÐÒÏÇÒÁÍÍÏÊ +\ttindex{mptopdf}, ËÏÔÏÒÕÀ ÍÏÖÎÏ ÎÁÊÔÉ × +\url{http://context.aanhet.net/mptopdf.htm}. +%%Users of plain pdf\TeX\ should refer to the standalone macros of the +%%\ttindex{mptopdf} bundle, that can be found at +%%\url{http://context.aanhet.net/mptopdf.htm}. + +\paragraph{Con\TeX t} +÷ Con\TeX t\index{ConTeXt?Con\TeX t} ÐÏÄÄÅÒÖËÁ MetaPost ÉÎÔÅÇÒÉÒÏ×ÁÎÁ × +ÑÄÒÏ. +%%In Con\TeX t\index{ConTeXt?Con\TeX t} support of MetaPost is integrated +%%in the kernel. +ïÔÄÅÌØÎÏ ÏÔ ×ÓÔÒÏÅÎÎÏÊ ÇÒÁÆÉËÉ (ÓÍ. ÒÕËÏ×ÏÄÓÔ×Ï ÐÏ MetaFun\index{MetaFun}) +ÍÏÖÎÏ ÔÁËÖÅ ×ÓÔÒÁÉ×ÁÔØ ÇÒÁÆÉËÕ ÉÚ×ÎÅ ËÏÍÁÎÄÏÊ +\verb+\externalfigure+% +\index{externalfigure?\texttt{\string\externalfigure}}. +%%Apart from inline graphics (see MetaFun\index{MetaFun} +%%manual), one can embed graphics explictely with the +%%\verb+\externalfigure+% +%%\index{externalfigure?\texttt{\string\externalfigure}} command. +úÁÎÕÍÅÒÏ×ÁÎÎÙÅ ÆÁÊÌÙ ÒÁÓÐÏÚÎÁÀÔÓÑ Á×ÔÏÍÁÔÉÞÅÓËÉ, ËÁË ÇÒÁÆÉËÁ Ó +\ttt{mps}-ÒÁÓÛÉÒÅÎÉÅÍ. +%%Numbered graphics are recognized automatically, as are graphics with the +%%\ttt{mps} suffix. +óÐÅÃÉÁÌØÎÙÅ Ó×ÏÊÓÔ×Á, ÔÁËÉÅ ËÁË ÚÁÔÅÎÅÎÉÅ, ÐÒÏÚÒÁÞÎÏÓÔØ, ×ËÌÀÞÅÎÉÅ ÒÉÓÕÎËÏ×, +Ã×ÅÔÏ×ÏÅ ÐÒÏÓÔÒÁÎÓÔ×Ï É ÐÏÄÏÂÎÙÅ ÏÂÒÁÂÁÔÙ×ÁÀÔÓÑ Á×ÔÏÍÁÔÉÞÅÓËÉ. +%%Special features like shading, transparency, image +%%inclusion, color spaces and such are handled automatically. +ðÒÁËÔÉÞÅÓËÉ ÐÏÌØÚÏ×ÁÔÅÌÉ Con\TeX t ÂÕÄÕÔ ×ÅÒÏÑÔÎÏ ÏÐÒÅÄÅÌÑÔØ ÇÒÁÆÉËÕ +MetaPost × ÄÏËÕÍÅÎÔÅ-ÉÓÈÏÄÎÉËÅ, ËÏÔÏÒÙÊ ÉÓÐÏÌØÚÕÅÔ ÎÅËÏÔÏÒÙÅ ÎÏ×ÛÅÓÔ×Á, +ÎÁÐÒÉÍÅÒ, ÂÏÌÅÅ ÅÓÔÅÓÔ×ÅÎÎÙÊ ÉÎÔÅÒÆÅÊÓ ÓÏ Ó×ÏÊÓÔ×ÁÍÉ ÄÏËÕÍÅÎÔÁ, ÐÏÄÄÅÒÖËÁ +ÛÒÉÆÔÏ× É Á×ÔÏÍÁÔÉÞÅÓËÁÑ ÏÂÒÁÂÏÔËÁ. +%%In practice +%%Con\TeX t users will probably define MetaPost graphics in the document +%%source which has some advantages, like a more natural interfacing with +%%document properties, font support, and automatic processing. +ðÏÄÄÅÒÖËÁ ×ËÌÀÞÅÎÉÊ MetaPost ÐÒÅÄÓÔÁ×ÌÅÎÁ × ×ÅÒÓÉÑÈ MkII É MkIV, ÎÏ +ÉÓÐÏÌØÚÕÅÍÙÅ ÍÅÔÏÄÙ ÓÌÅÇËÁ ÒÁÚÌÉÞÁÀÔÓÑ. +%%Support +%%for MetaPost inclusion is present in the versions MkII as well as MkIV, +%%but the used methods are slightly different. +âÕÄÕÝÉÅ ×ÅÒÓÉÉ MkIV ÂÕÄÕÔ ÐÏÄÄÅÒÖÉ×ÁÔØ ÄÁÖÅ ÂÏÌÅÅ ÔÅÓÎÕÀ ÉÎÔÅÇÒÁÃÉÀ. +%%Future versions of MkIV +%%will support an even more tight integration. + +\paragraph{troff} +ôÁËÖÅ ×ÏÚÍÏÖÎÏ ×ËÌÀÞÁÔØ ×Ù×ÏÄ MetaPost × GNU +\emph{troff}-ÄÏËÕÍÅÎÔ. +%%It is also possible to include MetaPost output in a GNU \emph{troff} +%%document. +íÁËÒÏÐÁËÅÔ \ttt{-mpspic}\index{mpspic?\texttt{-mpspic}} ÏÐÒÅÄÅÌÑÅÔ ËÏÍÁÎÄÕ \verb|.PSPIC|\index{PSPIC?\texttt{.PSPIC}}, ËÏÔÏÒÁÑ ×ËÌÀÞÁÅÔ EPS-ÆÁÊÌ. +%%The \ttt{-mpspic}\index{mpspic?\texttt{-mpspic}} macro +%%package defines a command \verb|.PSPIC|\index{PSPIC?\texttt{.PSPIC}} +%%that includes an encapsulated PostScript file. +îÁÐÒÉÍÅÒ, ËÏÍÁÎÄÁ \emph{troff} +%%For instance, the \emph{troff} command +$$ \hbox{\verb|.PSPIC fig.1|} $$ +×ËÌÀÞÁÅÔ \ttt{fig.1}, ÉÓÐÏÌØÚÕÑ ÚÁÄÁÎÎÙÅ × ÆÁÊÌÅ ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÏÊ ÅÓÔÅÓÔ×ÅÎÎÙÅ ×ÙÓÏÔÕ É ÛÉÒÉÎÕ ÏÂÒÁÚÁ. +%%includes \ttt{fig.1}, using the natural height and width of the +%%image as given in the file's bounding box. + +\subsection{ûÁÂÌÏÎÙ ÉÍÅÎ ÆÁÊÌÏ×} +%%\subsection{File name templates} +\suppressfloats[t] + +MetaPost ÐÏÄÄÅÒÖÉ×ÁÅÔ ÛÁÂÌÏÎÙ ÄÌÑ ×ÙÈÏÄÎÙÈ ÆÁÊÌÏ×. +%%MetaPost has support for output file name templates. +üÔÉ ÛÁÂÌÏÎÙ ÉÓÐÏÌØÚÕÀÔ ÓÔÉÌØ \ttt{printf} escape-ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔÅÊ +É ÐÅÒÅÓÞÉÔÙ×ÁÀÔÓÑ ÐÅÒÅÄ ÔÅÍ, ËÁË ÒÉÓÕÎÏË ÚÁÐÉÓÙ×ÁÅÔÓÑ ÎÁ ÄÉÓË +%%These templates +%%use \ttt{printf}-style escape sequences and are re-evaluated before +%%each figure is written to disk. + +úÄÅÓØ ÉÓÐÏÌØÚÕÅÔÓÑ ËÏÍÁÎÄÁ \ttt{filenametemplate}% +\index{filenametemplate?\texttt{filenametemplate}}\label{Dfilenametemplate}, +ËÏÔÏÒÁÑ ×ÏÓÐÒÉÎÉÍÁÅÔ ÓÔÒÏËÕ-ÁÒÇÕÍÅÎÔ. +%%The command to use is \ttt{filenametemplate}% +%%\index{filenametemplate?\texttt{filenametemplate}}\label{Dfilenametemplate}, +%%and it accepts a string as argument. +åÅ ÎÅÓÌÏÖÎÙÊ ÓÉÎÔÁËÓÉÓ: +%%The syntax is as simple as: + +\begin{center}\begin{tabular}{l} +\verb|filenametemplate "%j-%3c.mps";|\\ +\verb|beginfig(1);|\\ +\verb| draw p;|\\ +\verb|endfig;| +\end{tabular}\end{center} + +åÓÌÉ ÉÓÈÏÄÎÙÊ ÆÁÊÌ ÓÏÈÒÁÎÑÌÓÑ ËÁË \ttt{fig.mp}, ÔÏ ÂÕÄÅÔ ÓÏÚÄÁÎ ×ÙÈÏÄÎÏÊ ÆÁÊÌ +\ttt{fig-001.mps} ×ÍÅÓÔÏ \ttt{fig.1}. +%%If the file is saved as \ttt{fig.mp}, then this will create the output +%%file \ttt{fig-001.mps} instead of \ttt{fig.1}. +íÁÌÅÎØËÏÅ ÍÎÏÖÅÓÔ×Ï ×ÏÚÍÏÖÎÙÈ escape-ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔÅÊ ÓÍ. × +ÔÁÂÌÉÃÅ~\ref{tab:fntmpl}. +%%A small set of escape +%%sequences are possible, see table~\ref{tab:fntmpl} for details. + +\def\d{$\langle$0-9$\rangle$} + +\begin{table} +\centering +\begin{tabular}{|>{\ttfamily}l|l|} +\hline +\multicolumn1{|c|}{Escape-ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ} & \multicolumn1{c|}{óÍÙÓÌ}\\\hline +%%\multicolumn1{|c|}{Escape sequence} & \multicolumn1{c|}{Meaning}\\\hline +\%\% & úÎÁË ÐÒÏÃÅÎÔÁ \\ +%%\%\% & A percent sign \\ +\%\,j & éÍÑ ÔÅËÕÝÅÊ ÒÁÂÏÔÙ\\ +%%\%\,j & The current jobname\\ +\%\d c & úÎÁÞÅÎÉÅ {\tt charcode}\\ +%%\%\d c & The charcode value\\ +\%\d y & ôÅËÕÝÉÊ ÇÏÄ\\ +%%\%\d y & The current year\\ +\%\d m & îÏÍÅÒ ÍÅÓÑÃÁ\\ +%%\%\d m & The numeric month\\ +\%\d d & äÅÎØ ÍÅÓÑÃÁ\\ +%%\%\d d & The day of the month\\ +\%\d H & þÁÓ\\ +%%\%\d H & The hour\\ +\%\d M & íÉÎÕÔÁ\\ +%%\%\d M & The minute\\ +\hline +\end{tabular} +\caption{òÁÚÒÅÛÅÎÎÙÅ escape-ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔÉ ÄÌÑ \ttt{filenametemplate}} +%%\caption{Allowed escape sequences for \ttt{filenametemplate}} +\label{tab:fntmpl} +\end{table} + +ðÒÉÍÉÔÉ× \ttt{filenametemplate} ÍÏÖÅÔ ÂÙÔØ ÔÁËÖÅ ÐÏÌÅÚÎÙÍ ÄÌÑ ÉÍÅÎÏ×ÁÎÉÑ +ÇÒÁÆÉÞÅÓËÉÈ ÆÁÊÌÏ× ÉÎÄÉ×ÉÄÕÁÌØÎÏ É ÅÝÅ ÄÌÑ ÈÒÁÎÅÎÉÑ ×ÓÅÈ +MetaPost-ÉÓÈÏÄÎÉËÏ× × ÏÄÎÏÍ ÆÁÊÌÅ. +%%The \ttt{filenametemplate} primitive can also be helpful for naming +%%graphic files individually, yet keeping all MetaPost sources in one file. +îÁÐÒÉÍÅÒ, ÓÏÂÅÒÅÍ ÉÓÈÏÄÎÉËÉ ÒÁÚÎÙÈ ÄÉÁÇÒÁÍÍ × ÏÄÉÎ ÆÁÊÌ \ttt{fig.mp} +%%E.\,g., collecting different diagram sources in a file \ttt{fig.mp} +$$ +\begin{verbatim} +filenametemplate "fig-quality.mps"; +beginfig(1); + ... +endfig; + +filenametemplate "fig-cost-vs-productivity.mps"; +beginfig(2); + ... +endfig; +\end{verbatim} +$$ +--- ÍÏÖÅÔ ÏËÁÚÁÔØÓÑ ÐÒÏÝÅ ×ÓÐÏÍÎÉÔØ ÐÒÁ×ÉÌØÎÏÅ ÉÍÑ ÄÉÁÇÒÁÍÍÙ × ÄÏËÕÍÅÎÔÅ +\TeX, ÞÅÍ ÎÕÍÅÒÏ×ÁÎÎÏÅ ÉÍÑ ÆÁÊÌÁ. +%%it might be easier to recall the correct diagram names in a +%%\TeX\ document than with numbered file names. +úÁÍÅÔØÔÅ, ÞÔÏ ÁÒÇÕÍÅÎÔ \ttt{beginfig} ÎÅ ÉÓÐÏÌØÚÕÅÔÓÑ ÐÒÉ ÏÔÓÕÔÓÔ×ÉÉ +ÏÂÒÁÚÃÁ \ttt{\%c} × ÓÔÒÏËÅ ÛÁÂÌÏÎÁ ÉÍÅÎÉ ÆÁÊÌÁ. +%%Note, the argument to +%%\ttt{beginfig} is not relevant as long as there's no \ttt{\%c} pattern +%%in the file name template string. + +äÌÑ ÏÂÅÓÐÅÞÅÎÉÑ ÓÏ×ÍÅÓÔÉÍÏÓÔÉ ÓÏ ÓÔÁÒÙÍÉ ÆÁÊÌÁÍÉ ÎÁÞÁÌØÎÏÅ ÚÎÁÞÅÎÉÅ +\ttt{filenametemplate} ÕÓÔÁÎÁ×ÌÉ×ÁÅÔÓÑ × \verb|%j.%c|. +%%To ensure compatibility with older files, the default value of +%%\ttt{filenametemplate} is \verb|%j.%c|. +åÓÌÉ ×Ù ÐÒÉÓ×ÏÉÔÅ ÐÕÓÔÕÀ ÓÔÒÏËÕ, ÔÏ ÜÔÏ ÂÕÄÅÔ ÏÚÎÁÞÁÔØ ×ÏÚ×ÒÁÔ Ë +ÎÁÞÁÌØÎÏÍÕ ÚÎÁÞÅÎÉÀ. +%%If you assign an empty string, it will revert to that default. + +\section{ëÒÉ×ÙÅ} +%%\section{Curves} +\label{curves} + +MetaPost ÓÏ×ÅÒÛÅÎÎÏ ÓÞÁÓÔÌÉ× ÐÒÉ ÒÉÓÏ×ÁÎÉÉ ËÁË ËÒÉ×ÙÈ, ÔÁË É ÐÒÑÍÙÈ ÌÉÎÉÊ. +%%MetaPost is perfectly happy to draw curved lines as well as straight ones. +ëÏÍÁÎÄÁ \verb|draw| Ó ÒÁÚÄÅÌÅÎÎÙÍÉ +\verb|..|\index{..?\texttt{..}} ÁÒÇÕÍÅÎÔÁÍÉ-ÔÏÞËÁÍÉ ÒÉÓÕÅÔ ÐÌÁ×ÎÕÀ +ËÒÉ×ÕÀ ÞÅÒÅÚ ÜÔÉ ÔÏÞËÉ. +%%A \verb|draw| statement with the points separated by +%%\verb|..|\index{..?\texttt{..}} draws a smooth curve through the points. +îÁÐÒÉÍÅÒ, ÐÏÓÍÏÔÒÉÔÅ ÎÁ ÒÅÚÕÌØÔÁÔ +%%For example consider the result of +$$ \hbox{\verb|draw z0..z1..z2..z3..z4|} $$ +ÐÏÓÌÅ ÏÐÒÅÄÅÌÅÎÉÑ ÐÑÔÉ ÔÏÞÅË ÔÁËÉÍ ÏÂÒÁÚÏÍ: +%%after defining five points as follows: +$$\begin{verbatim} +z0 = (0,0); z1 = (60,40); +z2 = (40,90); z3 = (10,70); +z4 = (30,50); +\end{verbatim} +$$ +òÉÓ.~\ref{fig2} ÐÏËÁÚÙ×ÁÅÔ ËÒÉ×ÕÀ ÞÅÒÅÚ ÔÏÞËÉ, ÐÏÍÅÞÅÎÎÙÅ ÏÔ \verb|z0| +ÄÏ \verb|z4| +%%Figure~\ref{fig2} shows the curve with points \verb|z0| through \verb|z4| +%%labeled. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-3} +$$ +\caption[ëÒÉ×ÁÑ ÞÅÒÅÚ ÔÏÞËÉ 0, 1, 2, 3 É 4] + {òÅÚÕÌØÔÁÔ {\tt draw z0..z1..z2..z3..z4}} +%%\caption[A curve through points 0, 1, 2, 3, and 4] +% {The result of {\tt draw z0..z1..z2..z3..z4}} +\label{fig2} +\end{figure} + +åÓÔØ ÍÎÏÇÏ ÄÒÕÇÉÈ ÓÐÏÓÏÂÏ× ÎÁÒÉÓÏ×ÁÔØ ÐÕÔØ ÞÅÒÅÚ ÔÅ ÖÅ ÓÁÍÙÅ ÐÑÔØ ÔÏÞÅË. +%%There are many other ways to draw a curved path through the same five +%%points. +äÌÑ ÐÏÌÕÞÅÎÉÑ ÇÌÁÄËÏÊ ÚÁÍËÎÕÔÏÊ ËÒÉ×ÏÊ ÓÏÅÄÉÎÉÔÅ \verb|z4| Ó ÎÁÞÁÌÏÍ +ÄÏÂÁ×ÌÅÎÉÅÍ \verb|..cycle|\index{cycle?\texttt{cycle}} Ë ËÏÍÁÎÄÅ +\verb|draw| ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig3}a. +%%To make a smooth closed curve, connect \verb|z4| back to the +%%beginning by appending \verb|..cycle|\index{cycle?\texttt{cycle}} to the +%%\verb|draw| statement as shown in Figure~\ref{fig3}a. +ôÁËÖÅ ×ÏÚÍÏÖÎÏ × ÏÄÎÏÊ ËÏÍÁÎÄÅ \verb|draw| ÓÍÅÛÉ×ÁÔØ ËÒÉ×ÙÅ É ÐÒÑÍÙÅ +ÌÉÎÉÉ ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig3}b. +%%It is also +%%possible in a single \verb|draw| statement to mix curves and straight +%%lines as shown in Figure~\ref{fig3}b. +ðÒÏÓÔÏ ÉÓÐÏÌØÚÕÊÔÅ \verb|--| ÔÁÍ, ÇÄÅ ×Ù ÈÏÔÉÔÅ ÐÒÑÍÙÅ ÌÉÎÉÉ, É \verb|..| +ÔÁÍ, ÇÄÅ ×Ù ÈÏÔÉÔÅ ËÒÉ×ÙÅ. +%%Just use \verb|--| where you want +%%straight lines and \verb|..| where you want curves. +ôÁËÉÍ ÏÂÒÁÚÏÍ, +%%Thus +$$ \hbox{\verb|draw z0..z1..z2..z3--z4--cycle|} $$ +ÐÒÏÉÚ×ÅÄÅÔ ËÒÉ×ÕÀ ÞÅÒÅÚ ÔÏÞËÉ 0,~1, 2 É~3, ÚÁÔÅÍ ÌÏÍÁÎÕÀ ÌÉÎÉÀ ÉÚ ÔÏÞËÉ~3 +× ÔÏÞËÕ~4 É ÏÂÒÁÔÎÏ × ÔÏÞËÕ~0. +%%produces a curve through points 0,~1, 2, and~3, then a polygonal line from +%%point~3 to point~4 and back to point~0. +òÅÚÕÌØÔÁÔ ÂÕÄÅÔ ÔÏÞÎÏ ÔÁËÉÍ ÖÅ ËÁË ÐÏÓÌÅ Ä×ÕÈ ËÏÍÁÎÄ ÒÉÓÏ×ÁÎÉÑ +%%The result is essentially the same +%%as having two draw statements +\begin{eqnarray*} + \hbox{\verb|draw z0..z1..z2..z3|}\\ +\noalign{\hbox{É}} +%%\noalign{\hbox{and}} + \hbox{\verb|draw z3--z4--z0|} +\end{eqnarray*} + +\begin{figure}[htp] +$$ {\includegraphics{manfig-ru-104} \atop (a)} + \qquad {\includegraphics{manfig-ru-204} \atop (b)} +$$ +\caption[úÁÍËÎÕÔÁÑ ËÒÉ×ÁÑ ÞÅÒÅÚ ÐÑÔØ ÔÏÞÅË] + {(a)~òÅÚÕÌØÔÁÔ {\tt draw z0..\linebreak[0]z1..\linebreak[0]% + z2..\linebreak[0]z3..\linebreak[0]z4..\linebreak[0]cycle}; + (b)~òÅÚÕÌØÔÁÔ {\tt draw z0..\linebreak[0]z1..\linebreak[0]% + z2..\linebreak[0]z3--\linebreak[0]z4--\linebreak[0]cycle}.} +%%\caption[Closed curves through five points] +%% {(a)~The result of {\tt draw z0..\linebreak[0]z1..\linebreak[0]% +%% z2..\linebreak[0]z3..\linebreak[0]z4..\linebreak[0]cycle}; +%% (b)~the result of {\tt draw z0..\linebreak[0]z1..\linebreak[0]% +%% z2..\linebreak[0]z3--\linebreak[0]z4--\linebreak[0]cycle}.} +\label{fig3} +\end{figure} + +\subsection{ëÕÂÉÞÅÓËÉÅ ËÒÉ×ÙÅ âÅÚØÅ} +%%\subsection{B\'ezier Cubic Curves} + +ëÏÇÄÁ MetaPost ÐÒÏÓÑÔ ÎÁÒÉÓÏ×ÁÔØ ÇÌÁÄËÕÀ ËÒÉ×ÕÀ ÞÅÒÅÚ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ +ÔÏÞÅË, ÏÎ ËÏÎÓÔÒÕÉÒÕÅÔ ËÕÓÏÞÎÕÀ ËÕÂÉÞÅÓËÕÀ ËÒÉ×ÕÀ Ó ÎÅÐÒÅÒÙ×ÎÙÍ ÕËÌÏÎÏÍ É +Ó ÐÒÉÂÌÉÚÉÔÅÌØÎÏ ÎÅÐÒÅÒÙ×ÎÏÊ ËÒÉ×ÉÚÎÏÊ\index{ËÒÉ×ÉÚÎÁ}. +%%When MetaPost is asked to draw a smooth curve through a sequence of +%%points, it constructs a piecewise cubic curve with continuous slope and +%%approximately continuous curvature\index{curvature}. +üÔÏ ÚÎÁÞÉÔ, ÞÔÏ ÓÐÅÃÉÆÉËÁÃÉÑ ÐÕÔÉ ÔÁËÁÑ ËÁË +%%This means that a +%%path specification such as +$$ \hbox{\verb|z0..z1..z2..z3..z4..z5|} $$ +ÄÁÅÔ × ÒÅÚÕÌØÔÁÔÅ ËÒÉ×ÕÀ, ÞÔÏ ÍÏÖÅÔ ÂÙÔØ ÏÐÒÅÄÅÌÅÎÁ +ÐÁÒÁÍÅÔÒÉÞÅÓËÉ\index{ÐÁÒÁÍÅÔÒÉÚÁÃÉÑ} ËÁË $(X(t),Y(t))$ ÄÌÑ +$0\leqslant t\leqslant5$, ÇÄÅ $X(t)$ É $Y(t)$ --- ËÕÓÏÞÎÙÅ ËÕÂÉÞÅÓËÉÅ ÆÕÎËÃÉÉ. +%%results in a curve that can be defined parametrically\index{parameterization} +%%as $(X(t),Y(t))$ for +%%$0\le t\le5$, where $X(t)$ and $Y(t)$ are piecewise cubic functions. +ôÁËÉÍ ÏÂÒÁÚÏÍ ÓÕÝÅÓÔ×ÕÀÔ ÒÁÚÌÉÞÎÙÅ ÐÁÒÙ ËÕÂÉÞÅÓËÉÈ ÆÕÎËÃÉÊ ÄÌÑ ËÁÖÄÏÇÏ ÏÇÒÁÎÉÞÅÎÎÏÇÏ +ÃÅÌÙÍÉ ÞÉÓÌÁÍÉ ÉÎÔÅÒ×ÁÌÁ ÄÌÑ $t$. +%%That is, +%%there is a different pair of cubic functions for each integer-bounded +%%$t$-interval. +åÓÌÉ ${\tt z0}=(x_0,y_0)$, ${\tt z1}=(x_1,y_1)$, +${\tt z2}=(x_2,y_2)$, \ldots, ÔÏ MetaPost ×ÙÂÉÒÁÅÔ +ËÏÎÔÒÏÌØÎÙÅ\index{ÕÐÒÁ×ÌÑÀÝÉÅ ÔÏÞËÉ} ÔÏÞËÉ âÅÚØÅ +%%If ${\tt z0}=(x_0,y_0)$, ${\tt z1}=(x_1,y_1)$, +%%${\tt z2}=(x_2,y_2)$, \ldots, MetaPost selects +%%B\'ezier control\index{control points} points +$(x_0^+,y_0^+)$, $(x_1^-,y_1^-)$, $(x_1^+,y_1^+)$, \ldots, +ÇÄÅ +%%where +\begin{eqnarray*} + X(t+i) &=& (1-t)^3x_i + 3t(1-t)^2x_i^+ + 3t^2(1-t)x_{i+1}^- + t^3x_{i+1},\\ + Y(t+i) &=& (1-t)^3y_i + 3t(1-t)^2y_i^+ + 3t^2(1-t)y_{i+1}^- + t^3y_{i+1} +\end{eqnarray*} +ÄÌÑ +%%for +$0\le t\le1$. +ôÏÞÎÙÅ ÐÒÁ×ÉÌÁ ÄÌÑ ×ÙÂÏÒÁ ËÏÎÔÒÏÌØÎÙÈ ÔÏÞÅË âÅÚØÅ ÐÒÉ×ÅÄÅÎÙ × \cite{ho:splin} +É × {\sl \MF book\/}~\cite{kn:c}. +%%The precise rules for choosing the B\'ezier control points +%%are described in \cite{ho:splin} and in {\sl The \MF book\/}~\cite{kn:c}. + +äÌÑ ÔÏÇÏ, ÞÔÏÂÙ ÐÕÔØ ÉÍÅÌ ÎÅÐÒÅÒÙ×ÎÙÊ ÕËÌÏÎ × $(x_i,y_i)$ ×ÈÏÄÑÝÅÅ É +ÉÓÈÏÄÑÝÅÅ ÎÁÐÒÁ×ÌÅÎÉÑ × $(X(i),Y(i))$ ÄÏÌÖÎÙ ÓÏÏÔ×ÅÔÓÔ×Ï×ÁÔØ. +%%In order for the path to have a continuous slope at $(x_i,y_i)$, the incoming +%%and outgoing directions at $(X(i),Y(i))$ must match. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ×ÅËÔÏÒÁ +%%Thus the vectors +$$ (x_i-x_i^-,\,y_i-y_i^-) \qquad +\hbox{É} +%%\hbox{and} + \qquad (x_i^+-x_i,\,y_i^+-y_i) +$$ +ÄÏÌÖÎÙ ÉÍÅÔØ ÏÄÉÎÁËÏ×ÏÅ ÎÁÐÒÁ×ÌÅÎÉÅ, Ô.~Å. $(x_i,y_i)$ ÄÏÌÖÎÁ ÂÙÔØ ÎÁ +ÏÔÒÅÚËÅ ÌÉÎÉÉ ÍÅÖÄÕ $(x_i^-,y_i^-)$ É $(x_i^+,y_i^+)$. +%%must have the same direction; i.e., $(x_i,y_i)$ must be on the line segment +%%between $(x_i^-,y_i^-)$ and $(x_i^+,y_i^+)$. +üÔÁ ÓÉÔÕÁÃÉÑ ÉÌÌÀÓÔÒÉÒÕÅÔÓÑ ÎÁ ÒÉÓ.~\ref{fig4}, ÇÄÅ ËÏÎÔÒÏÌØÎÙÅ ÔÏÞËÉ âÅÚØÅ, +×ÙÂÉÒÁÅÍÙÅ MetaPost, ÓÏÅÄÉÎÅÎÙ ÐÕÎËÔÉÒÎÙÍÉ ÌÉÎÉÑÍÉ. +%%This situation is illustrated +%%in Figure~\ref{fig4} where the B\'ezier control points selected by MetaPost +%%are connected by dashed lines. +äÌÑ ÔÅÈ, ËÔÏ ÚÎÁËÏÍ Ó ÉÎÔÅÒÅÓÎÙÍÉ Ó×ÏÊÓÔ×ÁÍÉ ÔÁËÏÊ ËÏÎÓÔÒÕËÃÉÉ, MetaPost +ÐÏÚ×ÏÌÑÅÔ ÓÐÅÃÉÆÉÃÉÒÏ×ÁÔØ ËÏÎÔÒÏÌØÎÙÅ ÔÏÞËÉ ÎÁÐÒÑÍÕÀ × ÓÌÅÄÕÀÝÅÍ +ÆÏÒÍÁÔÅ: \index{controls?\texttt{controls}} +%%For those who are familiar with the interesting +%%properties of this construction, MetaPost allows the control points to be +%%specified directly in the following format:\index{controls?\texttt{controls}} +$$ \begin{verbatim} +draw (0,0)..controls (26.8,-1.8) and (51.4,14.6) + ..(60,40)..controls (67.1,61.0) and (59.8,84.6) + ..(40,90)..controls (25.4,94.0) and (10.5,84.5) + ..(10,70)..controls ( 9.6,58.8) and (18.8,49.6) + ..(30,50); +\end{verbatim} +$$ + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-5} +$$ +\caption[ëÒÉ×ÁÑ É ÕÐÒÁ×ÌÑÀÝÁÑ ÌÏÍÁÎÁÑ] + {òÅÚÕÌØÔÁÔ {\tt draw z0..z1..z2..z3..z4} Ó Á×ÔÏÍÁÔÉÞÅÓËÉ + ×ÙÂÉÒÁÅÍÏÊ ÕÐÒÁ×ÌÑÀÝÅÊ ÌÏÍÁÎÏÊ âÅÚØÅ, ÉÌÌÀÓÔÒÉÒÕÅÍÏÊ + ÐÕÎËÔÉÒÎÙÍÉ ÌÉÎÉÑÍÉ.} +%%\caption[A curve and the control polygon] +%% {The result of {\tt draw z0..z1..z2..z3..z4} with the +%% automatically-selected B\'ezier control polygon illustrated by dashed +%% lines.} +\label{fig4} +\end{figure} + +\subsection{óÐÅÃÉÆÉËÁÃÉÑ ÎÁÐÒÁ×ÌÅÎÉÑ, ÎÁÐÒÑÖÅÎÉÑ É ÉÚÇÉÂÁ} +%%\subsection{Specifying Direction, Tension, and Curl} +\label{tenscurl} + +MetaPost ÏÂÅÓÐÅÞÉ×ÁÅÔ ÍÎÏÇÏ ÓÐÏÓÏÂÏ× ÕÐÒÁ×ÌÅÎÉÑ ÐÏ×ÅÄÅÎÉÅÍ ÐÕÔÉ ËÒÉ×ÏÊ +ÂÅÚ ÄÅÊÓÔ×ÉÔÅÌØÎÏÇÏ ÕËÁÚÁÎÉÑ ËÏÎÔÒÏÌØÎÙÈ ÔÏÞÅË. +%%MetaPost provides many ways of controlling the behavior of a curved path +%%without actually specifying the control points. +îÁÐÒÉÍÅÒ, ÎÅËÏÔÏÒÙÅ ÔÏÞËÉ ÎÁ ÐÕÔÉ ÍÏÇÕÔ ÂÙÔØ ×ÙÂÒÁÎÙ ËÁË ×ÅÒÔÉËÁÌØÎÙÊ ÉÌÉ +ÇÏÒÉÚÏÎÔÁÌØÎÙÊ ÜËÓÔÒÅÍÕÍÙ. +%%For instance, some +%%points on the path may be selected as vertical or horizontal extrema. +åÓÌÉ \verb|z1| ÓÌÅÄÕÅÔ ÂÙÔØ ÇÏÒÉÚÏÎÔÁÌØÎÙÍ ÜËÓÔÒÅÍÕÍÏÍ, Á \verb|z2| --- +×ÅÒÔÉËÁÌØÎÙÍ, ÔÏ ×Ù ÍÏÖÅÔÅ ÕËÁÚÁÔØ, ÞÔÏ $(X(t),Y(t))$ ÄÏÌÖÎÁ ÉÄÔÉ ××ÅÒÈ +× \verb|z1| É ×ÌÅ×Ï × \verb|z2|: +%%If \verb|z1| is to be a horizontal extreme and \verb|z2| is to be a +%%vertical extreme, you can specify that $(X(t),Y(t))$ should go upward at +%%\verb|z1| and to the left at \verb|z2|: +$$ \hbox{\verb|draw z0..z1{up}..z2{left}..z3..z4;|} $$ +ëÁÒÔÉÎËÁ-ÒÅÚÕÌØÔÁÔ, ÐÏËÁÚÁÎÎÁÑ ÎÁ ÒÉÓ.~\ref{fig5}, ÉÍÅÅÔ ÖÅÌÁÅÍÙÅ +×ÅÒÔÉËÁÌØÎÏÅ É ÇÏÒÉÚÏÎÔÁÌØÎÏÅ ÎÁÐÒÁ×ÌÅÎÉÑ × \verb|z1| É \verb|z2|, ÎÏ +ÏÎÁ ÎÅ ×ÙÇÌÑÄÉÔ ÔÁËÏÊ ÐÌÁ×ÎÏÊ, ËÁË ËÒÉ×ÁÑ ÎÁ ÒÉÓ.~\ref{fig2}. +%%The resulting shown in Figure~\ref{fig5} has the desired vertical and +%%horizontal directions at \verb|z1| and \verb|z2|, but it does not look +%%as smooth as the curve in Figure~\ref{fig2}. +üÔÏ ÏÂÕÓÌÏ×ÌÅÎÏ ÂÏÌØÛÉÍ ÒÁÚÒÙ×ÏÍ × ×ÅÌÉÞÉÎÅ ËÒÉ×ÉÚÎÙ \index{ËÒÉ×ÉÚÎÁ} +× \verb|z1|. +%%The reason is the large +%%discontinuity in curvature\index{curvature} at \verb|z1|. +åÓÌÉ Ñ×ÎÏ ÎÅ ÕËÁÚÁÔØ ÎÁÐÒÁ×ÌÅÎÉÅ × \verb|z1|, ÔÏ MetaPost-ÉÎÔÅÒÐÒÅÔÁÔÏÒ +×ÙÂÅÒÅÔ ÎÁÐÒÁ×ÌÅÎÉÅ ÔÁËÉÍ, ÞÔÏÂÙ ËÒÉ×ÉÚÎÁ ÎÁÄ \verb|z1| ÂÙÌÁ ÐÏÞÔÉ +ÔÁËÏÊ ÖÅ ËÁË É ËÒÉ×ÉÚÎÁ ÐÏÄ ÜÔÏÊ ÔÏÞËÏÊ. +%%If it were +%%not for the specified direction at \verb|z1|, the MetaPost interpreter +%%would have chosen a direction designed to make the curvature above +%%\verb|z1| almost the same as the curvature below that point. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-6} +$$ +\caption[ëÒÉ×ÁÑ É ÕÐÒÁ×ÌÑÀÝÁÑ ÌÏÍÁÎÁÑ] + {òÅÚÕÌØÔÁÔ {\tt draw z0..z1\char`\{up\char`\}..z2\char`\{left\char`\}% + ..z3..z4}.} +%%\caption[A curve and the control polygon] +%% {The result of {\tt draw z0..z1\char`\{up\char`\}..z2\char`\{left\char`\}% +%% ..z3..z4}.} +\label{fig5} +\end{figure} + +ëÁË ÍÏÖÅÔ ×ÙÂÏÒ ÎÁÐÒÁ×ÌÅÎÉÊ × ÄÁÎÎÙÈ ÔÏÞËÁÈ ÎÁ ËÒÉ×ÏÊ ÏÐÒÅÄÅÌÑÔØ ÂÕÄÅÔ ÌÉ +ËÒÉ×ÉÚÎÁ ÎÅÐÒÅÒÙ×ÎÏÊ? +%%How can the choice of directions at given points on a curve determine whether +%%the curvature will be continuous? +ïÔ×ÅÔ × ÔÏÍ, ÞÔÏ ËÒÉ×ÙÅ, ÉÓÐÏÌØÚÕÅÍÙÅ × MetaPost, ÐÒÉÛÌÉ ÉÚ ÓÅÍÅÊÓÔ×Á, ÇÄÅ +ÐÕÔØ ÏÐÒÅÄÅÌÑÅÔÓÑ Ó×ÏÉÍÉ ËÏÎÃÁÍÉ É ÎÁÐÒÁ×ÌÅÎÉÑÍÉ ÔÁÍ. +%%The reason is that curves used in MetaPost +%%come from a family where a path is determined by its endpoints and the +%%directions there. +òÉÓÕÎËÉ \ref{fig6} É~\ref{fig7} ÄÁÀÔ ÈÏÒÏÛÕÀ ÉÄÅÀ Ï ÔÏÍ, ÎÁ ÞÔÏ ÐÏÈÏÖÅ +ÜÔÏ ÓÅÍÅÊÓÔ×Ï ËÒÉ×ÙÈ. +%%Figures \ref{fig6} and~\ref{fig7} give a good idea of what +%%this family of curves is like. + +\begin{figure}[htp] +$$ \mathcenter{\includegraphics{manfig-ru-7}} \quad +\begin{verbatim} +beginfig(7) +for a=0 upto 9: + draw (0,0){dir 45}..{dir -10a}(6cm,0); +endfor +endfig; +\end{verbatim} +$$ +\caption{óÅÍÅÊÓÔ×Ï ËÒÉ×ÙÈ É ÉÎÓÔÒÕËÃÉÉ MetaPost ÄÌÑ ÅÇÏ ÇÅÎÅÒÁÃÉÉ} +%%\caption{A curve family and the MetaPost instructions for generating it} +\label{fig6} +\end{figure} + +\begin{figure}[htp] +$$ \mathcenter{\includegraphics{manfig-ru-8}} \quad +\begin{verbatim} +beginfig(8) +for a=0 upto 7: + draw (0,0){dir 45}..{dir 10a}(6cm,0); +endfor +endfig; +\end{verbatim} +$$ +\caption{äÒÕÇÏÅ ÓÅÍÅÊÓÔ×Ï ËÒÉ×ÙÈ Ó ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÍÉ ÉÎÓÔÒÕËÃÉÑÍÉ MetaPost} +%%\caption{Another curve family with the corresponding MetaPost instructions} +\label{fig7} +\end{figure} + +òÉÓÕÎËÉ \ref{fig6} É~\ref{fig7} ÉÌÌÀÓÔÒÉÒÕÀÔ ÎÏ×ÙÅ ×ÏÚÍÏÖÎÏÓÔÉ MetaPost. +%%Figures \ref{fig6} and~\ref{fig7} illustrate a few new MetaPost +%%features. +ðÅÒ×ÁÑ --- ÜÔÏ ÏÐÅÒÁÔÏÒ {\tt dir}\index{dir?\texttt{dir}}\label{Ddirop}, +ËÏÔÏÒÙÊ ÐÏ ÕÇÌÕ × ÇÒÁÄÕÓÁÈ ÇÅÎÅÒÉÒÕÅÔ ÅÄÉÎÉÞÎÙÊ ×ÅËÔÏÒ × ÜÔÏÍ ÎÁÐÒÁ×ÌÅÎÉÉ. +%%The first is the {\tt +%%dir}\index{dir?\texttt{dir}}\label{Ddirop} operator that takes an angle +%%in degrees and generates a unit vector in that direction. +ôÁËÉÍ ÏÂÒÁÚÏÍ, \verb|dir 0| ÜË×É×ÁÌÅÎÔÅÎ {\tt +right}\index{right?\texttt{right}}\label{Dright} É \verb|dir 90| +ÜË×É×ÁÌÅÎÔÅÎ {\tt up}\index{up?\texttt{up}}\label{Dup}. +%%Thus \verb|dir 0| is equivalent to {\tt +%%right}\index{right?\texttt{right}}\label{Dright} and \verb|dir 90| is +%%equivalent to {\tt up}\index{up?\texttt{up}}\label{Dup}. +åÓÔØ ÔÁËÖÅ ÇÏÔÏ×ÙÅ ×ÅËÔÏÒÁ ÎÁÐÒÁ×ÌÅÎÉÊ {\tt left}\index{left?\texttt{left}}\label{Dleft} É {\tt +down}\index{down?\texttt{down}}\label{Ddown} ÄÌÑ {\tt dir 180} É {\tt +dir 270}. +%%There are also predefined direction vectors {\tt +%%left}\index{left?\texttt{left}}\label{Dleft} and {\tt +%%down}\index{down?\texttt{down}}\label{Ddown} for {\tt dir 180} and {\tt +%%dir 270}. + +÷ÅËÔÏÒÁ ÎÁÐÒÁ×ÌÅÎÉÊ, ÚÁÄÁÎÎÙÅ × \verb|{}|, ÍÏÇÕÔ ÂÙÔØ ÌÀÂÏÊ ÄÌÉÎÙ É ÏÎÉ +ÍÏÇÕÔ ËÁË ×ÈÏÄÉÔØ × ÔÏÞËÕ, ÔÁË É ×ÙÈÏÄÉÔØ ÉÚ ÎÅÅ. +%%The direction +%%vectors given in \verb|{}| can be of any length, and they can come before a +%%point as well as after one. +÷ÏÚÍÏÖÎÏ ÄÁÖÅ × ÓÐÅÃÉÆÉËÁÃÉÉ ÐÕÔÉ ÉÍÅÔØ ÏÂÁ ÎÁÐÒÁ×ÌÅÎÉÑ ÄÌÑ ÏÄÎÏÊ ÔÏÞËÉ, ÄÏ É +ÐÏÓÌÅ. +%%It is even possible for a path specification +%%to have directions given before and after a point. +îÁÐÒÉÍÅÒ, ÕÞÁÓÔÏË ÓÐÅÃÉÆÉËÁÃÉÉ ÐÕÔÉ +%%For example a path specification containing +$$ \hbox{\verb|..{dir 60}(10,0){up}..|} $$ +ÐÒÏÉÚ×ÅÄÅÔ ËÒÉ×ÕÀ Ó ÕÇÌÏÍ × $(10,0)$. +%%produces a curve with a corner at $(10,0)$. + +úÁÍÅÔØÔÅ, ÞÔÏ ÎÅËÏÔÏÒÙÅ ËÒÉ×ÙÅ ÎÁ ÒÉÓ.~\ref{fig6} ÉÍÅÀÔ +ÔÏÞËÉ ÐÅÒÅÇÉÂÁ\index{ÐÅÒÅÇÉÂÙ}. +%%Note that some of the curves in Figure~\ref{fig6} have points of +%%inflection\index{inflections}. +üÔÏ ÎÅÏÂÈÏÄÉÍÏ ÐÒÉ ÓÏÚÄÁÎÉÉ ÇÌÁÄËÏÊ ËÒÉ×ÏÊ × ÓÉÔÕÁÃÉÉ ÐÏÄÏÂÎÏÊ +ÒÉÓ.~\ref{fig3}a, ÎÏ ÜÔÏ ×ÅÒÏÑÔÎÏ ÎÅÖÅÌÁÔÅÌØÎÏ ÐÒÉ ÒÁÂÏÔÅ Ó +×ÅÒÔÉËÁÌØÎÙÍÉ É ÇÏÒÉÚÏÎÔÁÌØÎÙÍÉ ÔÏÞËÁÍÉ ÜËÓÔÒÅÍÕÍÁ ËÁË ÐÏËÁÚÁÎÏ +ÎÁ ÒÉÓ.~\ref{fig8}a. +%%This is necessary in order to produce +%%smooth curves in situations like Figure~\ref{fig3}a, but it is probably +%%not desirable when dealing with vertical and horizontal extreme points +%%as in Figure~\ref{fig8}a. +åÓÌÉ \verb|z1| ÎÕÖÎÏ ÓÄÅÌÁÔØ ÎÁÉ×ÙÓÛÅÊ ÔÏÞËÏÊ ÎÁ ËÒÉ×ÏÊ, ÔÏ +ÜÔÏ ÍÏÖÎÏ ÐÏÌÕÞÉÔØ, ÉÓÐÏÌØÚÕÑ +\verb|...|\index{...?\texttt{...}} ×ÍÅÓÔÏ \verb|..| × +ÓÐÅÃÉÆÉËÁÃÉÉ ÐÕÔÉ ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig8}b. +%%If \verb|z1| is supposed to be the topmost +%%point on the curve, this can be achieved by using +%%\verb|...|\index{...?\texttt{...}} instead of \verb|..| in the path +%%specification as shown in Figure~\ref{fig8}b. +úÎÁÞÅÎÉÅ \verb|...| --- ÜÔÏ ``×ÙÂÒÁÔØ Ó×ÏÂÏÄÎÙÊ ÏÔ ÐÅÒÅÇÉÂÏ× ÐÕÔØ ÍÅÖÄÕ +ÜÔÉÍÉ ÔÏÞËÁÍÉ, ÅÓÌÉ ÎÁÐÒÁ×ÌÅÎÉÑ × ËÏÎÃÏ×ÙÈ ÔÏÞËÁÈ ÄÁÀÔ ÔÁËÕÀ ×ÏÚÍÏÖÎÏÓÔØ''. +%%The meaning of \verb|...| +%%is ``choose an inflection-free path between these points unless the +%%endpoint directions make this impossible.'' +îÁ ÒÉÓ.~\ref{fig6} ×ÏÚÍÏÖÎÏ ÉÚÂÁ×ÉÔØÓÑ ÏÔ ÐÅÒÅÇÉÂÏ×, Á ÎÁ ÒÉÓ.~\ref{fig7} ÎÅÔ. +%%(It would be possible to +%%avoid inflections in Figure~\ref{fig6}, but not in Figure~\ref{fig7}). + +\begin{figure}[htp] +$$ {\mathcenter{\includegraphics{manfig-ru-109}} \atop + \hbox{\verb|draw z0{up}..z1{right}..z2{down}|}} + \quad + {\mathcenter{\includegraphics{manfig-ru-209}} \atop + \hbox{\verb|draw z0{up}...z1{right}...z2{down}|}} +$$ +\caption{ä×Å ËÏÍÁÎÄÙ {\tt draw} É ËÒÉ×ÁÑ-ÒÅÚÕÌØÔÁÔ.} +%%\caption{Two {\tt draw} statements and the resulting curves.} +\label{fig8} +\end{figure} + +äÒÕÇÏÊ ÓÐÏÓÏ ÕÐÒÁ×ÌÑÔØ ÎÅÐÏÄÈÏÄÑÝÉÍ ÐÕÔÅÍ × Õ×ÅÌÉÞÅÎÉÉ ÐÁÒÁÍÅÔÒÁ +"ÎÁÐÒÑÖÅÎÉÅ"\index{ÎÁÐÒÑÖÅÎÉÅ}. +%%Another way to control a misbehaving path is to increase the +%%``tension''\index{tension} parameter. +éÓÐÏÌØÚÏ×ÁÎÉÅ \verb|..| × ÓÐÅÃÉÆÉËÁÃÉÉ ÐÕÔÉ ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ ÐÁÒÁÍÅÔÒ +ÎÁÐÒÑÖÅÎÉÑ × ÔÉÐÏ×ÏÅ ÚÎÁÞÅÎÉÅ 1. +%%Using \verb|..| in a path +%%specification sets the tension parameter to the default value~1. +åÓÌÉ ÜÔÏ ÄÅÌÁÅÔ ÎÅËÏÔÏÒÕÀ ÞÁÓÔØ ÐÕÔÉ ÓÌÉÛËÏÍ ÄÉËÏÊ, ÔÏ ÍÙ ÍÏÖÅÍ +×ÙÂÏÒÏÞÎÏ Õ×ÅÌÉÞÉÔØ ÎÁÐÒÑÖÅÎÉÅ. +%%If this makes some part of a path a little too wild, we can selectively +%%increase the tension. +åÓÌÉ ÒÉÓ.~\ref{fig9}a ÒÁÓÓÍÁÔÒÉ×ÁÅÔÓÑ ËÁË ``ÓÌÉÛËÏÍ ÄÉËÉÊ'', +ÔÏ ËÏÍÁÎÄÁ {\tt draw} × ÓÌÅÄÕÀÝÅÊ ÆÏÒÍÅ Õ×ÅÌÉÞÉÔ ÎÁÐÒÑÖÅÎÉÅ ÍÅÖÄÕ +{\tt z1} É {\tt z2}: +%%If Figure~\ref{fig9}a is considered ``too wild,'' +%%a {\tt draw} statement of the following form increases the tension +%%between {\tt z1} and {\tt z2}: +$$ \hbox{\verb|draw z0..z1..tension 1.3..z2..z3|} $$ +üÔÏ ÐÒÏÉÚ×ÅÄÅÔ ÒÉÓ.~\ref{fig9}b. +%%This produces Figure~\ref{fig9}b. +äÌÑ ÁÓÉÍÍÅÔÒÉÞÎÏÇÏ ÜÆÆÅËÔÁ ÐÏÄÏÂÎÏÇÏ ÒÉÓ.~\ref{fig9}c, ËÏÍÁÎÄÁ \verb|draw| +ÐÏÌÕÞÁÅÔ ×ÉÄ +%%For an asymmetrical effect like +%%Figure~\ref{fig9}c, the \verb|draw| statement becomes +$$ \hbox{\verb|draw z0..z1..tension 1.5 and 1..z2..z3|} $$ +ðÁÒÁÍÅÔÒ ÎÁÐÒÑÖÅÎÉÑ ÍÏÖÅÔ ÂÙÔØ ÍÅÎØÛÉÍ ÅÄÉÎÉÃÙ, ÎÏ ÏÎ ÄÏÌÖÅÎ ÂÙÔØ ÎÅ +ÍÅÎÅÅ $3\over4$. +%%The tension parameter can be less than one, but it must be at least $3\over4$. + +\begin{figure}[htp] +$$ {\mathcenter{\includegraphics{manfig-ru-110}} \atop (a)} + \quad + {\mathcenter{\includegraphics{manfig-ru-210}} \atop (b)} + \quad + {\mathcenter{\includegraphics{manfig-ru-310}} \atop (c)} +$$ +\caption[üÆÆÅËÔ ÉÚÍÅÎÅÎÉÑ ÐÁÒÁÍÅÔÒÁ ÎÁÐÒÑÖÅÎÉÑ] + {òÅÚÕÌØÔÁÔÙ {\tt draw z0..z1..tension} $\alpha$ {\tt É} $\beta$ + {\tt ..z2..z3} ÄÌÑ ÒÁÚÎÙÈ $\alpha$ É $\beta$: +%%\caption[Effects of changing the tension parameter] +%% {Results of {\tt draw z0..z1..tension} $\alpha$ {\tt and} $\beta$ +%% {\tt ..z2..z3} for various $\alpha$ and $\beta$: + (a)~$\alpha=\beta=1$; (b)~$\alpha=\beta=1.3$; + (c)~$\alpha=1.5$, $\beta=1$.} +\label{fig9} +\end{figure} + +ðÕÔÉ MetaPost ÉÍÅÀÔ ÔÁËÖÅ ÐÁÒÁÍÅÔÒ, ÎÁÚÙ×ÁÅÍÙÊ +``ÉÚÇÉÂ''\index{curl?\texttt{curl}}, ËÏÔÏÒÙÊ ×ÌÉÑÅÔ ÎÁ ËÏÎÃÙ ÐÕÔÅÊ. +%%MetaPost paths also have a parameter called +%%``curl''\index{curl?\texttt{curl}} that affects the ends of a path. +ðÒÉ ÏÔÓÕÔÓÔ×ÉÉ ÓÐÅÃÉÆÉËÁÃÉÊ ÎÁÐÒÁ×ÌÅÎÉÑ ÐÅÒ×ÙÊ É ÐÏÓÌÅÄÎÉÊ ÏÔÒÅÚËÉ +ÎÅÃÉËÌÉÞÅÓËÏÇÏ ÐÕÔÉ --- ÜÔÏ ÐÒÉÂÌÉÚÉÔÅÌØÎÏ ÄÕÇÉ ÏËÒÕÖÎÏÓÔÉ, ËÁË × ÓÌÕÞÁÅ +$c=1$ ÎÁ ÒÉÓ.~\ref{fig10}. +%%In +%%the absence of any direction specifications, the first and last segments +%%of a non-cyclic path are approximately circular arcs as in the $c=1$ +%%case of Figure~\ref{fig10}. +äÌÑ ÉÓÐÏÌØÚÏ×ÁÎÉÑ ÄÒÕÇÏÇÏ ÚÎÁÞÅÎÉÑ ÄÌÑ ÐÁÒÁÍÅÔÒÁ ÉÚÇÉÂÁ ÕËÁÖÉÔÅ +\verb|{curl c}| ÄÌÑ ÎÅËÏÔÏÒÏÇÏ ÚÎÁÞÅÎÉÑ $c$. +%%To use a different value for the curl +%%parameter, specify \verb|{curl c}| for some other value of $c$. +ôÁËÉÍ ÏÂÒÁÚÏÍ, +%%Thus +$$ \hbox{\verb|draw z0{curl c}..z1..{curl c}z2|} $$ +ÕÓÔÁÎÏ×ÉÔ ÐÁÒÁÍÅÔÒ ÉÚÇÉÂÁ ÄÌÑ \verb|z0| É \verb|z2|. +%%sets the curl parameter for \verb|z0| and \verb|z2|. +íÁÌÅÎØËÉÅ ÚÎÁÞÅÎÉÑ ÐÁÒÁÍÅÔÒÁ ÉÚÇÉÂÁ ÕÍÅÎØÛÁÀÔ ËÒÉ×ÉÚÎÕ\index{ËÒÉ×ÉÚÎÁ} +× ÕËÁÚÁÎÎÙÈ ËÏÎÃÏ×ÙÈ ÔÏÞËÁÈ ÐÕÔÉ, Á ÂÏÌØÛÉÅ ÚÎÁÞÅÎÉÑ Õ×ÅÌÉÞÉ×ÁÀÔ ËÒÉ×ÉÚÎÕ +ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig10}. +%%Small values of +%%the curl parameter reduce the curvature\index{curvature} at the +%%indicated path endpoints, while large values increase the curvature as +%%shown in Figure~\ref{fig10}. +÷ ÞÁÓÔÎÏÓÔÉ, ÚÎÁÞÅÎÉÅ ÉÚÇÉÂÁ ÎÏÌØ ÄÅÌÁÅÔ ËÒÉ×ÉÚÎÕ ÎÕÌÅ×ÏÊ. +%%In particular, a curl value of zero makes +%%the curvature approach zero. + +\begin{figure}[htp] +$$ {\mathcenter{\includegraphics{manfig-ru-111}} \atop c=0} + \qquad + {\mathcenter{\includegraphics{manfig-ru-211}} \atop c=1} + \qquad + {\mathcenter{\includegraphics{manfig-ru-311}} \atop c=2} + \qquad + {\mathcenter{\includegraphics{manfig-ru-411}} \atop c=\infty} +$$ +\caption[üÆÆÅËÔ ÉÚÍÅÎÅÎÉÑ ÐÁÒÁÍÅÔÒÁ ÉÚÇÉÂÁ] + {òÅÚÕÌØÔÁÔÙ {\tt draw z0\char`\{curl c\char`\}..z1..% + \char`\{curl c\char`\}z2} ÄÌÑ ÒÁÚÎÙÈ ÚÎÁÞÅÎÉÊ + ÐÁÒÁÍÅÔÒÁ ÉÚÇÉÂÁ~$c$.} +%%\caption[Effects of changing the curl parameter] +%% {Results of {\tt draw z0\char`\{curl c\char`\}..z1..% +%% \char`\{curl c\char`\}z2} for various values +%% of the curl parameter~$c$.} +\label{fig10} +\end{figure} + +\subsection{ðÏÌÎÙÊ ÓÉÎÔÁËÓÉÓ ÐÕÔÉ} +%%\subsection{Summary of Path Syntax} + +åÓÔØ ÅÝÅ ÎÅÓËÏÌØËÏ ÄÒÕÇÉÈ Ó×ÏÊÓÔ× ÓÉÎÔÁËÓÉÓÁ ÐÕÔÉ MetaPost, ÎÏ ÏÎÉ +ÏÔÎÏÓÉÔÅÌØÎÏ ÎÅ×ÁÖÎÙ. +%%There are a few other features of MetaPost path syntax, but they are +%%relatively unimportant. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ \MF\ ÉÓÐÏÌØÚÕÅÔ ÔÁËÏÊ ÖÅ ÓÉÎÔÁËÓÉÓ ÐÕÔÉ, ÚÁÉÎÔÅÒÅÓÏ×ÁÎÎÙÍ +ÞÉÔÁÔÅÌÑÍ ÓÔÏÉÔ ÐÏÓÍÏÔÒÅÔØ \cite[ÒÁÚÄÅÌ 14]{kn:c}. +%%Since \MF\ uses the same path syntax, +%%interested readers can refer to \cite[chapter 14]{kn:c}. +ó×ÏÄËÁ ÓÉÎÔÁËÓÉÓÁ ÐÕÔÉ ÎÁ ÒÉÓ.~\ref{sypath} ×ËÌÀÞÁÅÔ ×ÓÅ, +ÏÂÓÕÖÄÁÅÍÏÅ ÄÏ ÓÉÈ ÐÏÒ, ×ËÌÀÞÁÑ ËÏÎÓÔÒÕËÃÉÉ \verb|--| É \verb|...|, +ËÏÔÏÒÙÅ \cite{kn:c} ÐÏËÁÚÙ×ÁÅÔ ËÁË ÍÁËÒÏÓÙ, Á ÎÅ ÐÒÉÍÉÔÉ×Ù. +%%The summary of +%%path syntax in Figure~\ref{sypath} includes everything discussed so far +%%including the \verb|--| and \verb|...| constructions which \cite{kn:c} +%%shows to be macros rather than primitives. +îÅÓËÏÌØËÏ ËÏÍÍÅÎÔÁÒÉÅ× ÐÏ ÓÅÍÁÎÔÉËÅ ÐÒÉ×ÅÄÅÎÙ ÚÄÅÓØ: ÅÓÌÉ ÎÅÐÕÓÔÏÊ +$\descr{ÕËÁÚÁÔÅÌØ ÎÁÐÒÁ×ÌÅÎÉÑ}$ ÓÔÏÉÔ ÐÅÒÅÄ $\descr{ÕÚÌÏÍ ÐÕÔÉ}$, ÎÏ +ÎÅ ÐÏÓÌÅ, ÉÌÉ ÎÁÏÂÏÒÏÔ, ÔÏ ÕËÁÚÁÎÎÏÅ ÎÁÐÒÁ×ÌÅÎÉÅ (ÉÌÉ ×ÅÌÉÞÉÎÁ ÉÚÇÉÂÁ) +ÐÒÉÌÁÇÁÅÔÓÑ ËÁË Ë ×ÈÏÄÑÝÉÍ, ÔÁË É Ë ×ÙÈÏÄÑÝÉÍ ÏÔÒÅÚËÁÍ ÐÕÔÉ. +%%A few comments on the +%%semantics are in order here: If there is a non-empty $\descr{direction +%%specifier}$ before a $\descr{path knot}$ but not after it, or vice +%%versa, the specified direction (or curl amount) applies to both the +%%incoming and outgoing path segments. +ðÏÈÏÖÅÅ ÓÏÇÌÁÛÅÎÉÅ ÐÒÉÍÅÎÑÅÔÓÑ, ËÏÇÄÁ ÓÐÅÃÉÆÉËÁÔÏÒ $\descr{ÕÐÒÁ×ÌÅÎÉÑ}$ +ÄÁÅÔ ÔÏÌØËÏ ÏÄÎÕ $\descr{ÐÅÒ×ÉÞÎÕÀ ÐÁÒÕ}$. +%%A similar arrangement applies when +%%a $\descr{controls}$ specification gives only one $\descr{pair +%%primary}$. +ôÁËÉÍ ÏÂÒÁÚÏÍ, +%%Thus +$$ \hbox{\verb|..controls (30,20)..|} $$ +ÜË×É×ÁÌÅÎÔÎÏ +%%is equivalent to +$$ \hbox{\verb|...controls (30,20) and (30,20)..|} $$ + +\begin{figure}[htp] +\begin{ctabbing} +$\descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \rightarrow + \descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}$\\ +\qquad \= ${}\mid \descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \descr{ÕËÁÚÁÔÅÌØ ÎÁÐÒÁ×ÌÅÎÉÑ}$\\ +\> ${}\mid \descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \descr{ÓÏÅÄÉÎÉÔÅÌØ ÐÕÔÉ}$ \verb|cycle|\\ +$\descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \rightarrow + \descr{ÕÚÅÌ ÐÕÔÉ}$\\ +\> ${}\mid \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \descr{ÓÏÅÄÉÎÉÔÅÌØ ÐÕÔÉ} \descr{ÕÚÅÌ ÐÕÔÉ}$\\ +$\descr{ÓÏÅÄÉÎÉÔÅÌØ ÐÕÔÉ} \rightarrow + \hbox{\verb|--|}$\\ +\> ${}\mid \descr{ÕËÁÚÁÔÅÌØ ÎÁÐÒÁ×ÌÅÎÉÑ} \descr{ÂÁÚÏ×ÙÊ ÓÏÅÄÉÎÉÔÅÌØ ÐÕÔÉ} + \descr{ÕËÁÚÁÔÅÌØ ÎÁÐÒÁ×ÌÅÎÉÑ}$\\ +$\descr{ÕËÁÚÁÔÅÌØ ÎÁÐÒÁ×ÌÅÎÉÑ} \rightarrow + \descr{ÐÕÓÔÏ}$\\ +\> ${}\mid {}$\verb|{curl| $\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\verb|}|\\ +\> ${}\mid {}$\verb|{|$\descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}$\verb|}|\\ +\> ${}\mid {}$\verb|{|$\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\verb|,|% + $\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\verb|}|\\ +$\descr{ÂÁÚÏ×ÙÊ ÓÏÅÄÉÎÉÔÅÌØ ÐÕÔÉ} \rightarrow + \hbox{\verb|..|} + \mid \hbox{\verb|...|} + \mid \hbox{\verb|..|}\descr{ÎÁÐÒÑÖÅÎÉÅ}\hbox{\verb|..|} + \mid \hbox{\verb|..|}\descr{ÕÐÒÁ×ÌÅÎÉÅ}\hbox{\verb|..|}$\\ +$\descr{ÎÁÐÒÑÖÅÎÉÅ} \rightarrow + \hbox{\verb|tension|}\descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +\> ${}\mid \hbox{\verb|tension|}\descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ} + \hbox{\verb|and|}\descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +$\descr{ÕÐÒÁ×ÌÅÎÉÅ} \rightarrow + \hbox{\verb|controls|}\descr{ÐÅÒ×ÉÞÎÁÑ ÐÁÒÁ}$\\ +\> ${}\mid \hbox{\verb|controls|}\descr{ÐÅÒ×ÉÞÎÁÑ ÐÁÒÁ} + \hbox{\verb|and|}\descr{ÐÅÒ×ÉÞÎÁÑ ÐÁÒÁ}$ +%%$\descr{path expression} \rightarrow +%% \descr{path subexpression}$\\ +%%\qquad \= ${}\mid \descr{path subexpression} \descr{direction specifier}$\\ +%%\> ${}\mid \descr{path subexpression} \descr{path join}$ \verb|cycle|\\ +%%$\descr{path subexpression} \rightarrow +%% \descr{path knot}$\\ +%%\> ${}\mid \descr{path expression} \descr{path join} \descr{path knot}$\\ +%%$\descr{path join} \rightarrow +%% \hbox{\verb|--|}$\\ +%%\> ${}\mid \descr{direction specifier} \descr{basic path join} +%% \descr{direction specifier}$\\ +%%$\descr{direction specifier} \rightarrow +%% \descr{empty}$\\ +%%\> ${}\mid {}$\verb|{curl| $\descr{numeric expression}$\verb|}|\\ +%%\> ${}\mid {}$\verb|{|$\descr{pair expression}$\verb|}|\\ +%%\> ${}\mid {}$\verb|{|$\descr{numeric expression}$\verb|,|% +%% $\descr{numeric expression}$\verb|}|\\ +%%$\descr{basic path join} \rightarrow +%% \hbox{\verb|..|} +%% \mid \hbox{\verb|...|} +%% \mid \hbox{\verb|..|}\descr{tension}\hbox{\verb|..|} +%% \mid \hbox{\verb|..|}\descr{controls}\hbox{\verb|..|}$\\ +%%$\descr{tension} \rightarrow +%% \hbox{\verb|tension|}\descr{numeric primary}$\\ +%%\> ${}\mid \hbox{\verb|tension|}\descr{numeric primary} +%% \hbox{\verb|and|}\descr{numeric primary}$\\ +%%$\descr{controls} \rightarrow +%% \hbox{\verb|controls|}\descr{pair primary}$\\ +%%\> ${}\mid \hbox{\verb|controls|}\descr{pair primary} +%% \hbox{\verb|and|}\descr{pair primary}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ËÏÎÓÔÒÕËÃÉÉ ÐÕÔÉ} +%%\caption{The syntax for path construction} +\label{sypath} +\end{figure} + +ðÁÒÁ ËÏÏÒÄÉÎÁÔ, ÐÏÄÏÂÎÁÑ \verb|(30,20)| ÉÌÉ ÐÅÒÅÍÅÎÎÏÊ \verb|z|, +ÐÒÅÄÓÔÁ×ÌÑÀÝÅÊ ËÏÏÒÄÉÎÁÔÎÕÀ ÐÁÒÕ, --- ÜÔÏ ÔÏ, ÞÔÏ ÎÁ ÒÉÓ.~\ref{sypath} +ÚÏ×ÅÔÓÑ $\descr{ÐÅÒ×ÉÞÎÏÊ ÐÁÒÏÊ}$. +%%A pair of coordinates like \verb|(30,20)| or a \verb|z| variable that +%%represents a coordinate pair is what Figure~\ref{sypath} calls a +%%$\descr{pair primary}$. +ðÏÈÏÖÉÍ Ñ×ÌÑÅÔÓÑ $\descr{ÕÚÅÌ ÐÕÔÉ}$ ÚÁ ÉÓËÌÀÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ ÏÎ ÍÏÖÅÔ +ÐÒÉÏÂÒÅÔÁÔØ ÄÒÕÇÉÅ ÆÏÒÍÙ, ÔÁËÉÅ ËÁË ×ÙÒÁÖÅÎÉÅ ÐÕÔÉ × ÓËÏÂËÁÈ. +%%A $\descr{path knot}$ is similar except that it +%%can take on other forms such as a path expression in parentheses. +ðÅÒ×ÉÞÎÏÓÔÉ É ×ÙÒÁÖÅÎÉÑ ÒÁÚÌÉÞÎÙÈ ÔÉÐÏ× ÂÕÄÕÔ ÏÂÓÕÖÄÁÔØÓÑ × ÐÏÌÎÏÍ ÏÂßÅÍÅ +× ÒÁÚÄÅÌÅ~\ref{exprs}. +%%Primaries and expressions of various types will be discussed in full +%%generality in Section~\ref{exprs}. + +\section{ìÉÎÅÊÎÙÅ ÕÒÁ×ÎÅÎÉÑ} +%%\section{Linear Equations} +\label{lin.eq} + +÷ÁÖÎÙÍ Ó×ÏÊÓÔ×ÏÍ, ×ÚÑÔÙÍ ÉÚ \MF, Ñ×ÌÑÅÔÓÑ ×ÏÚÍÏÖÎÏÓÔØ ÒÅÛÁÔØ ÌÉÎÅÊÎÙÅ +ÕÒÁ×ÎÅÎÉÑ, ×ÓÌÅÄÓÔ×ÉÅ ÜÔÏÇÏ ÐÒÏÇÒÁÍÍÙ ÍÏÇÕÔ ÐÉÓÁÔØÓÑ × ÞÁÓÔÉÞÎÏ +ÄÅËÌÁÒÁÔÉ×ÎÏÊ ÍÁÎÅÒÅ. +%%An important feature taken from \MF\ is the ability to solve linear +%%equations so that programs can be written in a partially declarative fashion. +îÁÐÒÉÍÅÒ, MetaPost-ÉÎÔÅÒÐÒÅÔÁÔÏÒ ÍÏÖÅÔ ÓÞÉÔÁÔØ +%%For example, the MetaPost interpreter can read +$$ \hbox{\verb|a+b=3; 2a=b+3;|} $$ +É ×Ù×ÅÓÔÉ, ÞÔÏ $a=2$ É $b=1$. +%%and deduce that $a=2$ and $b=1$. +üÔÉ ÖÅ ×ÙÒÁÖÅÎÉÑ ÍÏÇÕÔ ÂÙÔØ ÚÁÐÉÓÁÎÙ ÓÌÅÇËÁ ÂÏÌÅÅ ËÏÍÐÁËÔÎÏ ÐÕÔÅÍ +ÓÏÅÄÉÎÅÎÉÑ ÉÈ ×ÍÅÓÔÅ ÎÅÓËÏÌØËÉÍÉ ÚÎÁËÁÍÉ ÒÁ×ÅÎÓÔ×Á: +%%The same equations can be written +%%slightly more compactly by stringing them together with multiple equal +%%signs: +$$ \hbox{\verb|a+b = 2a-b = 3;|} $$ +ëÁËÉÍ ÂÙ ÓÐÏÓÏÂÏÍ ×Ù ÎÅ ÚÁÄÁ×ÁÌÉ ÕÒÁ×ÎÅÎÉÑ, ×Ù ÍÏÖÅÔÅ ÚÁÔÅÍ ÄÁÔØ +ËÏÍÁÎÄÕ\index{show?\texttt{show}} +%%Whichever way you give the equations, you can then give the +%%command\index{show?\texttt{show}} +$$ \hbox{\tt show a,b;} $$ +ÄÌÑ ÐÒÏÓÍÏÔÒÁ ÚÎÁÞÅÎÉÊ {\tt a} É {\tt b}. +%%to see the values of {\tt a} and {\tt b}. +MetaPost ÏÔ×ÅÔÉÔ, ÎÁÐÅÞÁÔÁ× +%%MetaPost responds by typing +$$\begin{verbatim} +>> 2 +>> 1 +\end{verbatim} +$$ + +úÁÍÅÔØÔÅ, ÞÔÏ {\tt =}\index{=?\texttt{=}} ÎÅ Ñ×ÌÑÅÔÓÑ ÏÐÅÒÁÔÏÒÏÍ ÐÒÉÓ×ÁÉ×ÁÎÉÑ; +ÏÎ ÐÒÏÓÔÏ ÏÂßÑ×ÌÑÅÔ, ÞÔÏ ÌÅ×ÁÑ ÞÁÓÔØ ÒÁ×ÎÁ ÐÒÁ×ÏÊ. +%%Note that {\tt =}\index{=?\texttt{=}} is not an assignment operator; it +%%simply declares that the left-hand side equals the right-hand side. +ôÁËÉÍ ÏÂÒÁÚÏÍ, {\tt a=a+1} ÐÒÉ×ÅÄÅÔ Ë ÓÏÏÂÝÅÎÉÀ Ï ÏÛÉÂËÅ, ÖÁÌÕÀÝÅÍÕÓÑ +ÎÁ ``ÐÒÏÔÉ×ÏÒÅÞÉ×ÏÅ ÕÒÁ×ÎÅÎÉÅ\index{Inconsistent equation?\texttt{Inconsistent +equation}}''. +%%Thus {\tt a=a+1} produces an error message complaining about an +%%``inconsistent equation\index{Inconsistent equation?\texttt{Inconsistent +%%equation}}.'' +óÐÏÓÏ Õ×ÅÌÉÞÅÎÉÑ ÚÎÁÞÅÎÉÑ {\tt a} --- × ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÏÐÅÒÁÔÏÒÁ +ÐÒÉÓ×ÁÉ×ÁÎÉÑ\index{ÐÒÉÓ×ÁÉ×ÁÎÉÅ} {\tt :=}\index{:=?\texttt{:=}} ËÁË × +ÐÒÉÍÅÒÅ: +%%The way to increase the value of {\tt a} is to use the +%%assignment\index{assignment} operator {\tt :=}\index{:=?\texttt{:=}} as +%%follows: +$$ \hbox{\tt a:=a+1;} $$ +äÒÕÇÉÍÉ ÓÌÏ×ÁÍÉ, {\tt :=} ÄÌÑ ÉÚÍÅÎÅÎÉÑ ÓÕÝÅÓÔ×ÕÀÝÉÈ ÚÎÁÞÅÎÉÊ, Á +{\tt =} ÄÌÑ ÚÁÄÁÎÉÑ ÌÉÎÅÊÎÙÈ ÕÒÁ×ÎÅÎÉÊ ÄÌÑ ÒÅÛÅÎÉÑ. +%%In other words, {\tt :=} is for changing existing values while {\tt =} is for +%%giving linear equations to solve. + +îÅÔ ÏÇÒÁÎÉÞÅÎÉÊ ÎÁ ÓÍÅÛÉ×ÁÎÉÅ ÕÒÁ×ÎÅÎÉÊ É ÏÐÅÒÁÃÉÊ ÐÒÉÓ×ÁÉ×ÁÎÉÑ, ÎÁÐÒÉÍÅÒ, +%%There is no restriction against mixing equations and assignment +%%operations as in the following example: +$$ \hbox{\tt a = 2; b = a; a := 3; c = a;} $$ +ðÏÓÌÅ ÐÅÒ×ÙÈ Ä×ÕÈ ÕÒÁ×ÎÅÎÉÊ, ÕÓÔÁÎÁ×ÌÉ×ÁÀÝÉÈ {\tt a} É~{\tt b} ÒÁ×ÎÙÍÉ 2, +ÏÐÅÒÁÃÉÑ ÐÒÉÓ×ÁÉ×ÁÎÉÑ ÉÚÍÅÎÉÔ {\tt a} ÎÁ~3 ÂÅÚ ×ÌÉÑÎÉÑ ÎÁ {\tt b}. +%%After the first two equations set {\tt a} and~{\tt b} equal to 2, the +%%assignment operation changes {\tt a} to~3 without affecting {\tt b}. +ïËÏÎÞÁÔÅÌØÎÏÅ ÚÎÁÞÅÎÉÅ {\tt c} --- 3, Ô.~Ë. ÏÎÏ ÐÒÉÒÁ×ÎÑÅÔÓÑ ÎÏ×ÏÍÕ +ÚÎÁÞÅÎÉÀ {\tt a}. +%%The final value of {\tt c} is 3 since it is equated to the new value of +%%{\tt a}. +÷ ÏÂÝÅÍ, ÏÐÅÒÁÃÉÑ ÐÒÉÓ×ÁÉ×ÁÎÉÑ ÉÎÔÅÒÐÒÅÔÉÒÕÅÔÓÑ ÓÎÁÞÁÌÁ ×ÙÞÉÓÌÅÎÉÅÍ ÎÏ×ÏÇÏ +ÚÎÁÞÅÎÉÑ É ÚÁÔÅÍ ÕÎÉÞÔÏÖÅÎÉÅÍ ÓÔÁÒÏÇÏ ÚÎÁÞÅÎÉÑ ÉÚ ×ÓÅÈ ÓÕÝÅÓÔ×ÕÀÝÉÈ ÕÒÁ×ÎÅÎÉÊ +ÐÅÒÅÄ ÓÏÂÓÔ×ÅÎÎÏ ÐÒÉÓ×ÁÉ×ÁÎÉÅÍ. +%%In general, an assignment operation is interpreted by first +%%computing the new value, then eliminating the old value from all +%%existing equations before actually assigning the new value. + +\subsection{õÒÁ×ÎÅÎÉÑ É ËÏÏÒÄÉÎÁÔÎÙÅ ÐÁÒÙ} +%%\subsection{Equations and Coordinate Pairs} + +MetaPost ÍÏÖÅÔ ÔÁËÖÅ ÒÅÛÁÔØ ÌÉÎÅÊÎÙÅ ÕÒÁ×ÎÅÎÉÑ, ÓÏÄÅÒÖÁÝÉÅ ËÏÏÒÄÉÎÁÔÎÙÅ ÐÁÒÙ. +%%MetaPost can also solve linear equations involving coordinate pairs. +íÙ ÕÖÅ ×ÉÄÅÌÉ ÍÎÏÇÏ ÔÒÉ×ÉÁÌØÎÙÈ ÐÒÉÍÅÒÏ× ÜÔÏÇÏ × ÆÏÒÍÅ ÕÒÁ×ÎÅÎÉÊ, ÐÏÄÏÂÎÙÈ +%%We have +%%already seen many trivial examples of this in the form of equations like +$$ \hbox{\verb|z1=(0,.2in)|} $$ +ëÁÖÄÁÑ ÓÔÏÒÏÎÁ ÕÒÁ×ÎÅÎÉÑ ÄÏÌÖÎÁ ÂÙÔØ ÓÆÏÒÍÉÒÏ×ÁÎÁ ÓÌÏÖÅÎÉÅÍ ÉÌÉ ×ÙÞÉÔÁÎÉÅÍ +ËÏÏÒÄÉÎÁÔÎÙÈ ÐÁÒ É ÕÍÎÏÖÅÎÉÅÍ ÉÌÉ ÄÅÌÅÎÉÅÍ ÉÈ ÎÁ ÉÚ×ÅÓÔÎÙÅ ÞÉÓÌÏ×ÙÅ +ËÏÌÉÞÅÓÔ×Á. +%%Each side of the equation must be formed by adding or subtracting +%%coordinate pairs and multiplying or dividing them by known numeric +%%quantities. +äÒÕÇÉÅ ÓÐÏÓÏÂÙ ÉÍÅÎÏ×ÁÎÉÑ ÐÁÒ ÚÎÁÞÅÎÉÊ ÐÅÒÅÍÅÎÎÙÈ ÂÕÄÕÔ ÏÂÓÕÖÄÁÔØÓÑ ÐÏÚÖÅ, +Á ÐÏËÁ ÒÁÓÓÍÏÔÒÉÍ ÉÍÅÎÏ×ÁÎÉÅ ×ÉÄÁ +${\tt z}\descr{ÞÉÓÌÏ}$\index{z convention?{\tt z}-ÓÏÇÌÁÛÅÎÉÅ}, ËÏÔÏÒÏÅ ×ÅÓØÍÁ +ÕÄÏÂÎÏ, ÐÏÔÏÍÕ ÞÔÏ ÏÎÏ --- ÓÏËÒÁÝÅÎÉÅ ÄÌÑ +$$ \hbox{\tt (x}\descr{ÞÉÓÌÏ} \hbox{\tt, y}\descr{ÞÉÓÌÏ}\hbox{\tt)} $$ +%%Other ways of naming pair-valued variables will be +%%discussed later, but the ${\tt z}\descr{number}$\index{z convention?{\tt +%%z} convention} is convenient because it is an abbreviation for +%%$$ \hbox{\tt (x}\descr{number} \hbox{\tt, y}\descr{number}\hbox{\tt)} $$ +üÔÏ ÄÅÌÁÅÔ ×ÏÚÍÏÖÎÙÍ ÄÁ×ÁÔØ ÚÎÁÞÅÎÉÑ ÐÅÒÅÍÅÎÎÙÍ \verb|z| ÚÁÄÁÎÉÅÍ +ÕÒÁ×ÎÅÎÉÊ ÄÌÑ ÉÈ ËÏÏÒÄÉÎÁÔ. +%%This makes it possible to give values to \verb|z| variables by giving +%%equations involving their coordinates. +îÁÐÒÉÍÅÒ, ÔÏÞËÉ {\tt z1}, {\tt z2}, {\tt z3}, É~{\tt z6} ÎÁ ÒÉÓ.~\ref{fig12} +ÂÙÌÉ ÉÎÉÃÉÁÌÉÚÉÒÏ×ÁÎÙ ÓÌÅÄÕÀÝÉÍÉ ÕÒÁ×ÎÅÎÉÑÍÉ: +%%For instance, points {\tt z1}, +%%{\tt z2}, {\tt z3}, and~{\tt z6} in Figure~\ref{fig12} were initialized +%%via the following equations: +\begin{eqnarray*} + &&\hbox{\verb|z1=-z2=(.2in,0);|} \\ + &&\hbox{\verb|x3=-x6=.3in;|} \\ + &&\hbox{\verb|x3+y3=x6+y6=1.1in;|} +\end{eqnarray*} +÷ ÔÏÞÎÏÓÔÉ ÔÅ ÖÅ ÓÁÍÙÅ ÔÏÞËÉ ÍÏÇÌÉ ÂÙÔØ ÐÏÌÕÞÅÎÙ ÐÒÑÍÏÊ ÕÓÔÁÎÏ×ËÏÊ ÉÈ ÚÎÁÞÅÎÉÊ: +%%Exactly the same points could be obtained by setting their values directly: +$$ \begin{verbatim} +z1=(.2in,0); z2=(-.2in,0); +z3=(.3in,.8in); z6=(-.3in,1.4in); +\end{verbatim} +$$ + +ðÏÓÌÅ ÞÔÅÎÉÑ ÕÒÁ×ÎÅÎÉÊ MetaPost-ÉÎÔÅÒÐÒÅÔÁÔÏÒ ÚÎÁÅÔ ÚÎÁÞÅÎÉÑ +{\tt z1}, {\tt z2}, {\tt z3} É~{\tt z6}. +%%After reading the equations, the MetaPost interpreter knows the values +%%of {\tt z1}, {\tt z2}, {\tt z3}, and~{\tt z6}. +óÌÅÄÕÀÝÉÊ ÛÁÇ × ËÏÎÓÔÒÕÉÒÏ×ÁÎÉÉ ÒÉÓ.~\ref{fig12} --- ÜÔÏ ÏÐÒÅÄÅÌÅÎÉÅ ÔÏÞÅË +{\tt z4} É {\tt z5}, ÏÄÉÎÁËÏ×Ï ÕÄÁÌÅÎÎÙÈ ÏÔ {\tt z3} É {\tt z6} É ÌÅÖÁÝÉÈ ÎÁ +ÏÄÎÏÊ ÌÉÎÉÉ Ó ÎÉÍÉ. +%%The next step in the +%%construction of Figure~\ref{fig12} is to define points {\tt z4} and {\tt +%%z5} equally spaced along the line from {\tt z3} to {\tt z6}. +ðÏÔÏÍÕ ËÁË ÜÔÁ ÏÐÅÒÁÃÉÑ ÐÏÑ×ÌÑÅÔÓÑ ÞÁÓÔÏ, MetaPost ÉÍÅÅÔ ÄÌÑ ÎÅÅ ÓÐÅÃÉÁÌØÎÙÊ +ÓÉÎÔÁËÓÉÓ. +%%Since this +%%operation comes up often, MetaPost has a special syntax for it. +õÓÒÅÄÎÑÀÝÁÑ ËÏÎÓÔÒÕËÃÉÑ\index{ÕÓÒÅÄÎÅÎÉÅ}\index{[]?\texttt{[]}!ÕÓÒÅÄÎÅÎÉÅ} +%%This +%%mediation construction\index{mediation}\index{[]?\texttt{[]}!mediation} +$$ \hbox{\verb|z4=1/3[z3,z6]|} $$ +ÏÚÎÁÞÁÅÔ, ÞÔÏ {\tt z4} ÐÒÏÛÌÁ $1\over3$ ÐÕÔÉ ÏÔ $z3$ ÄÏ $z6$, Ô.~Å. +%%means that {\tt z4} is $1\over3$ of the way from $z3$ to $z6$; i.e., +$$ {\tt z4}={\tt z3}+{1\over3}({\tt z6}-{\tt z3}). $$ +óÈÏÖÁÑ ËÏÎÓÔÒÕËÃÉÑ +%%Similarly +$$ \hbox{\verb|z5=2/3[z3,z6]|} $$ +ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ {\tt z5} ÎÁ $2\over3$ ÐÕÔÉ ÏÔ $z3$ ÄÏ $z6$. +%%makes {\tt z5} $2\over3$ of the way from $z3$ to $z6$. + +\begin{figure}[htp] +$$ \begin{verbatim} +beginfig(13); +z1=-z2=(.2in,0); +x3=-x6=.3in; +x3+y3=x6+y6=1.1in; +z4=1/3[z3,z6]; +z5=2/3[z3,z6]; +z20=whatever[z1,z3]=whatever[z2,z4]; +z30=whatever[z1,z4]=whatever[z2,z5]; +z40=whatever[z1,z5]=whatever[z2,z6]; +draw z1--z20--z2--z30--z1--z40--z2; +pickup pencircle scaled 1pt; +draw z1--z2; +draw z3--z6; +endfig; +\end{verbatim} +\quad \mathcenter{\includegraphics{manfig-ru-13}} +$$ +\caption[ëÏÄ MetaPost, ÉÓÐÏÌØÚÕÀÝÉÊ ÌÉÎÅÊÎÙÅ ÕÒÁ×ÎÅÎÉÑ, É ÒÉÓÕÎÏË] + {ëÏÍÁÎÄÙ MetaPost É ÒÉÓÕÎÏË-ÒÅÚÕÌØÔÁÔ. ñÒÌÙËÉ ÔÏÞÅË ÄÏÂÁ×ÌÅÎÙ + Ë ÒÉÓÕÎËÕ ÄÌÑ ÑÓÎÏÓÔÉ.} +%%\caption[MetaPost code and figure using linear equations] +%% {MetaPost commands and the resulting figure. Point labels have been +%% added to the figure for clarity.} +\label{fig12} +\end{figure} + +õÓÒÅÄÎÅÎÉÅ ÍÏÖÅÔ ÂÙÔØ ÔÁËÖÅ ÉÓÐÏÌØÚÏ×ÁÎÏ ÄÌÑ ÔÏÇÏ, ÞÔÏÂÙ ÓËÁÚÁÔØ, ÞÔÏ +ÎÅËÏÔÏÒÁÑ ÔÏÞËÁ ÎÁÈÏÄÉÔÓÑ × ÎÅÉÚ×ÅÓÔÎÏÊ ÐÏÚÉÃÉÉ ÎÁ ÐÒÑÍÏÊ ÍÅÖÄÕ Ä×ÕÍÑ +ÉÚ×ÅÓÔÎÙÍÉ ÔÏÞËÁÍÉ. +%%Mediation can also be used to say that some point is at an unknown +%%position along the line between two known points. +îÁÐÒÉÍÅÒ, ÍÙ ÍÏÖÅÍ ××ÅÓÔÉ ÎÏ×ÕÀ ÐÅÒÅÍÅÎÎÕÀ {\tt aa} É ÚÁÐÉÓÁÔØ ÞÔÏ-ÔÏ ×ÒÏÄÅ +%%For instance, we +%%could a introduce new variable {\tt aa} and write something like +$$ \hbox{\verb|z20=aa[z1,z3];|} $$ +üÔÏ ÏÚÎÁÞÁÅÔ, ÞÔÏ {\tt z20} --- ÜÔÏ ÎÅÉÚ×ÅÓÔÎÏÅ ÏÔÎÏÛÅÎÉÅ {\tt aa} ÐÕÔÉ +ÐÏ ÐÒÑÍÏÊ ÍÅÖÄÕ {\tt z1} É {\tt z3}. +%%This says that {\tt z20} is some unknown fraction {\tt aa} of the way +%%along the line between {\tt z1} and {\tt z3}. +åÝÅ ÏÄÎÏÇÏ ÔÁËÏÇÏ ÏÔÎÏÛÅÎÉÑ ÄÌÑ ÄÒÕÇÏÊ ÌÉÎÉÉ ÄÏÓÔÁÔÏÞÎÏ ÄÌÑ ÆÉËÓÁÃÉÉ +ÚÎÁÞÅÎÉÑ {\tt z20}. +%%Another such equation +%%involving a different line is sufficient to fix the value of {\tt z20}. +ïÐÉÓÁÎÉÅ ÔÏÇÏ, ÞÔÏ {\tt z20} ÐÅÒÅÓÅÞÅÎÉÅ ÐÒÑÍÙÈ {\tt z1}-{\tt z3} +É {\tt z2}-{\tt z4} ××ÏÄÉÔ ÅÝÅ ÏÄÎÕ ÐÅÒÅÍÅÎÎÕÀ {\tt ab} É ÕÓÔÁÎÁ×ÌÉ×ÁÅÔÓÑ +%%To say that {\tt z20} is at the intersection of the {\tt z1}-{\tt z3} +%%line and the {\tt z2}-{\tt z4} line, introduce another variable {\tt ab} +%%and set +$$ \hbox{\verb|z20=ab[z2,z4];|} $$ +üÔÏ ÐÏÚ×ÏÌÑÅÔ MetaPost ÎÁÊÔÉ {\tt x20}, {\tt y20}, {\tt aa} É {\tt ab}. +%%This allows MetaPost to solve for {\tt x20}, {\tt y20}, {\tt aa}, and {\tt ab}. + +îÅÓËÏÌØËÏ ÓÌÏÖÎÏ×ÁÔÏ ÐÏÓÔÏÑÎÎÏ ÄÕÍÁÔØ Ï ÎÏ×ÙÈ ÉÍÅÎÁÈ, ÐÏÄÏÂÎÙÈ {\tt aa} É +{\tt ab}. +%%It is a little painful to keep thinking up new names like {\tt aa} and +%%{\tt ab}. +üÔÏÇÏ ÍÏÖÎÏ ÉÚÂÅÖÁÔØ, ÉÓÐÏÌØÚÕÑ ÓÐÅÃÉÁÌØÎÕÀ ×ÏÚÍÏÖÎÏÓÔØ, ÎÁÚÙ×ÁÅÍÕÀ +{\tt whatever}\index{whatever?\texttt{whatever}}\label{Dwhatev}. +%%This can be avoided by using a special feature called {\tt +%%whatever}\index{whatever?\texttt{whatever}}\label{Dwhatev}. +üÔÏÔ ÍÁËÒÏÓ ÇÅÎÅÒÉÒÕÅÔ ÎÏ×ÕÀ ÁÎÏÎÉÍÎÕÀ ÐÅÒÅÍÅÎÎÕÀ ËÁÖÄÙÊ ÒÁÚ, ËÏÇÄÁ ÏÎ +ÐÏÑ×ÌÑÅÔÓÑ. +%%This macro +%%generates a new anonymous variable each time it appears. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ËÏÍÁÎÄÁ +%%Thus the statement +$$ \hbox{\verb|z20=whatever[z1,z3]=whatever[z2,z4]|} $$ +ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ {\tt z20} ËÁË É ÒÁÎØÛÅ, ÎÏ ÏÎÁ ÉÓÐÏÌØÚÕÅÔ +{\tt whatever} ÄÌÑ ÇÅÎÅÒÁÃÉÉ Ä×ÕÈ {\em ÒÁÚÌÉÞÎÙÈ\/} ÁÎÏÎÉÍÎÙÈ ÐÅÒÅÍÅÎÎÙÈ +×ÍÅÓÔÏ {\tt aa} É {\tt ab}. +%%sets {\tt z20} as before, except it uses {\tt whatever} to generate two +%%{\em different\/} anonymous variables instead of {\tt aa} and {\tt ab}. +òÉÓ.~\ref{fig12} ÐÏËÁÚÙ×ÁÅÔ ËÁË ÕÓÔÁÎÁ×ÌÉ×ÁÀÔÓÑ {\tt z20}, {\tt z30} É +{\tt z40}. +%%This is how Figure~\ref{fig12} sets {\tt z20}, {\tt z30}, and +%%{\tt z40}. + +\subsection{òÁÂÏÔÁ Ó ÎÅÉÚ×ÅÓÔÎÙÍÉ} +%%\subsection{Dealing with Unknowns} + +õÒÁ×ÎÅÎÉÑ × ÓÉÓÔÅÍÅ ÔÁËÏÊ, ËÁË ÎÁ ÒÉÓ.~\ref{fig12}, ÍÏÇÕÔ ÂÙÔØ ÚÁÄÁÎÙ × ÌÀÂÏÍ +ÐÏÒÑÄËÅ, ÎÏ ×ÓÅ ÕÒÁ×ÎÅÎÉÑ ÄÏÌÖÎÙ ÂÙÔØ ÌÉÎÅÊÎÙÍÉ É ×ÓÅ ÐÅÒÅÍÅÎÎÙÅ ÄÏÌÖÎÏ ÂÙÔØ +×ÏÚÍÏÖÎÙÍ ×ÙÞÉÓÌÉÔØ ÔÏÇÄÁ, ËÏÇÄÁ ÏÎÉ ÐÏÎÁÄÏÂÑÔÓÑ. +%%A system of equations such as those used in Figure~\ref{fig12} can be given in +%%any order as long as all the equations are linear and all the variables can +%%be determined before they are needed. +üÔÏ ÚÎÁÞÉÔ, ÞÔÏ ÕÒÁ×ÎÅÎÉÑ +%%This means that the equations +\begin{eqnarray*} + && \hbox{\verb|z1=-z2=(.2in,0);|}\\ + && \hbox{\verb|x3=-x6=.3in;|}\\ + && \hbox{\verb|x3+y3=x6+y6=1.1in;|}\\ + && \hbox{\verb|z4=1/3[z3,z6];|}\\ + && \hbox{\verb|z5=2/3[z3,z6];|} +\end{eqnarray*} +ÄÏÓÔÁÔÏÞÎÙ ÄÌÑ ÏÐÒÅÄÅÌÅÎÉÑ {\tt z1} É ÏÓÔÁÌØÎÙÈ ÄÏ {\tt z6} É ÐÏÒÑÄÏË +ÕÒÁ×ÎÅÎÉÊ ÎÅ ×ÁÖÅÎ. +%%suffice to determine {\tt z1} through {\tt z6}, no matter what order the +%%equations are given in. +ó ÄÒÕÇÏÊ ÓÔÏÒÏÎÙ +%%On the other hand +$$ \hbox{\verb|z20=whatever[z1,z3]|} $$ +ÂÕÄÅÔ ÐÒÁ×ÉÌØÎÏ ÔÏÌØËÏ × ÓÌÕÞÁÅ, ËÏÇÄÁ ÉÚ×ÅÓÔÎÏÅ ÚÎÁÞÅÎÉÅ ÂÙÌÏ ÐÒÅÄ×ÁÒÉÔÅÌØÎÏ +ÕËÁÚÁÎÏ ÄÌÑ ÒÁÚÎÏÓÔÉ ${\tt z3}-{\tt z1}$, ÐÏÔÏÍÕ ÞÔÏ ÜÔÏ ÕÒÁ×ÎÅÎÉÅ +ÜË×É×ÁÌÅÎÔÎÏ\index{ÕÓÒÅÄÎÅÎÉÅ} +%%is legal only when a known value has previously been specified for the difference +%%${\tt z3}-{\tt z1}$, because the equation is equivalent +%%to\index{mediation} +$$ \hbox{\verb|z20 = z1 + whatever*(z3-z1)|} $$ +É ÔÒÅÂÏ×ÁÎÉÑ ÌÉÎÅÊÎÏÓÔÉ ÎÅ ÐÏÚ×ÏÌÑÀÔ ÕÍÎÏÖÁÔØ ÎÅÉÚ×ÅÓÔÎÙÅ ËÏÍÐÏÎÅÎÔÙ +${\tt z3}-{\tt z1}$ ÎÁ ÁÎÏÎÉÍÎÙÊ ÎÅÉÚ×ÅÓÔÎÙÊ ÒÅÚÕÌØÔÁÔ +{\tt whatever}. +%%and the linearity requirement disallows multiplying unknown components +%%of ${\tt z3}-{\tt z1}$ by the anonymous unknown result of {\tt +%%whatever}. +ïÂÝÅÅ ÐÒÁ×ÉÌÏ × ÔÏÍ, ÞÔÏ ×Ù ÎÅ ÍÏÖÅÔÅ ÕÍÎÏÖÁÔØ Ä×Á ÎÅÉÚ×ÅÓÔÎÙÈ ËÏÌÉÞÅÓÔ×Á, +ÄÅÌÉÔØ ÎÁ ÎÅÉÚ×ÅÓÔÎÏÅ ËÏÌÉÞÅÓÔ×Ï ÉÌÉ ÉÓÐÏÌØÚÏ×ÁÔØ ÎÅÉÚ×ÅÓÔÎÏÅ ËÏÌÉÞÅÓÔ×Ï × +ËÏÍÁÎÄÅ {\tt draw}. +%%The general rule is that you cannot multiply two unknown +%%quantities or divide by an unknown quantity, nor can an unknown quantity +%%be used in a {\tt draw} statement. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÒÁÚÒÅÛÅÎÙ ÔÏÌØËÏ ÌÉÎÅÊÎÙÅ ÕÒÁ×ÎÅÎÉÑ, MetaPost-ÉÎÔÅÒÐÒÅÔÁÔÏÒ +ÍÏÖÅÔ ÌÅÇËÏ ÒÅÛÁÔØ ÕÒÁ×ÎÅÎÉÑ É ÈÒÁÎÉÔØ ÉÎÆÏÒÍÁÃÉÀ Ï ÔÏÍ, ËÁËÉÅ ×ÅÌÉÞÉÎÙ +ÉÚ×ÅÓÔÎÙ. +%%Since only linear equations are +%%allowed, the MetaPost interpreter can easily solve the equations and +%%keep track of what values are known. + +îÁÉÂÏÌÅÅ ÅÓÔÅÓÔ×ÅÎÎÙÊ ÓÐÏÓÏ ÇÁÒÁÎÔÉÒÏ×ÁÔØ, ÞÔÏ MetaPost ÓÍÏÖÅÔ ×ÏÓÐÒÉÎÑÔØ +×ÙÒÁÖÅÎÉÅ ÔÉÐÁ +%%The most natural way to ensure that MetaPost can handle an expression like +$$ \hbox{\verb|whatever[z1,z3]|} $$ +× ÇÁÒÁÎÔÉÉ, ÞÔÏ {\tt z1} É {\tt z3} ÉÚ×ÅÓÔÎÙ. +%%is to ensure that {\tt z1} and {\tt z3} are both known. +ïÄÎÁËÏ ÜÔÏÇÏ × ÄÅÊÓÔ×ÉÔÅÌØÎÏÓÔÉ ÎÅ ÔÒÅÂÕÅÔÓÑ, Ô.~Ë. MetaPost ÓÍÏÖÅÔ ×Ù×ÅÓÔÉ +ÚÎÁÞÅÎÉÅ ÄÌÑ ${\tt z3}-{\tt z1}$, ÎÅ ÚÎÁÑ ÐÒÅÄ×ÁÒÉÔÅÌØÎÏ {\tt z1} É {\tt z3}. +%%However this is not +%%actually required since MetaPost may be able to deduce a known value for +%%${\tt z3}-{\tt z1}$ before either of {\tt z1} and {\tt z3} are known. +îÁÐÒÉÍÅÒ, MetaPost ×ÏÓÐÒÉÎÉÍÁÅÔ ÐÒÁ×ÉÌØÎÙÍÉ ÕÒÁ×ÎÅÎÉÑ +%%For instance, MetaPost will accept the equations +$$ \hbox{\verb|z3=z1+(.1in,.6in); z20=whatever[z1,z3];|} $$ +É ÐÒÉ ÜÔÏÍ ÎÅ ÂÕÄÅÔ ÓÐÏÓÏÂÅÎ ÏÐÒÅÄÅÌÉÔØ ÌÀÂÕÀ ÉÚ ËÏÍÐÏÎÅÎÔ {\tt z1}, +{\tt z3} ÉÌÉ {\tt z20}. +%%but it will not be able to determine any of the components of {\tt z1}, +%%{\tt z3}, or {\tt z20}. + +üÔÉ ÕÒÁ×ÎÅÎÉÑ ÄÁÀÔ ÞÁÓÔÉÞÎÕÀ ÉÎÆÏÒÍÁÃÉÀ Ï {\tt z1}, {\tt z3} É {\tt z20}. +%%These equations do give partial information about {\tt z1}, {\tt z3}, +%%and {\tt z20}. +èÏÒÏÛÉÊ ÓÐÏÓÏ ÐÏÎÑÔØ ÜÔÏ × ÒÁÓÓÍÏÔÒÅÎÉÉ ÄÒÕÇÏÇÏ ÕÒÁ×ÎÅÎÉÑ +%%A good way to see this is to give another equation such as +$$ \hbox{\verb|x20-x1=(y20-y1)/6;|} $$ +ïÎÏ ÐÒÏÉÚ×ÅÄÅÔ ÓÏÏÂÝÅÎÉÅ Ï ÏÛÉÂËÅ ``{\tt ! Redundant +equation}''\index{Redundant equation?\texttt{Redundant +equation}}\footnote{éÚÂÙÔÏÞÎÏÅ ÕÒÁ×ÎÅÎÉÅ}. +%%This produces the error message ``{\tt ! Redundant +%%equation}\index{Redundant equation?\texttt{Redundant equation}}.'' +MetaPost ÓÞÉÔÁÅÔ, ÞÔÏ ×Ù ÐÙÔÁÅÔÅÓØ ÓÏÏÂÝÁÔØ ÅÍÕ ÞÔÏ-ÔÏ ÎÏ×ÏÅ É ÐÏÜÔÏÍÕ +ÏÎ ÏÂÙÞÎÏ ÐÒÅÄÕÐÒÅÖÄÁÅÔ ÐÒÉ ÚÁÄÁÎÉÉ ÉÚÂÙÔÏÞÎÏÇÏ ÕÒÁ×ÎÅÎÉÑ. +%%MetaPost assumes that you are trying to tell it something new, so it +%%will usually warn you when you give a redundant equation. +îÏ×ÏÅ ÕÒÁ×ÎÅÎÉÅ ×ÉÄÁ +%%If the new equation had been +$$ \hbox{\verb|(x20-x1)-(y20-y1)/6=1in;|} $$ +ÐÒÏÉÚ×ÅÄÅÔ ÓÏÏÂÝÅÎÉÅ Ï ÏÛÉÂËÅ\index{Inconsistent equation?\texttt{Inconsistent equation}}\footnote{ðÒÏÔÉ×ÏÒÅÞÉ×ÏÅ ÕÒÁ×ÎÅÎÉÅ +(ÏÔËÌÏÎÅÎÉÅ ÎÁ 71.99979).} +%%the error message would have been\index{Inconsistent +%%equation?\texttt{Inconsistent equation}} +$$ \hbox{\verb|! Inconsistent equation (off by 71.99979).|} $$ +üÔÏ ÓÏÏÂÝÅÎÉÅ Ï ÏÛÉÂËÅ ÉÌÌÀÓÔÒÉÒÕÅÔ ÏÛÉÂËÕ ÏËÒÕÇÌÅÎÉÑ\index{ÏÛÉÂËÁ ÏËÒÕÇÌÅÎÉÑ} +× ÍÅÈÁÎÉÚÍÅ MetaPost ÄÌÑ ÒÅÛÅÎÉÑ ÌÉÎÅÊÎÙÈ ÕÒÁ×ÎÅÎÉÊ. +%%This error message illustrates +%%roundoff\index{roundoff error} error in MetaPost's linear equation solving +%%mechanism. +ïÛÉÂËÁ ÏËÒÕÇÌÅÎÉÑ --- ÜÔÏ ÏÂÙÞÎÏ ÎÅÓÅÒØÅÚÎÁÑ ÐÒÏÂÌÅÍÁ, ÎÏ ÏÎÁ ÍÏÖÅÔ ×ÙÚ×ÁÔØ +ÚÁÔÒÕÄÎÅÎÉÅ ÐÒÉ ÐÏÐÙÔËÅ ÎÁÊÔÉ ÐÅÒÅÓÅÞÅÎÉÅ Ä×ÕÈ ÐÏÞÔÉ ÐÁÒÁÌÌÅÌØÎÙÈ ÐÒÑÍÙÈ. +%%Roundoff error +%%is normally not a serious problem. but it is likely to cause trouble if you are +%%trying to do something like find the intersection of two lines that are almost +%%parallel. + +\section{÷ÙÒÁÖÅÎÉÑ} +%%\section{Expressions} +\label{exprs} + +îÁÓÔÁÌÏ ×ÒÅÍÑ ÄÌÑ ÂÏÌÅÅ ÓÉÓÔÅÍÁÔÉÞÅÓËÏÇÏ ÏÂÚÏÒÁ ÑÚÙËÁ MetaPost. +%%It is now time for a more systematic view of the MetaPost language. +íÙ ×ÉÄÅÌÉ ÞÉÓÌÏ×ÙÅ ËÏÌÉÞÅÓÔ×Á É ËÏÏÒÄÉÎÁÔÎÙÅ ÐÁÒÙ É ÔÏ, ÞÔÏ ÉÈ ÍÏÖÎÏ +ÓÏÅÄÉÎÑÔØ ÄÌÑ ÕËÁÚÁÎÉÑ ÐÕÔÉ ÄÌÑ ËÏÍÁÎÄ {\tt draw}. +%%We +%%have seen that there are numeric quantities and coordinate pairs, and +%%that these can be combined to specify paths for {\tt draw} statements. +íÙ ÔÁËÖÅ ×ÉÄÅÌÉ, ËÁË ÐÅÒÅÍÅÎÎÙÅ ÍÏÇÕÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÙ × ÌÉÎÅÊÎÙÈ ÕÒÁ×ÎÅÎÉÑÈ, +ÎÏ ÎÅ ÏÂÓÕÖÄÁÌÉ ×ÓÅÈ ÏÐÅÒÁÃÉÊ É ÔÉÐÏ× ÄÁÎÎÙÈ, ÞÔÏ ÍÏÇÕÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÙ × +ÕÒÁ×ÎÅÎÉÑÈ. +%%We have also seen how variables can be used in linear equations, but we +%%have not discussed all the operations and data types that can be used in +%%equations. + +éÓÐÏÌØÚÏ×ÁÎÉÅ ËÏÍÁÎÄÙ \index{show?\texttt{show}}\label{Dshow} +$$ {\tt show}\, \descr{×ÙÒÁÖÅÎÉÅ} $$ +ÄÌÑ ÐÅÞÁÔÉ ÓÉÍ×ÏÌØÎÏÇÏ ÐÒÅÄÓÔÁ×ÌÅÎÉÑ ÚÎÁÞÅÎÉÑ ÌÀÂÏÇÏ ×ÙÒÁÖÅÎÉÑ ÄÅÌÁÅÔ +×ÏÚÍÏÖÎÙÍ ÜËÓÐÅÒÉÍÅÎÔÙ Ó ×ÙÒÁÖÅÎÉÑÍÉ ÌÀÂÙÈ ÔÉÐÏ× ÄÁÎÎÙÈ, ×ÓÔÒÅÞÁÀÝÉÈÓÑ ÄÁÌÅÅ. +%%It is possible to experiment with expressions involving any of the data types +%%mentioned below by using the statement\index{show?\texttt{show}}\label{Dshow} +%%$$ {\tt show}\, \descr{expression} $$ +%%to ask MetaPost to print a symbolic representation of the value of each +%%expression. +éÚ×ÅÓÔÎÙÅ ÞÉÓÌÏ×ÙÅ ÚÎÁÞÅÎÉÑ ÐÅÞÁÔÁÀÔÓÑ × ÏÔÄÅÌØÎÙÈ ÓÔÒÏËÁÈ, +ÐÒÅÄ×ÁÒÑÅÍÙÅ ``{\tt >>} ''. +%%For known numeric values, each is printed on a new line +%%preceded by ``{\tt >>} ''. +äÒÕÇÉÅ ÔÉÐÙ ÒÅÚÕÌØÔÁÔÁ ÒÁÓÞÅÔÁ ÐÅÞÁÔÁÀÔÓÑ ÐÏÈÏÖÉÍ ÏÂÒÁÚÏÍ, ÚÁ +ÉÓËÌÀÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ ÓÌÏÖÎÙÅ ÚÎÁÞÅÎÉÑ ÉÎÏÇÄÁ ÎÅ ÒÁÓÐÅÞÁÔÙ×ÁÀÔÓÑ ÎÁ ÕÓÔÒÏÊÓÔ×Å +×Ù×ÏÄÁ. +%%Other types of result are printed similarly, +%%except that complicated values are sometimes not printed on standard +%%output. +ðÏÓÌÅÄÎÅÅ ÐÒÏÉÚ×ÏÄÉÔ ÓÓÙÌËÕ ÎÁ +ÆÁÊÌ-ÄÕÂÌÉËÁÔ\index{ÆÁÊÌÙ!ÄÕÂÌÉËÁÔ}, ËÏÔÏÒÁÑ ×ÙÇÌÑÄÉÔ ÐÒÉÍÅÒÎÏ +ÔÁË\footnote{ËÁÒÔÉÎËÁ (ÓÍ. ÆÁÊÌ-ÄÕÂÌÉËÁÔ)} +%%This produces a reference to the transcript +%%file\index{files!transcript} that looks like this: +$$ \hbox{\tt >> picture (see the transcript file)} $$ +åÓÌÉ ×Ù ÚÁÈÏÔÉÔÅ ÒÁÓÐÅÞÁÔËÉ ÎÁ ÔÅÒÍÉÎÁÌÅ ÐÏÌÎÙÈ ÒÅÚÕÌØÔÁÔÏ× ËÏÍÁÎÄÙ +{\tt show}, ÔÏ ÎÁÚÎÁÞØÔÅ ÐÏÌÏÖÉÔÅÌØÎÏÅ ÚÎÁÞÅÎÉÅ ×ÎÕÔÒÅÎÎÅÊ\index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ} ÐÅÒÅÍÅÎÎÏÊ\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} {\tt +tracingonline}\index{tracingonline?\texttt{tracingonline}}\label{Dtonline}. +%%If you want to the full results of {\tt show} statements to be printed +%%on your terminal, assign a positive value to the internal\index{internal +%%variables} variable\index{variables!internal} {\tt +%%tracingonline}\index{tracingonline?\texttt{tracingonline}}\label{Dtonline}. + +\subsection{ôÉÐÙ ÄÁÎÎÙÈ} +%%\subsection{Data Types} + +MetaPost × ÄÅÊÓÔ×ÉÔÅÌØÎÏÓÔÉ ÉÍÅÅÔ ÄÅÓÑÔØ ÔÉÐÏ× ÄÁÎÎÙÈ\index{ÔÉÐÙ}: ÞÉÓÌÏ×ÏÊ, +ÄÌÑ ÐÁÒ, ÄÌÑ ÐÕÔÅÊ, ÔÒÁÎÓÆÏÒÍÁÃÉÉ, Ã×ÅÔÁ (rgb-Ã×ÅÔÁ), cmyk-Ã×ÅÔÁ, ÓÔÒÏËÏ×ÙÊ, +ÌÏÇÉÞÅÓËÉÊ, ÄÌÑ ËÁÒÔÉÎÏË É ÔÉÐ ÐÅÒÁ. +%%MetaPost actually has ten basic data types\index{types}: numeric, +%%pair, path, transform, (rgb)color, cmykcolor, string, boolean, picture, and +%%pen. +äÁ×ÁÊÔÅ ÒÁÓÓÍÁÔÒÉ×ÁÔØ ÉÈ ÐÏ-ÏÄÎÏÍÕ, ÎÁÞÉÎÁÑ Ó ÞÉÓÌÏ×ÏÇÏ ÔÉÐÁ. +%%Let us consider these one at a time beginning with the numeric +%%type. + +þÉÓÌÏ×ÙÅ (numeric)\index{ÞÉÓÌÏ×ÏÊ ÔÉÐ} ËÏÌÉÞÅÓÔ×Á ÐÒÅÄÓÔÁ×ÌÑÀÔÓÑ × MetaPost Ó ÆÉËÓÉÒÏ×ÁÎÎÏÊ +ÄÅÓÑÔÉÞÎÏÊ ÔÏÞËÏÊ\index{ÁÒÉÆÍÅÔÉËÁ} ËÁË ÃÅÌÙÅ, ÕÍÎÏÖÅÎÎÙÅ ÎÁ $1\over65536$. +%%Numeric\index{numeric type} quantities in MetaPost are represented in fixed +%%point arithmetic\index{arithmetic} as +%%integer multiples of $1\over65536$. +ïÎÉ ÄÏÌÖÎÙ ÏÂÙÞÎÏ ÉÍÅÔØ ÍÏÄÕÌØ, ÍÅÎØÛÉÊ 4096, ÎÏ ÐÒÏÍÅÖÕÔÏÞÎÙÅ ÒÅÚÕÌØÔÁÔÙ ÍÏÇÕÔ +ÂÙÔØ × ×ÏÓÅÍØ ÒÁÚ ÂÏÌØÛÅ. +%%They must normally have absolute values +%%less than 4096 but intermediate results can be eight times larger. +üÔÏ ÎÅ ÄÏÌÖÎÏ ÂÙÔØ ÐÒÏÂÌÅÍÏÊ ÄÌÑ ÒÁÓÓÔÏÑÎÉÊ ÉÌÉ ÚÎÁÞÅÎÉÊ ËÏÏÒÄÉÎÁÔ, Ô.~Ë. 4096 +PostScript-ÐÕÎËÔÏ× ÓÏÓÔÁ×ÌÑÀÔ ÂÏÌÅÅ 1.4 ÍÅÔÒÁ. +%%This should not be a problem for distances or coordinate values since 4096 +%%PostScript points is more than 1.4~meters. +åÓÌÉ ×ÁÍ ÎÕÖÎÏ ÒÁÂÏÔÁÔØ Ó ÞÉÓÌÁÍÉ ÒÁÚÍÅÒÁ 4096 É ÂÏÌÅÅ, ÔÏ ÕÓÔÁÎÏ×ËÁ ×ÎÕÔÒÅÎÎÅÊ +ÐÅÒÅÍÅÎÎÏÊ {\tt warningcheck}\index{warningcheck?\texttt{warningcheck}}\label{Dwarncheck} × +ÎÏÌØ ÐÏÄÁ×ÉÔ ÐÒÅÄÕÐÒÅÖÄÁÀÝÉÅ ÓÏÏÂÝÅÎÉÑ Ï ÂÏÌØÛÉÈ ÞÉÓÌÏ×ÙÈ ËÏÌÉÞÅÓÔ×ÁÈ. +%%If you need to work with numbers +%%of magnitude 4096 or more, setting the internal variable +%%{\tt warningcheck}\index{warningcheck}\label{Dwarncheck} to zero +%%suppresses the warning messages about large numeric quantities. + +ôÉÐ pair (ÐÁÒÙ) \index{ÔÉÐ-ÐÁÒÁ} ÐÒÅÄÓÔÁ×ÌÑÅÔÓÑ ËÁË ÐÁÒÁ ÞÉÓÌÏ×ÙÈ ËÏÌÉÞÅÓÔ×. +%%The pair\index{pair type} type is represented as a pair of numeric +%%quantities. +íÙ ×ÉÄÅÌÉ, ÞÔÏ ÐÁÒÙ ÉÓÐÏÌØÚÕÀÔÓÑ ÄÌÑ ÚÁÄÁÎÉÑ ËÏÏÒÄÉÎÁÔ × ËÏÍÁÎÄÅ {\tt draw}. +%%We have seen that pairs are used to give coordinates in +%%{\tt draw} statements. +ðÁÒÙ ÍÏÖÎÏ ÓËÌÁÄÙ×ÁÔØ, ×ÙÞÉÔÁÔØ, ÉÓÐÏÌØÚÏ×ÁÔØ × ×ÙÒÁÖÅÎÉÑÈ ÕÓÒÅÄÎÅÎÉÑ, ÕÍÎÏÖÁÔØ É +ÄÅÌÉÔØ ÎÁ ÞÉÓÌÁ. +%%Pairs can be added, subtracted, used in +%%mediation expressions, or multiplied or divided by numerics. + +ôÉÐ ÐÕÔÅÊ (path)\index{ÔÉÐ-ÐÕÔØ} ÕÖÅ ÏÂÓÕÖÄÁÌÓÑ × ËÏÎÔÅËÓÔÅ ËÏÍÁÎÄÙ {\tt draw}, ÎÏ +ÜÔÏ ÏÂÓÕÖÄÅÎÉÅ ÏÂÏÛÌÏ ÓÔÏÒÏÎÏÊ ÔÏ, ÞÔÏ ÐÕÔÉ ×ÁÖÎÙÅ ÏÔÄÅÌØÎÙÅ ÏÂßÅËÔÙ, ËÏÔÏÒÙÅ +ÍÏÖÎÏ ÓÏÈÒÁÎÑÔØ É ÉÚÍÅÎÑÔØ. +%%Paths\index{path type} have already been discussed in the context of {\tt draw} +%%statements, but +%%that discussion did not mention that paths are first-class objects that can be +%%stored and manipulated. +ðÕÔØ ÐÒÅÄÓÔÁ×ÌÑÅÔ ÐÒÑÍÕÀ ÌÉÎÉÀ ÉÌÉ ËÒÉ×ÕÀ, ÏÐÒÅÄÅÌÑÅÍÙÅ ÐÁÒÁÍÅÔÒÉÞÅÓËÉ. +%%A path represents a straight or curved line that is +%%defined parametrically. + +äÒÕÇÏÊ ÔÉÐ ÄÁÎÎÙÈ ÐÒÅÄÓÔÁ×ÌÑÅÔ ÐÒÏÉÚ×ÏÌØÎÕÀ ÁÆÆÉÎÎÕÀ +ÔÒÁÎÓÆÏÒÍÁÃÉÀ (transform)\index{ÔÉÐ-ÔÒÁÎÓÆÏÒÍÁÃÉÑ}. +%%Another data type represents an arbitrary affine +%%transformation\index{transform type}. +{\em ôÒÁÎÓÆÏÒÍÁÃÉÑ} ÍÏÖÅÔ ÂÙÔØ ÌÀÂÏÊ ËÏÍÂÉÎÁÃÉÅÊ ×ÒÁÝÅÎÉÊ, ÍÁÓÛÔÁÂÉÒÏ×ÁÎÉÊ, +ÎÁËÌÏÎÏ× É ÓÄ×ÉÇÏ×. +%%A {\em transform\/} can be any +%%combination of rotating, scaling, slanting, and shifting. +åÓÌÉ ${\tt +p}=(p_x,p_y)$ --- ÜÔÏ ÐÁÒÁ É {\tt T} --- ÜÔÏ +ÔÒÁÎÓÆÏÒÍÁÃÉÑ,\index{transformed?\texttt{transformed}} ÔÏ +$$ \hbox{\tt p transformed T} $$ +%%If ${\tt +%%p}=(p_x,p_y)$ is a pair and {\tt T} is a +%%transform,\index{transformed?\texttt{transformed}} +%%$$ \hbox{\tt p transformed T} $$ +--- ÜÔÏ ÐÁÒÁ ×ÉÄÁ +%%is a pair of the form +$$ (t_x+t_{xx}p_x+t_{xy}p_y, t_y+t_{yx}p_x+t_{yy}p_y), $$ +ÇÄÅ 6 ÞÉÓÌÏ×ÙÈ ËÏÌÉÞÅÓÔ× $(t_x,t_y,t_{xx},t_{xy},t_{yx},t_{yy})$ +ÏÐÒÅÄÅÌÑÀÔ {\tt T}. +%%where the six numeric quantities $(t_x,t_y,t_{xx},t_{xy},t_{yx},t_{yy})$ +%%determine {\tt T}. +ôÒÁÎÓÆÏÒÍÁÃÉÉ ÍÏÇÕÔ ÂÙÔØ ÐÒÉÍÅÎÉÍÙ Ë ÐÕÔÑÍ, ÒÉÓÕÎËÁÍ, ÐÅÒØÑÍ É ÔÒÁÎÓÆÏÒÍÁÃÉÑÍ. +%%Transforms can also be applied to paths, pictures, pens, +%%and transforms. + +ôÉÐ Ã×ÅÔÁ (color)\index{ÔÉÐ-Ã×ÅÔ} ÐÏÄÏÂÅÎ ÔÉÐÕ ÐÁÒÙ, ÎÏ ÏÎ ÉÍÅÅÔ ÔÒÉ ËÏÍÐÏÎÅÎÔÙ +×ÍÅÓÔÏ Ä×ÕÈ É ËÁÖÄÁÑ ËÏÍÐÏÎÅÎÔÁ ÏÂÙÞÎÏ ÎÁÈÏÄÉÔÓÑ × ÄÉÁÐÁÚÏÎÅ ÏÔ 0 ÄÏ 1. +%%The color\index{color type} type is like the pair type, except +%%that it has three components instead of two and each component is +%%normally between 0 and 1. +ðÏÄÏÂÎÏ ÐÁÒÁÍ, Ã×ÅÔÁ ÍÏÇÕÔ ÓËÌÁÄÙ×ÁÔØÓÑ, ×ÙÞÉÔÁÔØÓÑ, ÉÓÐÏÌØÚÏ×ÁÔØÓÑ × ×ÙÒÁÖÅÎÉÑ ÕÓÒÅÄÎÅÎÉÑ, ÕÍÎÏÖÁÔØÓÑ É ÄÅÌÉÔØÓÑ ÎÁ ÞÉÓÌÁ. +%%Like pairs, colors can be added, +%%subtracted, used in mediation expressions, or multiplied or divided +%%by numerics. +ã×ÅÔÁ ÍÏÇÕÔ ÚÁÄÁ×ÁÔØÓÑ ÐÒÉ ÐÏÍÏÝÉ ËÏÎÓÔÁÎÔ \ttindex{black}\label{Dblack}, \ttindex{white}\label{Dwhite}, +\ttindex{red}\label{Dred}, \ttindex{green}\label{Dgreen}, +\ttindex{blue}\label{Dblue} ÉÌÉ Ñ×ÎÏ ÚÁÄÁÎÎÙÍÉ ËÒÁÓÎÏÊ, ÚÅÌÅÎÏÊ É ÓÉÎÅÊ +ËÏÍÐÏÎÅÎÔÁÍÉ. +%%Colors can be specified in terms of the predefined +%%constants \ttindex{black}\label{Dblack}, \ttindex{white}\label{Dwhite}, +%%\ttindex{red}\label{Dred}, \ttindex{green}\label{Dgreen}, +%%\ttindex{blue}\label{Dblue}, or the red, green, and +%%blue components can be given explicitly. +þÅÒÎÙÊ --- ÜÔÏ {\tt (0,0,0)} É ÂÅÌÙÊ --- ÜÔÏ {\tt (1,1,1)}. +%%Black is {\tt (0,0,0)} and +%%white is {\tt (1,1,1)}. +õÒÏ×ÅÎØ ÓÅÒÏÇÏ, ÔÁËÏÊ ËÁË {\tt (.4,.4,.4)}, ÍÏÖÎÏ ÔÁËÖÅ ÚÁÄÁÔØ ËÁË +{\tt 0.4white}. +%%A level of gray such as {\tt (.4,.4,.4)} can also be +%%specified as {\tt 0.4white}. +èÏÔÑ Ã×ÅÔÏ×ÏÊ ÐÅÒÅÍÅÎÎÏÊ ÍÏÖÅÔ ÂÙÔØ ÌÀÂÁÑ ÕÐÏÒÑÄÏÞÅÎÎÁÑ ÔÒÏÊËÁ, ÐÒÉ +ÄÏÂÁ×ÌÅÎÉÉ ÏÂßÅËÔÁ Ë ËÁÒÔÉÎËÅ MetaPost ÐÒÅÏÂÒÁÚÕÅÔ ÅÅ Ã×ÅÔÁ ÏÂÒÅÚËÏÊ +ËÁÖÄÏÊ Ã×ÅÔÏ×ÏÊ ËÏÍÐÏÎÅÎÔÙ ÄÏ ÄÉÁÐÁÚÏÎÁ ÏÔ 0 ÄÏ 1. +%%Although color typed variables may be +%%any ordered triplet, when adding an object to a picture, MetaPost will +%%convert its color by clipping each component between 0 and 1. +îÁÐÒÉÍÅÒ, MetaPost ÂÕÄÅÔ ×Ù×ÏÄÉÔØ Ã×ÅÔ (1,2,3) ËÁË (1,1,1). +%%For +%%example, MetaPost will output the color (1,2,3) as (1,1,1). +MetaPost ÒÅÛÁÅÔ ÌÉÎÅÊÎÙÅ ÕÒÁ×ÎÅÎÉÑ Ó Ã×ÅÔÁÍÉ ÔÁËÉÍ ÖÅ ÏÂÒÁÚÏÍ ËÁË É Ó ÐÁÒÁÍÉ. +%%MetaPost solves linear equations involving +%%colors the same way it does for pairs. +ôÉÐ `rgbcolor' (rgb-Ã×ÅÔ) --- ÜÔÏ ÓÉÎÏÎÉÍ ÔÉÐÁ `color' (Ã×ÅÔ). +%%The type `rgbcolor' is an alias of. +%%type `color'. + +ôÉÐ cmykcolor\index{ÔÉÐ-cmyk-Ã×ÅÔ} (cmyk-Ã×ÅÔÁ) ÐÏÄÏÂÅÎ ÔÉÐÕ color, ÎÏ +ÉÍÅÅÔ ÞÅÔÙÒÅ ËÏÍÐÏÎÅÎÔÙ ×ÍÅÓÔÏ ÔÒÅÈ. +%%The cmykcolor\index{cmykcolor type} type is similar to the color +%%type except that it has four components instead of three. +üÔÏÔ ÔÉÐ ÉÓÐÏÌØÚÕÅÔÓÑ ÄÌÑ ÚÁÄÁÎÉÑ Ã×ÅÔÏ× ÉÈ ÚÅÌÅÎÏÇÏÌÕÂÏÊ (cyan), +ÐÕÒÐÕÒÎÏËÒÁÓÎÏÊ (magenta), ÖÅÌÔÏÊ É ÞÅÒÎÏÊ ËÏÍÐÏÎÅÎÔÁÍÉ. +%%This type is used to +%%specify colors by their cyan, magenta, yellow, and black components explicitly. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ cmyk-Ã×ÅÔ ÉÓÐÏÌØÚÕÅÔ ËÒÁÓËÉ ×ÍÅÓÔÏ Ó×ÅÔÏ×ÙÈ ÌÕÞÅÊ, ÂÅÌÙÊ +Ã×ÅÔ ÂÕÄÅÔ ×ÙÒÁÖÁÔØÓÑ ËÁË {\tt (0,0,0,0)} É ÞÅÒÎÙÊ ËÁË {\tt (0,0,0,1)}. +%%Because CMYK colors deal with pigments instead of light rays, the color +%%black would be expressed as {\tt (1,1,1,1)} and white as {\tt (0,0,0,0)}. +ôÅÏÒÅÔÉÞÅÓËÉ Ã×ÅÔÁ {\tt ($c$,$m$,$y$,1)} É {\tt (1,1,1,$k$)} ÄÏÌÖÎÙ ÄÁ×ÁÔØ ÞÅÒÎÙÊ +ÄÌÑ ÌÀÂÙÈ ÚÎÁÞÅÎÉÊ $c$, $m$, $y$ É~$k$. +%%In theory, the colors +%%{\tt ($c$,$m$,$y$,1)} and {\tt (1,1,1,$k$)} should result in black for +%%any values of $c$, $m$, $y$ and~$k$, too. +îÁ ÐÒÁËÔÉËÅ ÜÔÏÇÏ ÉÚÂÅÇÁÀÔ, Ô.~Ë. ÜÔÏ ÔÒÁÔÉÔ Ã×ÅÔÎÙÅ ÞÅÒÎÉÌÁ É ÍÏÖÅÔ ÐÒÉ×ÏÄÉÔØ Ë +ÎÅÕÄÏ×ÌÅÔ×ÏÒÉÔÅÌØÎÙÍ ÒÅÚÕÌØÔÁÔÁÍ. +%%But in practice, this is +%%avoided since it is a waste of colored ink and can lead to +%%unsatisfactory results. + +óÔÒÏËÉ (string)\index{ÓÔÒÏËÏ×ÙÊ ÔÉÐ} ÐÒÅÄÓÔÁ×ÌÑÀÔ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÓÉÍ×ÏÌÏ×. +%%A string\index{string type} represents a sequence of characters. +óÔÒÏËÏ×ÙÅ ËÏÎÓÔÁÎÔÙ\index{ÓÔÒÏËÏ×ÙÅ ËÏÎÓÔÁÎÔÙ} ÚÁÄÁÀÔÓÑ × Ä×ÏÊÎÙÈ ËÁ×ÙÞËÁÈ +\hbox{\verb|"ÐÏÄÏÂÎÏ ÜÔÏÊ"|}. +%%String constants\index{string constants} are given +%%in double quotes \hbox{\verb|"like this"|}. +óÔÒÏËÏ×ÙÅ ËÏÎÓÔÁÎÔÙ ÎÅ ÍÏÇÕÔ ÓÏÄÅÒÖÁÔØ Ä×ÏÊÎÙÈ ËÁ×ÙÞÅË ÉÌÉ ÐÅÒÅÈÏÄÏ× ÎÁ ÎÏ×ÕÀ +ÓÔÒÏËÕ, ÎÏ ÅÓÔØ ÓÐÏÓÏ ËÏÎÓÔÒÕÉÒÏ×ÁÔØ ÓÔÒÏËÉ, ÓÏÄÅÒÖÁÝÉÅ ÌÀÂÕÀ +ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ×ÏÓØÍÉÂÉÔÎÙÈ ÚÎÁËÏ×. +%%String constants cannot contain +%%double quotes or newlines, but there is a way to construct a string containing +%%any sequence of eight-bit characters. + +\label{Dscantokens} +ðÒÅÏÂÒÁÚÏ×ÁÎÉÅ ÓÔÒÏË × ÄÒÕÇÉÅ ÔÉÐÙ, ÏÂÙÞÎÏ ÞÉÓÌÏ×ÙÅ, ×ÏÚÍÏÖÎÏ ÐÒÉÍÉÔÉ×ÏÍ +{\tt scantokens}\index{scantokens?\texttt{scantokens}}: +\begin{center}\texttt{n := scantokens(}\textit{ÓÔÒÏËÁ}\texttt{);}\end{center} +%%Conversion from strings to other types, notably numeric, can be accomplished by +%%the {\tt scantokens}\index{scantokens?\texttt{scantokens}} primitive: +%%\begin{center}\texttt{n := scantokens(}\textit{str}\texttt{);}\end{center} +âÏÌÅÅ ÁÂÓÔÒÁËÔÎÏ, \texttt{scantokens} ÒÁÚÂÉÒÁÅÔ ÓÔÒÏËÕ ÎÁ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ +ÚÎÁËÏ×, ÔÁËÖÅ ËÁË MetaPost ÓÞÉÔÙ×ÁÌ ÂÙ ÉÈ ÐÒÉ ××ÏÄÅ. +%%More generally, \texttt{scantokens} parses a string into a token +%%sequence, as if MetaPost had read it as input. + +ìÏÇÉÞÅÓËÉÊ\index{ÌÏÇÉÞÅÓËÉÊ ÔÉÐ} ÔÉÐ (boolean) ÉÍÅÅÔ ËÏÎÓÔÁÎÔÙ {\tt +true}\index{true?\texttt{true}}\label{Dtrue} É {\tt +false}\index{false?\texttt{false}}\label{Dfalse} É ÏÐÅÒÁÔÏÒÙ {\tt +and}\index{and?\texttt{and}}\label{Dand}, {\tt +or}\index{or?\texttt{or}}\label{Dor}, {\tt +not}\index{not?\texttt{not}}\label{Dnot}. +%%The boolean\index{boolean type} type has the constants {\tt +%%true}\index{true?\texttt{true}}\label{Dtrue} and {\tt +%%false}\index{false}\label{Dfalse} and the operators {\tt +%%and}\index{and?\texttt{and}}\label{Dand}, {\tt +%%or}\index{or?\texttt{or}}\label{Dor}, {\tt +%%not}\index{not?\texttt{not}}\label{Dnot}. +ïÔÎÏÛÅÎÉÑ \verb|=| É \verb|<>|\index{<>?\texttt{<>}}\label{Dcmpar} +ÐÒÏ×ÅÒÑÀÔ ÏÂßÅËÔÙ ÌÀÂÙÈ ÔÉÐÏ× ÎÁ ÒÁ×ÅÎÓÔ×Ï É ÎÅÒÁ×ÅÎÓÔ×Ï\index{ÎÅÒÁ×ÅÎÓÔ×Ï}. +%%The relations \verb|=| and +%%\verb|<>|\index{<>?\texttt{<>}}\label{Dcmpar} test objects of any type +%%for equality and inequality\index{inequality}. +ïÔÎÏÛÅÎÉÑ ÓÒÁ×ÎÅÎÉÑ \index{ÓÒÁ×ÎÅÎÉÅ} \verb|<|\index{<?\texttt{<}}, +\verb|<=|\index{<=?\texttt{<=}}, \verb|>|\index{>?\texttt{>}} É +\verb|>=|\index{>=?\texttt{>=}} ÏÐÒÅÄÅÌÑÀÔÓÑ ÓÌÏ×ÁÒÎÏ ÄÌÑ ÓÔÒÏË É +ÏÂÙÞÎÙÍ ÓÐÏÓÏÂÏÍ ÄÌÑ ÞÉÓÅÌ. +%%Comparison\index{comparison} relations \verb|<|\index{<?\texttt{<}}, +%%\verb|<=|\index{<=?\texttt{<=}}, \verb|>|\index{>?\texttt{>}}, and +%%\verb|>=|\index{>=?\texttt{>=}} are defined lexicographically for +%%strings and in the obvious way for numerics. +ïÔÎÏÛÅÎÉÑ ÐÏÒÑÄËÁ ÏÐÒÅÄÅÌÅÎÙ ÔÁËÖÅ É ÄÌÑ ÌÏÇÉÞÅÓËÉÈ ×ÅÌÉÞÉÎ, ÐÁÒ, Ã×ÅÔÏ× É +ÔÒÁÎÓÆÏÒÍÁÃÉÊ, ÎÏ ÐÒÁ×ÉÌÁ ÉÈ ÓÒÁ×ÎÅÎÉÑ ÎÅ ÓÔÏÉÔ ÏÂÓÕÖÄÁÔØ ÚÄÅÓØ. +%%Ordering relations are +%%also defined for booleans, pairs, colors, and transforms, but the +%%comparison rules are not worth discussing here. + +ôÉÐ ÄÁÎÎÙÈ picture\index{ÔÉÐ-ÒÉÓÕÎÏË} (ÒÉÓÕÎÏË) --- ÜÔÏ × ÔÏÞÎÏÓÔÉ ÔÏ, ÞÔÏ +ÐÏÄÒÁÚÕÍÅ×ÁÅÔÓÑ ÅÇÏ ÉÍÅÎÅÍ. +%%The picture\index{picture type} data type is just what the name implies. +÷ÓÅ, ÞÔÏ ÍÏÖÎÏ ÎÁÒÉÓÏ×ÁÔØ × MetaPost, ÍÏÖÎÏ ÓÏÈÒÁÎÉÔØ × ÐÅÒÅÍÅÎÎÏÊ-ËÁÒÔÉÎËÅ. +%%Anything that can be drawn in MetaPost can be stored in a picture +%%variable. +æÁËÔÉÞÅÓËÉ ËÏÍÁÎÄÁ {\tt draw}\index{draw?\texttt{draw}} ÓÏÈÒÁÎÑÅÔ Ó×ÏÉ +ÒÅÚÕÌØÔÁÔÙ × ÏÓÏÂÏÊ ÐÅÒÅÍÅÎÎÏÊ-ËÁÒÔÉÎËÅ, ÎÁÚÙ×ÁÅÍÏÊ {\tt +currentpicture}\index{currentpicture?\texttt{currentpicture}}. +%%In fact, the {\tt draw}\index{draw?\texttt{draw}} statement +%%actually stores its results in a special picture variable called {\tt +%%currentpicture}\index{currentpicture?\texttt{currentpicture}}. +ëÁÒÔÉÎËÉ ÍÏÇÕÔ ÂÙÔØ ÄÏÂÁ×ÌÅÎÙ Ë ÄÒÕÇÉÍ ËÁÒÔÉÎËÁÍ É ÉÈ ÍÏÖÎÏ ÔÒÁÎÓÆÏÒÍÉÒÏ×ÁÔØ. +%%Pictures +%%can be added to other pictures and operated on by transforms. + +îÁËÏÎÅÃ, ÔÉÐ ÄÁÎÎÙÈ, ÎÁÚÙ×ÁÅÍÙÊ pen\index{ÔÉÐ-ÐÅÒÏ} (ÐÅÒÏ). +%%Finally, there is a data type called a pen\index{pen type}. +çÌÁ×ÎÁÑ ÆÕÎËÃÉÑ ÐÅÒØÅ× × MetaPost × ÏÐÒÅÄÅÌÅÎÉÉ ÔÏÌÝÉÎÙ ÌÉÎÉÉ, ÎÏ ÉÈ +ÔÁËÖÅ ÍÏÖÎÏ ÉÓÐÏÌØÚÏ×ÁÔØ ÄÌÑ ÄÏÓÔÉÖÅÎÉÑ ËÁÌÌÉÇÒÁÆÉÞÅÓËÉÈ ÜÆÆÅËÔÏ×. +%%The main +%%function of pens in MetaPost is to determine line thickness, but they +%%can also be used to achieve calligraphic effects. +ëÏÍÁÎÄÁ\index{pickup?\texttt{pickup}}\label{Dpickup} +$$ {\tt pickup\ }\descr{×ÙÒÁÖÅÎÉÅ-ÐÅÒÏ} $$ +ÏÂÕÓÌÏ×ÉÔ ÉÓÐÏÌØÚÏ×ÁÎÉÅ ÚÁÄÁÎÎÏÇÏ ÐÅÒÁ × ÐÏÓÌÅÄÕÀÝÉÈ ËÏÍÁÎÄÁÈ {\tt draw}. +%%The statement\index{pickup?\texttt{pickup}}\label{Dpickup} +%%$$ {\tt pickup\ }\descr{pen expression} $$ +%%causes the given pen to be used in subsequent {\tt draw} statements. + +ïÂÙÞÎÏ ×ÙÒÁÖÅÎÉÅ-ÐÅÒÏ ÉÍÅÅÔ ÆÏÒÍÕ +$$ {\tt pencircle\ scaled\ }\descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}. $$ +%%Normally, the pen expression is of the form +%%$$ {\tt pencircle\ scaled\ }\descr{numeric primary}. $$ +ïÎÏ ÏÐÒÅÄÅÌÑÅÔ ËÒÕÇÏ×ÏÅ ÐÅÒÏ, ÐÒÏÉÚ×ÏÄÑÝÅÅ ÌÉÎÉÉ ÐÏÓÔÏÑÎÎÏÊ ÔÏÌÝÉÎÙ. +%%This defines a circular pen that produces lines of constant thickness. +åÓÌÉ ÖÅÌÁÔÅÌØÎÙ ËÁÌÌÉÇÒÁÆÉÞÅÓËÉÅ ÜÆÆÅËÔÙ, ÔÏ ×ÙÒÁÖÅÎÉÅ-ÐÅÒÏ ÍÏÖÅÔ ÂÙÔØ +ÐÒÉÓÐÏÓÏÂÌÅÎÏ ÄÌÑ ÚÁÄÁÎÉÑ ÜÌÌÉÐÔÉÞÅÓËÏÇÏ ÉÌÉ ÍÎÏÇÏÕÇÏÌØÎÏÇÏ ÐÅÒÁ. +%%If calligraphic effects are desired, the pen expression can be adjusted to give +%%an elliptical pen or a polygonal pen. + +\subsection{ïÐÅÒÁÔÏÒÙ} +%%\subsection{Operators} + +åÓÔØ ÍÎÏÇÏ ÒÁÚÎÙÈ ÓÐÏÓÏÂÏ× ÓÄÅÌÁÔØ ×ÙÒÁÖÅÎÉÑ ÄÅÓÑÔÉ ÂÁÚÏ×ÙÈ ÔÉÐÏ×, ÎÏ +ÂÏÌØÛÉÎÓÔ×Ï ÏÐÅÒÁÃÉÊ ÍÏÖÎÏ ÓÏÐÏÓÔÁ×ÉÔØ ÓÒÁ×ÎÉÔÅÌØÎÏ ÐÒÏÓÔÏÍÕ +ÓÉÎÔÁËÓÉÓÕ Ó ÞÅÔÙÒØÍÑ ÕÒÏ×ÎÑÍÉ ÐÒÉÏÒÉÔÅÔÁ ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{syexpr}. +%%There are many different ways to make expressions of the ten basic +%%types, but most of the operations fit into a fairly simple syntax with +%%four levels of precedence as shown in Figure~\ref{syexpr}. +åÓÔØ ÐÅÒ×ÉÞÎÏÓÔÉ\index{ÐÅÒ×ÉÞÎÏÓÔØ?\tdescr{ÐÅÒ×ÉÞÎÏÓÔØ}}, +×ÔÏÒÉÞÎÏÓÔÉ\index{×ÔÏÒÉÞÎÏÓÔØ?\tdescr{×ÔÏÒÉÞÎÏÓÔØ}}, +ÔÒÅÔÉÞÎÏÓÔÉ\index{ÔÒÅÔÉÞÎÏÓÔØ?\tdescr{ÔÒÅÔÉÞÎÏÓÔØ}} É +×ÙÒÁÖÅÎÉÑ\index{×ÙÒÁÖÅÎÉÅ?\tdescr{×ÙÒÁÖÅÎÉÅ}} ËÁÖÄÏÇÏ ÉÚ ÂÁÚÏ×ÙÈ ÔÉÐÏ×, +ÐÏÜÔÏÍÕ ÓÉÎÔÁËÓÉÞÅÓËÉÅ ÐÒÁ×ÉÌÁ ÍÏÇÕÔ ÕÔÏÞÎÑÔØÓÑ ÄÌÑ ÒÁÂÏÔÙ Ó ÔÁËÉÍÉ +ÓÕÝÎÏÓÔÑÍÉ ËÁË \tdescr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}, \tdescr{ÌÏÇÉÞÅÓËÁÑ ÔÒÅÔÉÞÎÏÓÔØ} +É Ô.~Ä. +%%There are +%%primaries\index{primary?\tdescr{primary}}, +%%secondaries\index{secondary?\tdescr{secondary}}, +%%tertiaries\index{tertiary?\tdescr{tertiary}}, and +%%expressions\index{expression?\tdescr{expression}} of each of the basic +%%types, so the syntax rules could be specialized to deal with items such +%%as \tdescr{numeric primary}, \tdescr{boolean tertiary}, etc. +üÔÏ ÐÏÚ×ÏÌÑÅÔ ÔÉÐÕ ÒÅÚÕÌØÔÁÔÁ ÏÐÅÒÁÃÉÉ ÚÁ×ÉÓÅÔØ ÏÔ ×ÙÂÏÒÁ ÏÐÅÒÁÔÏÒÁ É ÔÉÐÏ× +ÏÐÅÒÁÎÄÏ×. +%%This +%%allows the result type for an operation to depend on the choice of +%%operator and the types of its operands. +îÁÐÒÉÍÅÒ, ÏÔÎÏÛÅÎÉÅ {\tt <} --- ÜÔÏ \tdescr{ÔÒÅÔÉÞÎÁÑ ÂÉÎÁÒÎÏÓÔØ}, ËÏÔÏÒÕÀ +ÍÏÖÎÏ ÐÒÉÍÅÎÉÔØ Ë \tdescr{ÞÉÓÌÏ×ÏÍÕ ×ÙÒÁÖÅÎÉÀ} É Ë \tdescr{ÞÉÓÌÏ×ÏÊ ÔÒÅÔÉÞÎÏÓÔÉ} +ÄÌÑ ÐÏÌÕÞÅÎÉÑ \tdescr{ÌÏÇÉÞÅÓËÏÇÏ ×ÙÒÁÖÅÎÉÑ}. +%%For example, the {\tt <} +%%relation is a \tdescr{tertiary binary} that can be applied to a +%%\tdescr{numeric expression} and a \tdescr{numeric tertiary} to give a +%%\tdescr{boolean expression}. +üÔÏÔ ÖÅ ÏÐÅÒÁÔÏÒ ÍÏÖÅÔ ÄÏÐÕÓËÁÔØ ÄÒÕÇÉÅ ÔÉÐÙ ÏÐÅÒÁÎÄÏ× ÔÁËÉÅ ËÁË +\tdescr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} É \tdescr{ÓÔÒÏËÏ×ÁÑ ÔÒÅÔÉÞÎÏÓÔØ}, ÎÏ +ÒÅÚÕÌØÔÁÔÏÍ × ÓÌÕÞÁÅ ÎÅÓÏ×ÐÁÄÅÎÉÑ ÔÉÐÏ× ÏÐÅÒÁÎÄÏ× ÂÕÄÅÔ ÓÏÏÂÝÅÎÉÅ Ï +ÏÛÉÂËÅ. +%%The same operator can accept other operand +%%types such as \tdescr{string expression} and \tdescr{string tertiary}, +%%but an error message results if the operand types do not match. + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÐÅÒ×ÉÞÎÏÓÔØ} \rightarrow \descr{ÐÅÒÅÍÅÎÎÁÑ}$\\ +%%$\tt \descr{primary} \rightarrow \descr{variable}$\\ +$\tt \qquad \;|\; \hbox{\tt (}\descr{×ÙÒÁÖÅÎÉÅ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; \hbox{\tt (}\descr{expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; \descr{ÏÐÅÒÁÔÏÒ 0-ÕÒÏ×ÎÑ}$\\ +%%$\tt \qquad \;|\; \descr{nullary op}$\\ +$\tt \qquad \;|\; \descr{of-ÏÐÅÒÁÔÏÒ} \descr{×ÙÒÁÖÅÎÉÅ} + of \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{of operator} \descr{expression} +%% of \descr{primary}$\\ +$\tt \qquad \;|\; \descr{ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{unary op} \descr{primary}$\\ +$\tt \descr{×ÔÏÒÉÞÎÏÓÔØ} \rightarrow \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{secondary} \rightarrow \descr{primary}$\\ +$\tt \qquad \;|\; \descr{×ÔÏÒÉÞÎÏÓÔØ} \descr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎ. ÏÐ-Ò} \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{secondary} \descr{primary binop} \descr{primary}$\\ +$\tt \descr{ÔÒÅÔÉÞÎÏÓÔØ} \rightarrow \descr{×ÔÏÒÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{tertiary} \rightarrow \descr{secondary}$\\ +$\tt \qquad \;|\; \descr{ÔÒÅÔÉÞÎÏÓÔØ} \descr{×ÔÏÒÉÞÎÙÊ ÂÉÎ. ÏÐ-Ò} + \descr{×ÔÏÒÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{tertiary} \descr{secondary binop} +%% \descr{secondary}$\\ +$\tt \descr{×ÙÒÁÖÅÎÉÅ} \rightarrow \descr{ÔÒÅÔÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{expression} \rightarrow \descr{tertiary}$\\ +$\tt \qquad \;|\; \descr{×ÙÒÁÖÅÎÉÅ} \descr{ÔÒÅÔÉÞÎÙÊ ÂÉÎ. ÏÐ-Ò} + \descr{ÔÒÅÔÉÞÎÏÓÔØ}$ +%%$\tt \qquad \;|\; \descr{expression} \descr{tertiary binop} +%% \descr{tertiary}$ +\end{ctabbing} +\caption{ïÂÝÉÅ ÓÉÎÔÁËÓÉÞÅÓËÉÅ ÐÒÁ×ÉÌÁ ÄÌÑ ×ÙÒÁÖÅÎÉÊ} +%%\caption{The overall syntax rules for expressions} +\index{ÕÎÁÒÎÙÊ op?\tdescr{ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}} \index{ÏÐÅÒÁÔÏÒ 0?\tdescr{ÏÐÅÒÁÔÏÒ 0-ÕÒÏ×ÎÑ}} +\index{ÐÅÒ×ÉÞÎÙÊ binop?\tdescr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}} +\index{×ÔÏÒÉÞÎÙÊ binop?\tdescr{×ÔÏÒÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}} +\index{ÔÒÅÔÉÞÎÙÊ binop?\tdescr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}} +%%\index{unary op?\tdescr{unary op}} \index{nullary op?\tdescr{nullary op}} +%%\index{primary binop?\tdescr{primary binop}} +%%\index{secondary binop?\tdescr{secondary binop}} +%%\index{tertiary binop?\tdescr{tertiary binop}} +\label{syexpr} +\end{figure} + +ïÐÅÒÁÔÏÒÙ ÕÍÎÏÖÅÎÉÑ É ÄÅÌÅÎÉÑ, {\tt *}\label{Dmldiv} É~{\tt +/}, --- ÐÒÉÍÅÒÙ ÔÏÇÏ, ÞÔÏ ÎÁ ÒÉÓ.~\ref{syexpr} ÚÏ×ÅÔÓÑ \tdescr{ÐÅÒ×ÉÞÎÙÍ +ÂÉÎÁÒÎÙÍ ÏÐÅÒÁÔÏÒÏÍ}. +%%The multiplication and division operators {\tt *}\label{Dmldiv} and~{\tt +%%/} are examples of what Figure~\ref{syexpr} calls a \tdescr{primary +%%binop}. +ëÁÖÄÙÊ ÉÚ ÎÉÈ ÍÏÖÅÔ ÄÏÐÕÓËÁÔØ Ä×Á ÞÉÓÌÏ×ÙÈ ÏÐÅÒÁÎÄÁ ÉÌÉ ÏÄÉÎ ÞÉÓÌÏ×ÏÊ +ÏÐÅÒÁÎÄ É ÏÄÉÎ ÔÉÐÁ ÐÁÒÁ ÉÌÉ Ã×ÅÔ. +%%Each can accept two numeric operands or one numeric operand and +%%one operand of type pair or color. +ïÐÅÒÁÔÏÒ ×ÏÚ×ÅÄÅÎÉÑ × ÓÔÅÐÅÎØ \verb|**|\index{**?\texttt{**}}\index{ÓÔÅÐÅÎØ}\label{Dpow} +--- ÜÔÏ \tdescr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}, ËÏÔÏÒÙÊ ÔÒÅÂÕÅÔ Ä×Á ÞÉÓÌÏ×ÙÈ ÏÐÅÒÁÎÄÁ. +%%The exponentiation operator +%%\verb|**|\index{**?\texttt{**}}\index{exponentiation}\label{Dpow} is a +%%\tdescr{primary binop} that requires two numeric operands. +òÁÚÍÅÝÅÎÉÅ ÅÇÏ ÎÁ ÔÏÍ ÖÅ ÕÒÏ×ÎÅ ÐÒÉÏÒÉÔÅÔÁ, ÞÔÏ É ÕÍÎÏÖÅÎÉÅ É ÄÅÌÅÎÉÅ, ÉÍÅÅÔ +ÎÅÐÒÉÑÔÎÏÅ ÐÏÓÌÅÄÓÔ×ÉÅ × ÔÏÍ, ÞÔÏ \verb|3*a**2| ÚÎÁÞÉÔ $(3a)^2$, Á ÎÅ +$3(a^2)$\index{ÎÅÒÅÇÕÌÑÒÎÏÓÔÉ ÒÁÚÂÏÒÁ}. +%%Placing this +%%at the same level of precedence as multiplication and division has the +%%unfortunate consequence that \verb|3*a**2| means $(3a)^2$, not +%%$3(a^2)$\index{parsing irregularities}. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÕÎÁÒÎÙÊ ÍÉÎÕÓ\label{Dneg} ÏÔÎÏÓÉÔÓÑ Ë ÐÅÒ×ÉÞÎÏÍÕ ÕÒÏ×ÎÀ, ÏÎ ÔÁËÖÅ +ÐÒÉ×ÏÄÉÔ Ë ÎÅÕÄÏÂÏÞÉÔÁÅÍÏÓÔÉ ÔÉÐÁ \verb|-a**2|, ÏÚÎÁÞÁÀÝÅÊ $(-a)^2$. +%%Since unary +%%negation\label{Dneg} applies at the primary level, it also turns out +%%that \verb|-a**2| means $(-a)^2$. +ë ÓÞÁÓÔØÀ, ×ÙÞÉÔÁÎÉÅ ÉÍÅÅÔ ÍÅÎØÛÉÊ ÐÒÉÏÒÉÔÅÔ É \verb|a-b**2| +ÏÚÎÁÞÁÅÔ $a-(b^2)$ ×ÍÅÓÔÏ $(a-b)^2$ +%%Fortunately, subtraction has lower +%%precedence so that \verb|a-b**2| does mean $a-(b^2)$ instead of +%%$(a-b)^2$. + +äÒÕÇÉÍ \tdescr{ÐÅÒ×ÉÞÎÙÍ ÂÉÎÁÒÎÙÍ ÏÐÅÒÁÔÏÒÏÍ} Ñ×ÌÑÅÔÓÑ ÏÐÅÒÁÔÏÒ {\tt +dotprod}\index{dotprod?\texttt{dotprod}}\label{Ddprod}, ×ÙÞÉÓÌÑÀÝÉÊ +ÓËÁÌÑÒÎÏÅ ÐÒÏÉÚ×ÅÄÅÎÉÅ Ä×ÕÈ ÐÁÒ. +%%Another \tdescr{primary binop} is the {\tt +%%dotprod}\index{dotprod?\texttt{dotprod}}\label{Ddprod} operator that +%%computes the vector dot product of two pairs. +îÁÐÒÉÍÅÒ, {\tt z1 dotprod z2} ÜË×É×ÁÌÅÎÔÎÏ {\tt x1*x2 + y1*y2}. +%%For example, {\tt z1 +%%dotprod z2} is equivalent to {\tt x1*y1 + x2*y2}. + +áÄÄÉÔÉ×ÎÙÅ ÏÐÅÒÁÔÏÒÙ {\tt -} É {\tt +}\label{Dadd} --- +\tdescr{×ÔÏÒÉÞÎÙÅ ÂÉÎÁÒÎÙÅ ÏÐÅÒÁÔÏÒÙ}, ÐÒÉÍÅÎÉÍÙÅ Ë ÞÉÓÌÁÍ, ÐÁÒÁÍ ÉÌÉ +Ã×ÅÔÁÍ É ÐÒÏÉÚ×ÏÄÑÝÉÅ ÒÅÚÕÌØÔÁÔÙ ÔÏÇÏ ÖÅ ÔÉÐÁ. +%%The additive operators {\tt +} and {\tt -}\label{Dadd} are +%%\tdescr{secondary binops} that operate on numerics, pairs, or colors and +%%produce results of the same type. +äÒÕÇÉÅ ÏÐÅÒÁÔÏÒÙ, ÞÔÏ ÐÏÐÁÄÁÀÔ × ÜÔÕ ËÁÔÅÇÏÒÉÀ --- ÜÔÏ ``ðÉÆÁÇÏÒÏ×Ï +ÓÌÏÖÅÎÉÅ'' \verb|++|\index{++?\texttt{++}}\label{Dpyadd} É ``ðÉÆÁÇÏÒÏ×Ï +×ÙÞÉÔÁÎÉÅ'' \verb|+-+|\index{+-+?\texttt{+-+}}\label{Dpysub}: +\verb|a++b| ÚÎÁÞÉÔ $\sqrt{a^2+b^2}$ É \verb|a+-+b| ÚÎÁÞÉÔ +$\sqrt{a^2-b^2}$. +%%Other operators that fall in this +%%category are ``Pythagorean addition'' +%%\verb|++|\index{++?\texttt{++}}\label{Dpyadd} and ``Pythagorean +%%subtraction'' \verb|+-+|\index{+-+?\texttt{+-+}}\label{Dpysub}: +%%\verb|a++b| means $\sqrt{a^2+b^2}$ and \verb|a+-+b| means +%%$\sqrt{a^2-b^2}$. +åÓÔØ ÅÝÅ ÓÌÉÛËÏÍ ÍÎÏÇÏ ÄÒÕÇÉÈ ÏÐÅÒÁÔÏÒÏ× ÄÌÑ ÐÅÒÅÞÉÓÌÅÎÉÑ ÚÄÅÓØ, ÎÏ +ÏÄÎÉ ÉÚ ÓÁÍÙÈ ×ÁÖÎÙÈ --- ÜÔÏ ÌÏÇÉÞÅÓËÉÅ ÏÐÅÒÁÔÏÒÙ {\tt +and}\index{and?\texttt{and}} É {\tt or}\index{or?\texttt{or}}. +%%There are too many other operators to list here, but +%%some of the most important are the boolean operators {\tt +%%and}\index{and?\texttt{and}} and {\tt or}\index{or?\texttt{or}}. +ïÐÅÒÁÔÏÒ {\tt and} --- ÜÔÏ \tdescr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} É ÏÐÅÒÁÔÏÒ +{\tt or} --- ÜÔÏ \tdescr{×ÔÏÒÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}. +%%The +%%{\tt and} operator is a \tdescr{primary binop} and the {\tt or} operator +%%is a \tdescr{secondary binop}. + +âÁÚÏ×ÙÅ ÏÐÅÒÁÃÉÉ ÓÏ ÓÔÒÏËÁÍÉ --- ÜÔÏ ÓËÌÅÊËÁ\index{ÓËÌÅÊËÁ}, +×ÙÄÅÌÅÎÉÅ ÐÏÄÓÔÒÏËÉ É ×ÙÞÉÓÌÅÎÉÅ ÄÌÉÎÙ ÓÔÒÏËÉ. +%%e basic operations on strings are concatenation\index{concatenation}, +%%substring construction and calculating the length of a string. +óËÌÅÊËÁ ÒÅÁÌÉÚÕÅÔÓÑ \tdescr{ÔÒÅÔÉÞÎÙÍ ÂÉÎÁÒÎÙÍ +ÏÐÅÒÁÔÏÒÏÍ} \verb|&|\index{&?\texttt{\&}}\label{Damp}, ÎÁÐÒÉÍÅÒ, +%%The \tdescr{tertiary binop} \verb|&|\index{&?\texttt{\&}}\label{Damp} +%%implements concatenation; e.g., +$$ \hbox{\verb|"abc" & "de"|} $$ +ÐÒÏÉÚ×ÏÄÉÔ ÓÔÒÏËÕ \verb|"abcde"|. +%%produces the string \verb|"abcde"|. +ïÐÅÒÁÔÏÒ {\tt +length}\index{length?\texttt{length}}\label{DlengthString} ×ÏÚ×ÒÁÝÁÅÔ +ÞÉÓÌÏ ÓÉÍ×ÏÌÏ× × ÓÔÒÏËÅ, ÅÓÌÉ ÁÒÇÕÍÅÎÔÏÍ Ñ×ÌÑÅÔÓÑ \tdescr{ÓÔÒÏËÏ×ÁÑ +ÐÅÒ×ÉÞÎÏÓÔØ}, ÎÁÐÒÉÍÅÒ, +%%The {\tt +%%length}\index{length?\texttt{length}}\label{DlengthString} operator +%%returns the number of characters in a string if the argument is a +%%\tdescr{string primary}; e.g., +$$ \hbox{\verb|length "abcde"|} $$ +×ÏÚ×ÒÁÝÁÅÔ \verb|5|. +%%returns \verb|5|. +äÒÕÇÏÅ ÐÒÉÍÅÎÅÎÉÅ ÏÐÅÒÁÔÏÒÁ {\tt length} ÏÂÓÕÖÄÁÅÔÓÑ ÎÁ +ÓÔÒ.\ \pageref{Dlength}. +%%Another application of the {\tt length} operator is +%%discussed on p.\ \pageref{Dlength}. +äÌÑ ×ÙÄÅÌÅÎÉÑ ÐÏÄÓÔÒÏËÉ \tdescr{of-ÏÐÅÒÁÔÏÒ} +{\tt substring}\index{substring +of?\texttt{substring of}}\label{Dsubstr} ÉÓÐÏÌØÚÕÅÔÓÑ ÔÁËÉÍ ÏÂÒÁÚÏÍ: +$$ {\tt substring}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ} \,{\tt of}\, \descr{ÓÔÒÏËÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ} $$ +%%For substring construction, the +%%\tdescr{of operator} {\tt substring}\index{substring +%%of?\texttt{substring of}}\label{Dsubstr} is used like this: +%%$$ {\tt substring}\, \descr{pair expression} \,{\tt of}\, \descr{string primary} $$ +þÁÓÔØ ÓÔÒÏËÉ ÄÌÑ ×ÙÄÅÌÅÎÉÅ ÏÐÒÅÄÅÌÑÅÔÓÑ \tdescr{×ÙÒÁÖÅÎÉÅÍ-ÐÁÒÏÊ}. +%%The \tdescr{pair expression} determines what part of the string to +%%select. +ðÏÚÉÃÉÉ × ÓÔÒÏËÅ ÎÕÍÅÒÕÀÔÓÑ\index{ÉÎÄÅËÓÁÃÉÑ} ÔÁË, ÞÔÏ ÃÅÌÙÅ ÐÏÚÉÃÉÉ +ÐÏÐÁÄÁÀÔ {\em ÍÅÖÄÕ\/} ÓÉÍ×ÏÌÁÍÉ. +%%For this purpose, the string is indexed\index{indexing} so that +%%integer positions fall {\em between\/} characters. +ðÒÅÄÓÔÁ×ÉÍ ÓÔÒÏËÕ, ÎÁÐÉÓÁÎÎÕÀ ÎÁ ËÕÓÏÞËÅ ÂÕÍÁÇÅ × ËÌÅÔËÕ ÔÁË, ÞÔÏ ÐÅÒ×ÙÊ +ÓÉÍ×ÏÌ ÚÁÊÍÅÔ $x$-ËÏÏÒÄÉÎÁÔÙ ÍÅÖÄÕ ÎÕÌÅÍ É ÅÄÉÎÉÃÅÊ, Á ÓÌÅÄÕÀÝÉÊ ÓÉÍ×ÏÌ +ÐÏËÒÏÅÔ ËÏÏÒÄÉÎÁÔÙ × ÄÉÁÐÁÚÏÎÅ $1\leqslant x\leqslant2$, É Ô.~Ä. +%%Pretend the string +%%is written on a piece of graph paper so that the first character +%%occupies $x$~coordinates between zero and one and the next character +%%covers the range $1\le x\le2$, etc. +ðÏÜÔÏÍÕ ÓÔÒÏËÕ \verb|"abcde"| ÓÌÅÄÕÅÔ ÐÒÅÄÓÔÁ×ÌÑÔØ × ×ÉÄÅ +%%Thus the string \verb|"abcde"| +%%should be thought of like this +$$ \includegraphics{manfig-ru-14} $$ +É {\tt substring (2,4) of {\qq}abcde{\qq}} ÂÕÄÅÔ {\tt {\qq}cd{\qq}}. +%%and {\tt substring (2,4) of {\qq}abcde{\qq}} is {\tt {\qq}cd{\qq}}. +üÔÏ ×ÙÇÌÑÄÉÔ ÎÅÓËÏÌØËÏ ÕÓÌÏÖÎÅÎÏ, ÎÏ ÉÍÅÅÔ ÃÅÌØÀ ÉÚÂÅÖÁÔØ ÎÁÄÏÅÄÁÀÝÉÈ +ÏÛÉÂÏË ``ÎÁ ÅÄÉÎÉÃÕ''. +%%This takes a little +%%getting used to but it tends to avoid annoying ``off by one'' errors. + +îÅËÏÔÏÒÙÅ ÏÐÅÒÁÔÏÒÙ ÎÅ ÂÅÒÕÔ ÁÒÇÕÍÅÎÔÏ× ×ÏÏÂÝÅ. +%%Some operators take no arguments at all. +ðÒÉÍÅÒ ÔÏÇÏ, ÞÔÏ ÎÁ ÒÉÓ.~\ref{syexpr} ÚÏ×ÅÔÓÑ \tdescr{ÏÐÅÒÁÔÏÒÏÍ 0-ÕÒÏ×ÎÑ}, --- +ÜÔÏ {\tt +nullpicture}\index{nullpicture?\texttt{nullpicture}}\label{Dnlpic}, +ËÏÔÏÒÙÊ ×ÏÚ×ÒÁÝÁÅÔ ÓÏ×ÅÒÛÅÎÎÏ ÐÕÓÔÕÀ ËÁÒÔÉÎËÕ. +%%An example of what +%%Figure~\ref{syexpr} calls a \tdescr{nullary op} is {\tt +%%nullpicture}\index{nullpicture?\texttt{nullpicture}}\label{Dnlpic} which +%%returns a completely blank picture. + +âÁÚÏ×ÙÊ ÓÉÎÔÁËÓÉÓ ÎÁ ÒÉÓ.~\ref{syexpr} ÐÏËÒÙ×ÁÅÔ ÔÏÌØËÏ ÔÅ ÁÓÐÅËÔÙ +ÓÉÎÔÁËÓÉÓÁ ×ÙÒÁÖÅÎÉÊ, ËÏÔÏÒÙÅ Ñ×ÌÑÀÔÓÑ ÎÅÚÁ×ÉÓÉÍÙÍÉ ÏÔ ÔÉÐÁ. +%%The basic syntax in Figure~\ref{syexpr} only covers aspects of the +%%expression syntax that are relatively type-independent. +îÁÐÒÉÍÅÒ, ÎÅÐÒÏÓÔÏÊ ÓÉÎÔÁËÓÉÓ ÐÕÔÉ ÎÁ ÒÉÓ.~\ref{sypath}, ÄÁÅÔ +ÁÌØÔÅÒÎÁÔÉ×ÎÙÅ ÐÒÁ×ÉÌÁ ÄÌÑ ËÏÎÓÔÒÕÉÒÏ×ÁÎÉÑ \tdescr{×ÙÒÁÖÅÎÉÑ-ÐÕÔÉ}. +%%For instance, +%%the complicated path syntax given in Figure~\ref{sypath} gives +%%alternative rules for constructing a \tdescr{path expression}. +äÏÐÏÌÎÉÔÅÌØÎÏÅ ÐÒÁ×ÉÌÏ\index{ÕÚÅÌ ÐÕÔÉ?\tdescr{ÕÚÅÌ ÐÕÔÉ}} +$$ \descr{ÕÚÅÌ ÐÕÔÉ} \rightarrow \descr{ÔÒÅÔÉÞÎÁÑ ÐÁÒÁ} \;|\; \descr{ÔÒÅÔÉÞÎÙÊ ÐÕÔØ} +$$ +ÏÂßÑÓÎÑÅÔ ÚÎÁÞÅÎÉÅ \tdescr{ÕÚÌÁ ÐÕÔÉ} ÎÁ ÒÉÓ.~\ref{sypath}. +%%An +%%additional rule\index{path knot?\tdescr{path knot}} +%%$$ \descr{path knot} \rightarrow \descr{pair tertiary} \;|\; \descr{path tertiary} +%%$$ +%%explains the meaning of \tdescr{path knot} in Figure~\ref{sypath}. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ×ÙÒÁÖÅÎÉÅ-ÐÕÔØ +%%This means +%%that the path expression +$$ \hbox{\verb|z1+(1,1){right}..z2|} $$ +ÎÅ ÎÕÖÄÁÅÔÓÑ × ÓËÏÂËÁÈ ×ÏËÒÕÇ {\tt z1+(1,1)}. +%%does not need parentheses around {\tt z1+(1,1)}. + +\subsection{äÒÏÂÉ, ÕÓÒÅÄÎÅÎÉÑ É ÕÎÁÒÎÙÅ ÏÐÅÒÁÔÏÒÙ} +%%\subsection{Fractions, Mediation, and Unary Operators} + +÷ÙÒÁÖÅÎÉÑ ÕÓÒÅÄÎÅÎÉÑ\index{ÕÓÒÅÄÎÅÎÉÅ} ÏÔÓÕÔÓÔ×ÕÀÔ × ÓÉÎÔÁËÓÉÓÅ ÂÁÚÏ×ÏÇÏ +×ÙÒÁÖÅÎÉÑ ÎÁ ÒÉÓ.~\ref{syexpr}. +%%Mediation\index{mediation} expressions do not appear in the basic expression +%%syntax of Figure~\ref{syexpr}. +÷ÙÒÁÖÅÎÉÑ ÕÓÒÅÄÎÅÎÉÑ ÒÁÚÂÉÒÁÀÔÓÑ ÎÁ \tdescr{ÐÅÒ×ÉÞÎÏÍ} ÕÒÏ×ÎÅ, ÔÁË ÞÔÏ +ÏÂÝÅÅ ÐÒÁ×ÉÌÏ ÄÌÑ ÉÈ ËÏÎÓÔÒÕÉÒÏ×ÁÎÉÑ ÓÌÅÄÕÀÝÅÅ +$$ \descr{ÐÅÒ×ÉÞÎÏÓÔØ} \rightarrow + \descr{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ} \hbox{\tt [} \descr{×ÙÒÁÖÅÎÉÅ} + \hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ} \hbox{\tt ]}, +$$ +ÇÄÅ ËÁÖÄÏÅ \tdescr{×ÙÒÁÖÅÎÉÅ} ÍÏÖÅÔ ÂÙÔØ ÔÉÐÁ ÞÉÓÌÏ, ÐÁÒÁ ÉÌÉ Ã×ÅÔ. +%%Mediation expressions are parsed at the +%%\tdescr{primary} level, so the general rule for constructing them is +%%$$ \descr{primary} \rightarrow +%% \descr{numeric atom} \hbox{\tt [} \descr{expression} +%% \hbox{\tt ,} \descr{expression} \hbox{\tt ]} +%%$$ +%%where each \tdescr{expression} can be of type numeric, pair, or color. +\tdescr{þÉÓÌÏ×ÏÊ ÁÔÏÍ}\index{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ?\tdescr{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ}} × +×ÙÒÁÖÅÎÉÉ ÕÓÒÅÄÎÅÎÉÑ ÉÍÅÅÔ ÏÞÅÎØ ÐÒÏÓÔÏÊ ÔÉÐ \tdescr{ÞÉÓÌÏ×ÏÊ ÐÅÒ×ÉÞÎÏÓÔÉ}, +ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{synprim}. +%%The \tdescr{numeric atom}\index{numeric atom?\tdescr{numeric atom}} in a +%%mediation expression is an extra simple type of \tdescr{numeric primary} +%%as shown in Figure~\ref{synprim}. +úÎÁÞÅÎÉÅÍ ×ÓÅÇÏ ÜÔÏÇÏ Ñ×ÌÑÅÔÓÑ ÔÏ, ÞÔÏ ÐÅÒ×ÙÊ ÐÁÒÁÍÅÔÒ × ×ÙÒÁÖÅÎÉÉ +ÕÓÒÅÄÎÅÎÉÑ ÔÒÅÂÕÅÔ ÚÁËÌÀÞÅÎÉÑ × ÓËÏÂËÉ, ÅÓÌÉ ÏÎ × ÔÏÞÎÏÓÔÉ ÎÅ ÐÅÒÅÍÅÎÎÁÑ, +ÎÅ ÐÏÌÏÖÉÔÅÌØÎÏÅ ÞÉÓÌÏ ÉÌÉ ÎÅ ÐÏÌÏÖÉÔÅÌØÎÁÑ ÄÒÏÂØ. +%%The meaning of all this is that the +%%initial parameter in a mediation expression needs to be parenthesized +%%when it is not just a variable, a positive number, or a positive +%%fraction. +îÁÐÒÉÍÅÒ,\index{ÎÅÒÅÇÕÌÑÒÎÏÓÔÉ ÒÁÚÂÏÒÁ} +$$ \hbox{\tt -1[a,b]} \quad {\rm É}\quad \hbox{\tt (-1)[a,b]} $$ +ÏÞÅÎØ ÒÁÚÌÉÞÎÙ: ÐÅÒ×ÏÅ --- ÜÔÏ $-b$, Ô.~Ë. ÏÎÏ ÜË×É×ÁÌÅÎÔÎÏ +{\tt -(1[a,b])}; ×ÔÏÒÏÅ --- ÜÔÏ $a-(b-a)$ ÉÌÉ $2a-b$. +%%For example,\index{parsing irregularities} +%%$$ \hbox{\tt -1[a,b]} \quad {\rm and}\quad \hbox{\tt (-1)[a,b]} $$ +%%are very different: the former is $-b$ since it is equivalent to +%%{\tt -(1[a,b])}; the latter is $a-(b-a)$ or $2a-b$. + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ} \rightarrow \descr{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ}$\\ +%%$\tt \descr{numeric primary} \rightarrow \descr{numeric atom}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ}\hbox{\tt [} + \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt ]}$\\ +%%$\tt \qquad \;|\; \descr{numeric atom}\hbox{\tt [} +%% \descr{numeric expression}\hbox{\tt ,}\descr{numeric expression}\hbox{\tt ]}$\\ +$\tt \qquad \;|\; \descr{of-ÏÐÅÒÁÔÏÒ} \descr{×ÙÒÁÖÅÎÉÅ} of \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{of operator} \descr{expression} of \descr{primary}$\\ +$\tt \qquad \;|\; \descr{ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{unary op} \descr{primary}$\\ +$\tt \descr{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ} \rightarrow \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒÅÍÅÎÎÁÑ}$\\ +%%$\tt \descr{numeric atom} \rightarrow \descr{numeric variable}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ ÉÌÉ ÄÒÏÂØ}$\\ +%%$\tt \qquad \;|\; \descr{number or fraction}$\\ +$\tt \qquad \;|\; \hbox{\tt (}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; \hbox{\tt (}\descr{numeric expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ×ÏÊ ÏÐÅÒÁÔÏÒ 0-ÕÒÏ×ÎÑ}$\\ +%%$\tt \qquad \;|\; \descr{numeric nullary op}$\\ +$\tt \descr{ÞÉÓÌÏ ÉÌÉ ÄÒÏÂØ} \rightarrow \descr{ÞÉÓÌÏ} + \hbox{\tt /}\descr{ÞÉÓÌÏ}$\\ +%%$\tt \descr{number or fraction} \rightarrow \descr{number} +%% \hbox{\tt /}\descr{number}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ, ÚÁ ËÏÔÏÒÙÍ ÎÅÔ + `$\hbox{\tt /}\descr{ÞÉÓÌÁ}$'}$ +%%$\tt \qquad \;|\; \descr{number not followed by +%% `$\hbox{\tt /}\descr{number}$'}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÞÅÓËÉÅ ÐÒÁ×ÉÌÁ ÄÌÑ ÞÉÓÌÏ×ÙÈ ÐÅÒ×ÉÞÎÏÓÔÅÊ} +%%\caption{Syntax rules for numeric primaries} +\label{synprim} +\end{figure} + +úÁÍÅÔÎÙÍ Ó×ÏÊÓÔ×ÏÍ ÓÉÎÔÁËÓÉÞÅÓËÉÈ ÐÒÁ×ÉÌ ÎÁ ÒÉÓ.~\ref{synprim} +Ñ×ÌÑÅÔÓÑ ÔÏ, ÞÔÏ ÏÐÅÒÁÔÏÒ {\tt /}\index{ÄÒÏÂÉ} Ó×ÑÚÙ×ÁÅÔ ÂÏÌÅÅ ËÒÅÐËÏ, +ËÏÇÄÁ ÅÇÏ ÏÐÅÒÁÎÄÙ Ñ×ÌÑÀÔÓÑ ÞÉÓÌÁÍÉ. +%%A noteworthy feature of the syntax rules in Figure~\ref{synprim} is that +%%the {\tt /}\index{fractions} operator binds most tightly when its +%%operands are numbers. +ôÁËÉÍ ÏÂÒÁÚÏÍ, {\tt 2/3} --- ÜÔÏ \tdescr{ÞÉÓÌÏ×ÏÊ +ÁÔÏÍ}\index{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ?\tdescr{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ}}\index{ÎÅÒÅÇÕÌÑÒÎÏÓÔÉ +ÒÁÚÂÏÒÁ}, Á {\tt (1+1)/3} --- ÜÔÏ ÔÏÌØËÏ \tdescr{ÞÉÓÌÏ×ÁÑ +×ÔÏÒÉÞÎÏÓÔØ}. +%%Thus {\tt 2/3} is a \tdescr{numeric +%%atom}\index{numeric atom?\tdescr{numeric atom}}\index{parsing +%%irregularities} while {\tt (1+1)/3} is only a \tdescr{numeric +%%secondary}. +ðÒÉÍÅÎÅÎÉÅ \tdescr{ÕÎÁÒÎÏÇÏ ÏÐÅÒÁÔÏÒÁ}, ÔÁËÏÇÏ ËÁË {\tt +sqrt}\index{sqrt?\texttt{sqrt}}\label{Dsqrt}, ÄÅÌÁÅÔ ÒÁÚÎÉÃÕ ÏÞÅ×ÉÄÎÏÊ: +$$ \hbox{\tt sqrt 2/3} $$ +ÚÎÁÞÉÔ $\sqrt{2\over3}$, Á +$$ \hbox{\tt sqrt(1+1)/3} $$ +ÚÎÁÞÉÔ $\sqrt 2/3$. +%%Applying a \tdescr{primary binop} such as {\tt +%%sqrt}\index{sqrt?\texttt{sqrt}}\label{Dsqrt} makes the difference clear: +%%$$ \hbox{\tt sqrt 2/3} $$ +%%means $\sqrt{2\over3}$ while +%%$$ \hbox{\tt sqrt(1+1)/3} $$ +%%means $\sqrt 2/3$. +ïÐÅÒÁÔÏÒÙ, ÔÁËÉÅ ËÁË {\tt sqrt}, ÍÏÇÕÔ ÂÙÔØ ÚÁÐÉÓÁÎÙ × ÓÔÁÎÄÁÒÔÎÏÊ +ÆÕÎËÃÉÏÎÁÌØÎÏÊ ÎÏÔÁÃÉÉ, ÎÏ ÞÁÓÔÏ ÎÅÔ ÎÕÖÄÙ ÂÒÁÔØ ÁÒÇÕÍÅÎÔ × ÓËÏÂËÉ. +%%Operators such as {\tt sqrt} can be written in +%%standard functional notation, but it is often unnecessary to +%%parenthesize the argument. +üÔÏ ×ÅÒÎÏ ÄÌÑ ÌÀÂÏÊ ÆÕÎËÃÉÉ, ÞÔÏ ÒÁÚÂÉÒÁÅÔÓÑ ËÁË \tdescr{ÕÎÁÒÎÁÑ ÏÐÅÒÁÃÉÑ}. +%%This applies to any function that is parsed +%%as a \tdescr{primary binop}. +îÁÐÒÉÍÅÒ, É {\tt abs(x)}\index{abs?\texttt{abs}}\label{Dabs}, É {\tt abs x} +×ÙÞÉÓÌÑÀÔ ÍÏÄÕÌØ {\tt x}. +%%For instance {\tt +%%abs(x)}\index{abs?\texttt{abs}}\label{Dabs} and {\tt abs x} both compute +%%the absolute value of {\tt x}. +üÔÏ ÖÅ ×ÅÒÎÏ ÄÌÑ ÆÕÎËÃÉÊ {\tt round}\index{round?\texttt{round}}\label{Dround}, +{\tt floor}\index{floor?\texttt{floor}}\label{Dfloor}, +{\tt ceiling}\index{ceiling?\texttt{ceiling}}\label{Dceil}, +{\tt sind}\index{sind?\texttt{sind}}\label{Dsind} É +{\tt cosd}\index{cosd?\texttt{cosd}}\label{Dcosd}. +%%The same holds for the {\tt +%%round}\index{round?\texttt{round}}\label{Dround}, {\tt +%%floor}\index{floor?\texttt{floor}}\label{Dfloor}, {\tt +%%ceiling}\index{ceiling?\texttt{ceiling}}\label{Dceil}, {\tt +%%sind}\index{sind?\texttt{sind}}\label{Dsind}, and {\tt +%%cosd}\index{cosd?\texttt{cosd}}\label{Dcosd} functions. +ä×Å ÐÏÓÌÅÄÎÉÅ ÉÚ ÎÉÈ ×ÙÞÉÓÌÑÀÔ ÔÒÉÇÏÎÏÍÅÔÒÉÞÅÓËÉÅ ÆÕÎËÃÉÉ ÏÔ ÕÇÌÁ +× ÇÒÁÄÕÓÁÈ. +%%The last two of +%%these compute trigonometric functions of angles in degrees. + +îÅ ×ÓÅ ÕÎÁÒÎÙÅ ÏÐÅÒÁÔÏÒÙ ÂÅÒÕÔ ÞÉÓÌÏ×ÙÅ ÁÒÇÕÍÅÎÔÙ É ×ÏÚ×ÒÁÝÁÀÔ ÞÉÓÌÏ×ÙÅ +ÒÅÚÕÌØÔÁÔÙ. +%%Not all unary operators take numeric arguments and return numeric +%%results. +îÁÐÒÉÍÅÒ, ÏÐÅÒÁÔÏÒ {\tt abs}\index{abs?\texttt{abs}} ÍÏÖÎÏ ÐÒÉÍÅÎÑÔØ +Ë ÐÁÒÅ ÄÌÑ ×ÙÞÉÓÌÅÎÉÑ ÄÌÉÎÙ ×ÅËÔÏÒÁ. +%%For instance, the {\tt abs}\index{abs?\texttt{abs}} operator +%%can be applied to a pair to compute the Euclidean length of a vector. +ðÒÉÍÅÎÅÎÉÅ ÏÐÅÒÁÔÏÒÁ {\tt +unitvector}\index{unitvector?\texttt{unitvector}}\label{Duvec} +Ë ÐÁÒÅ ÐÒÏÉÚ×ÏÄÉÔ ÏÐÑÔØ ÐÁÒÕ, ÚÁÄÁÀÝÕÀ ×ÅËÔÏÒ Ó ÔÅÍ ÖÅ ÎÁÐÒÁ×ÌÅÎÉÅÍ É +ÄÌÉÎÏÊ~1. +%%Applying the {\tt +%%unitvector}\index{unitvector?\texttt{unitvector}}\label{Duvec} operator +%%to a pair produces the same pair rescaled so that its Euclidean length +%%is~1. +ïÐÅÒÁÔÏÒ {\tt decimal}\index{decimal?\texttt{decimal}}\label{Ddecop} +ÂÅÒÅÔ ÞÉÓÌÏ É ×ÏÚ×ÒÁÝÁÅÔ ÅÇÏ ÓÔÒÏËÏ×ÏÅ ÐÒÅÄÓÔÁ×ÌÅÎÉÅ. +%%The {\tt decimal}\index{decimal?\texttt{decimal}}\label{Ddecop} +%%operator takes a number and returns the string representation. +ïÐÅÒÁÔÏÒ {\tt angle}\index{angle?\texttt{angle}}\label{Dangle} ÂÅÒÅÔ ÐÁÒÕ +É ×ÙÞÉÓÌÑÅÔ ÁÒËÔÁÎÇÅÎÓ ÏÔÎÏÛÅÎÉÑ ÅÅ ËÏÍÐÏÎÅÎÔ, Ô.~Å. {\tt angle} --- ÜÔÏ +ÏÐÅÒÁÔÏÒ, ÏÂÒÁÔÎÙÊ {\tt dir}, ÞÔÏ ÏÂÓÕÖÄÁÅÔÓÑ × ÒÁÚÄÅÌÅ~\ref{tenscurl}. +%%The {\tt angle}\index{angle?\texttt{angle}}\label{Dangle} operator takes a pair +%%and computes the two-argument arctangent; i.e., {\tt angle} is the +%%inverse of the {\tt dir} operator that was discussed in +%%Section~\ref{tenscurl}. +åÓÔØ ÔÁËÖÅ ÏÐÅÒÁÔÏÒ {\tt cycle}\index{cycle?\texttt{cycle}}\label{Dcycop}, ÞÔÏ +ÂÅÒÅÔ \tdescr{ÐÅÒ×ÉÞÎÙÊ ÐÕÔØ} É ×ÏÚ×ÒÁÝÁÅÔ ÌÏÇÉÞÅÓËÉÊ ÒÅÚÕÌØÔÁÔ, ÐÏËÁÚÙ×ÁÀÝÉÊ +Ñ×ÌÑÅÔÓÑ ÌÉ ÜÔÏÔ ÐÕÔØ ÚÁÍËÎÕÔÏÊ ËÒÉ×ÏÊ. +%%There is also an operator {\tt +%%cycle}\index{cycle?\texttt{cycle}}\label{Dcycop} that takes a +%%\tdescr{path primary} and returns a boolean result indicating whether +%%the path is a closed curve. + +óÕÝÅÓÔ×ÕÅÔ ÃÅÌÙÊ ËÌÁÓÓ ÄÒÕÇÉÈ ÏÐÅÒÁÔÏÒÏ× ÄÌÑ ËÌÁÓÓÉÆÉËÁÃÉÉ ×ÙÒÁÖÅÎÉÊ Ó +ÌÏÇÉÞÅÓËÉÍ ÒÅÚÕÌØÔÁÔÏÍ. +%%There is a whole class of other operators that classify expressions and +%%return boolean results. +éÍÑ ÔÉÐÁ, ÔÁËÏÅ ËÁË {\tt +pair}\index{pair?\texttt{pair}}, ÍÏÖÅÔ ÐÒÉÍÅÎÑÔØÓÑ Ë ÌÀÂÏÍÕ ÔÉÐÕ +\tdescr{ÐÅÒ×ÉÞÎÏÓÔÉ} É ×ÏÚ×ÒÁÝÁÔØ ÌÏÇÉÞÅÓËÉÊ ÒÅÚÕÌØÔÁÔ, ÐÏËÁÚÙ×ÁÀÝÉÊ +Ñ×ÌÑÅÔÓÑ ÌÉ ÁÒÇÕÍÅÎÔ ÐÁÒÏÊ\label{Dpairop}. +%%A type name such as {\tt +%%pair}\index{pair?\texttt{pair}} can operate on any type of +%%\tdescr{primary} and return a boolean result indicating whether the +%%argument is a {\tt pair}\label{Dpairop}. +áÎÁÌÏÇÉÞÎÏ, ËÁÖÄÏÅ ÉÍÑ ÉÚ ÓÌÅÄÕÀÝÉÈ ÄÁÌÅÅ ÍÏÖÎÏ ÉÓÐÏÌØÚÏ×ÁÔØ ËÁË ÕÎÁÒÎÙÊ +ÏÐÅÒÁÔÏÒ: +{\tt numeric}\index{numeric?\texttt{numeric}}\label{Dnumop}, +{\tt boolean}\index{boolean?\texttt{boolean}}\label{Dboolop}, +{\tt cmykcolor}\index{cmykcolor?\texttt{cmykcolor}}\label{Dccolrop}, +{\tt color}\index{color?\texttt{color}}\label{Dcolrop}, +{\tt string}\index{string?\texttt{string}}\label{Dstrgop}, +{\tt transform}\index{transform?\texttt{transform}}\label{Dtrnfop}, +{\tt path}\index{path?\texttt{path}}\label{Dpathop}, +{\tt pen}\index{pen?\texttt{pen}}\label{Dpenop}, +{\tt picture}\index{picture?\texttt{picture}}\label{Dpictop} É +{\tt rgbcolor}\index{rgbcolor?\texttt{rgbcolor}}\label{Drcolrop}. +%%Similarly, each of the +%%following can be used as a unary operator: +%%{\tt numeric}\index{numeric?\texttt{numeric}}\label{Dnumop}, +%%{\tt boolean}\index{boolean?\texttt{boolean}}\label{Dboolop}, +%%{\tt cmykcolor}\index{cmykcolor?\texttt{cmykcolor}}\label{Dccolrop}, +%%{\tt color}\index{color?\texttt{color}}\label{Dcolrop}, +%%{\tt string}\index{string?\texttt{string}}\label{Dstrgop}, +%%{\tt transform}\index{transform?\texttt{transform}}\label{Dtrnfop}, +%%{\tt path}\index{path?\texttt{path}}\label{Dpathop}, +%%{\tt pen}\index{pen?\texttt{pen}}\label{Dpenop}, +%%{\tt picture}\index{picture?\texttt{picture}}\label{Dpictop}, and +%%{\tt rgbcolor}\index{rgbcolor?\texttt{rgbcolor}}\label{Drcolrop}. +ëÒÏÍÅ ÐÒÏ×ÅÒËÉ ÔÉÐÁ \tdescr{ÐÅÒ×ÉÞÎÏÓÔÉ}, ×Ù ÍÏÖÅÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ ÏÐÅÒÁÔÏÒÙ +{\tt known}\index{known?\texttt{known}}\label{Dknown} É {\tt +unknown}\index{unknown?\texttt{unknown}}\label{Dunknwn} ÄÌÑ ÐÒÏ×ÅÒËÉ, +ÉÍÅÅÔ ÌÉ ÏÎÁ ËÏÎËÒÅÔÎÏÅ ÚÎÁÞÅÎÉÅ. +%%Besides just +%%testing the type of a \tdescr{primary}, you can use the {\tt +%%known}\index{known?\texttt{known}}\label{Dknown} and {\tt +%%unknown}\index{unknown?\texttt{unknown}}\label{Dunknwn} operators to +%%test if it has a completely known value. + +äÁÖÅ ÞÉÓÌÁ ÍÏÇÕÔ ×ÅÓÔÉ ÓÅÂÑ ËÁË ÏÐÅÒÁÔÏÒ × ÎÅËÏÔÏÒÙÈ ËÏÎÔÅËÓÔÁÈ. +%%Even a number can behave like an operator in some contexts. +üÔÏ ÓÓÙÌËÁ ÎÁ ÔÒÀË, ÞÔÏ ÐÏÚ×ÏÌÑÅÔ {\tt 3x}\index{ÕÍÎÏÖÅÎÉÅ, ÎÅÑ×ÎÏÅ} É +{\tt 3cm} ËÁË ÁÌØÔÅÒÎÁÔÉ×Ù ÄÌÑ {\tt 3*x} É {\tt 3*cm}. +%%This refers +%%to the trick that allows {\tt 3x}\index{multiplication, implicit} and +%%{\tt 3cm} as alternatives to {\tt 3*x} and {\tt 3*cm}. +ðÒÁ×ÉÌÏ × ÔÏÍ, ÞÔÏ \tdescr{ÞÉÓÌÏ ÉÌÉ ÄÒÏÂØ}, ÚÁ ËÏÔÏÒÙÍÉ ÎÅÔ {\tt +}, {\tt -} +ÉÌÉ ÄÒÕÇÏÇÏ \tdescr{ÞÉÓÌÁ ÉÌÉ ÄÒÏÂÉ}, ÍÏÖÅÔ ÓÌÕÖÉÔØ ËÁË \tdescr{ÐÅÒ×ÉÞÎÙÊ +ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}. +%%The rule is that +%%a \tdescr{number or fraction} that is not followed by {\tt +}, {\tt -}, +%%or another \tdescr{number or fraction} can serve as a \tdescr{primary +%%binop}. +ôÁËÉÍ ÏÂÒÁÚÏÍ, {\tt 2/3x}\index{ÎÅÒÅÇÕÌÑÒÎÏÓÔÉ ÒÁÚÂÏÒÁ} --- ÜÔÏ Ä×Å ÔÒÅÔÉ ÏÔ +{\tt x}, ÎÏ {\tt (2)/3x} --- ÜÔÏ $2\over3x$, Á {\tt 3 3} --- ÜÔÏ ÏÛÉÂËÁ. +%%Thus {\tt 2/3x}\index{parsing irregularities} is two thirds of +%%{\tt x} but {\tt (2)/3x} is $2\over3x$ and {\tt 3 3} is illegal. + +åÓÔØ ÔÁËÖÅ ÏÐÅÒÁÔÏÒÙ ÄÌÑ ÉÚ×ÌÅÞÅÎÉÑ ÞÉÓÌÏ×ÙÈ ÐÏÌÅÊ ÉÚ ÐÁÒ, Ã×ÅÔÏ×, +cmyk-Ã×ÅÔÏ× É ÄÁÖÅ ÔÒÁÎÓÆÏÒÍÁÃÉÊ. +%%There are also operators for extracting numeric subfields from pairs, +%%colors, cmykcolors, and even transforms. +åÓÌÉ {\tt p} --- ÜÔÏ \tdescr{ÐÅÒ×ÉÞÎÁÑ +ÐÁÒÁ}, ÔÏ {\tt xpart p}\index{xpart?\texttt{xpart}}\label{Dxprt} É +{\tt ypart p}\index{ypart?\texttt{ypart}}\label{Dyprt} ÉÚ×ÌÅËÁÀÔ ÅÅ ËÏÍÐÏÎÅÎÔÙ +ÔÁË, ÞÔÏ +$$ \hbox{\tt (xpart p, ypart p)} $$ ÜË×É×ÁÌÅÎÔÎÏ {\tt p}, ÄÁÖÅ ÅÓÌÉ +{\tt p} --- ÎÅÉÚ×ÅÓÔÎÁÑ ÐÁÒÁ, ÉÓÐÏÌØÚÕÅÍÁÑ × ÌÉÎÅÊÎÏÍ ÕÒÁ×ÎÅÎÉÉ. +%%If {\tt p} is a \tdescr{pair +%%primary}, {\tt xpart p}\index{xpart?\texttt{xpart}}\label{Dxprt} and +%%{\tt ypart p}\index{ypart?\texttt{ypart}}\label{Dyprt} extract its components so that +%%$$ \hbox{\tt (xpart p, ypart p)} $$ is equivalent to~{\tt p} even if +%%{\tt p} is an unknown pair that is being used in a linear equation. +áÎÁÌÏÇÉÞÎÏ, Ã×ÅÔ {\tt c} ÜË×É×ÁÌÅÎÔÅÎ\index{redpart?\texttt{redpart}}% +\index{greenpart?\texttt{greenpart}}% +\index{bluepart?\texttt{bluepart}}\label{Drgbprt} +$$ \hbox{\tt (redpart c, greenpart c, bluepart c)}. $$ +%%Similarly, a color {\tt c} is equivalent +%%to\index{redpart?\texttt{redpart}}% +%%\index{greenpart?\texttt{greenpart}}% +%%\index{bluepart?\texttt{bluepart}}\label{Drgbprt} +%%$$ \hbox{\tt (redpart c, greenpart c, bluepart c)} $$. +äÌÑ cmyk-Ã×ÅÔÁ {\tt c} ÅÇÏ ÜË×É×ÁÌÅÎÔ\index{cyanpart?\texttt{cyanpart}}% +\index{magentapart?\texttt{magentapart}}% +\index{yellowpart?\texttt{yellowpart}}% +\index{blackpart?\texttt{blackpart}}\label{Dcmykprt} +$$ \hbox{\tt (cyanpart c, magentapart c, yellowpart c, blackpart c)}, $$ +Á ÄÌÑ ÏÔÔÅÎËÁ ÓÅÒÏÇÏ {\tt c} ÅÓÔØ ÔÏÌØËÏ ÏÄÉÎ ËÏÍÐÏÎÅÎÔ +\index{greypart?\texttt{greypart}}\label{Dgreyprt}% +$$ \hbox{\tt greypart c}. $$ +%%For a cmykcolor {\tt c}, the parts are:\index{cyanpart?\texttt{cyanpart}}% +%%\index{magentapart?\texttt{magentapart}}% +%%\index{yellowpart?\texttt{yellowpart}}% +%%\index{blackpart?\texttt{blackpart}}\label{Dcmykprt} +%%$$ \hbox{\tt (cyanpart c, magentapart c, yellowpart c, blackpart c)} $$ +%%and for a greyscale color {\tt c}, there is only one component% +%%\index{greypart?\texttt{greypart}}\label{Dgreyprt}% +%%$$ \hbox{\tt greypart c}. $$ +÷ÓÅ ÏÐÅÒÁÔÏÒÙ ËÏÍÐÏÎÅÎÔ Ã×ÅÔÁ ÏÂÓÕÖÄÁÀÔÓÑ ÂÏÌÅÅ ÐÏÄÒÏÂÎÏ × +ÒÁÚÄÅÌÅ~\ref{piccomp}. +%%All color component operators are discussed in more detail in +%%section~\ref{piccomp}. +óÐÅÃÉÆÉËÁÔÏÒÙ ÞÁÓÔÅÊ ÔÒÁÎÓÆÏÒÍÁÃÉÊ ÏÂÓÕÖÄÁÀÔÓÑ × ÒÁÚÄÅÌÅ~\ref{transsec}. +%%The part specifiers for transforms are discussed +%%in section~\ref{transsec}. + +\section{ðÅÒÅÍÅÎÎÙÅ} +%%\section{Variables} +\label{vars} +MetaPost ÐÏÚ×ÏÌÑÅÔ ÓÏÓÔÁ×ÎÙÅ ÉÍÅÎÁ ÐÅÒÅÍÅÎÎÙÈ, ÔÁËÉÅ ËÁË {\tt z.a}, {\tt x2r}, +{\tt y2r} É {\tt z2r}, ÇÄÅ {\tt z2r} ÏÚÎÁÞÁÅÔ {\tt (x2r,y2r)}, Á +{\tt z.a} --- {\tt (x.a,y.a)}. +%%MetaPost allows compound variable names such as {x.a}, {\tt x2r}, {\tt y2r}, +%%and {\tt z2r}, where {\tt z2r} means {\tt (x2r,y2r)} and {\tt z.a} means +%%{\tt (x.a,y.a)}. +æÁËÔÉÞÅÓËÉ ÓÕÝÅÓÔ×ÕÅÔ ÛÉÒÏËÉÊ ËÌÁÓÓ ÓÕÆÆÉËÓÏ×, ÎÁÐÒÉÍÅÒ, +{\tt z}\tdescr{ÓÕÆÆÉËÓ}\index{ÓÕÆÆÉËÓ?\tdescr{ÓÕÆÆÉËÓ}}, ÏÚÎÁÞÁÀÝÉÊ +$$ (x\descr{ÓÕÆÆÉËÓ},\, y\descr{ÓÕÆÆÉËÓ}). $$ +%%In fact there is a broad class of suffixes such that +%%{\tt z}\tdescr{suffix}\index{suffix?\tdescr{suffix}} means +%%$$ (x\descr{suffix},\, y\descr{suffix}). $$ +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ \tdescr{ÓÕÆÆÉËÓ} ÓÏÓÔÁ×ÌÑÅÔÓÑ ÉÚ ÚÎÁËÏ×, ÂÕÄÅÔ ÎÁÉÌÕÞÛÉÍ +ÎÁÞÁÔØ Ó ÎÅÓËÏÌØËÉÈ ÓÌÏ× Ï ÚÎÁËÁÈ. +%%Since a \tdescr{suffix} is composed of tokens, it is best to begin with a few +%%comments about tokens. + +\subsection{úÎÁËÉ} +%%\subsection{Tokens} + +÷ÈÏÄÎÏÊ ÆÁÊÌ MetaPost ÒÁÓÓÍÁÔÒÉ×ÁÅÔÓÑ ËÁË ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÞÉÓÅÌ, +ÓÔÒÏËÏ×ÙÈ ËÏÎÓÔÁÎÔ É ÓÉÍ×ÏÌØÎÙÈ ÚÎÁËÏ×\index{ÚÎÁËÉ}\index{ÚÎÁËÉ!ÓÉÍ×ÏÌÉÞÅÓËÉÅ}. +%%A MetaPost input file is treated as a sequence of numbers, string +%%constants, and symbolic tokens\index{tokens}\index{tokens!symbolic}. +þÉÓÌÏ ÓÏÓÔÏÉÔ ÉÚ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔÉ ÃÉÆÒ É ÍÏÖÅÔ ÓÏÄÅÒÖÁÔØ ÄÅÓÑÔÉÞÎÕÀ ÔÏÞËÕ. +%%A +%%number consists of a sequence of digits possibly containing a decimal +%%point. +ôÅÈÎÉÞÅÓËÉ ÚÎÁË ÍÉÎÕÓ ×ÎÁÞÁÌÅ ÏÔÒÉÃÁÔÅÌØÎÏÇÏ ÞÉÓÌÁ --- ÜÔÏ ÏÔÄÅÌØÎÙÊ ÚÎÁË. +%%Technically, the minus sign in front of a negative number is a +%%separate token. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ MetaPost ÉÓÐÏÌØÚÕÅÔ ÁÒÉÆÍÅÔÉËÕ\index{ÁÒÉÆÍÅÔÉËÁ} Ó +ÆÉËÓÉÒÏ×ÁÎÎÏÊ ÔÏÞËÏÊ, ÏÎ ÎÅ ÐÏÎÉÍÁÅÔ ÜËÓÐÏÎÅÎÃÉÁÌØÎÏÊ ÎÏÔÁÃÉÉ, ÔÁËÏÊ ËÁË +{\tt 6.02E23}. +%%Since MetaPost uses fixed point +%%arithmetic\index{arithmetic}, it does not understand exponential +%%notation such as {\tt 6.02E23}. +MetaPost ÂÕÄÅÔ ÉÎÔÅÒÐÒÅÔÉÒÏ×ÁÔØ ÜÔÏ ËÁË ÞÉÓÌÏ 6.02, ÚÁ ËÏÔÏÒÙÍ ÓÌÅÄÕÅÔ +ÓÉÍ×ÏÌØÎÙÊ ÚÎÁË {\tt E}, ÚÁ ËÏÔÏÒÙÍ ÉÄÅÔ ÞÉÓÌÏ~23. +%%MetaPost would interpret this as the +%%number 6.02, followed by the symbolic token {\tt E}, followed by the +%%number~23. + +÷ÓÅ ÍÅÖÄÕ ÐÁÒÏÊ Ä×ÏÊÎÙÈ ËÁ×ÙÞÅË, {\tt \qq}, Ñ×ÌÑÅÔÓÑ ÓÔÒÏËÏ×ÏÊ +ËÏÎÓÔÁÎÔÏÊ\index{ÓÔÒÏËÏ×ÙÅ ËÏÎÓÔÁÎÔÙ}. +%%Anything between a pair of double quotes {\tt \qq} is a +%%string constant\index{string constants}. +óÔÒÏËÏ×ÏÊ ËÏÎÓÔÁÎÔÅ ÎÅÌØÚÑ ÎÁÞÉÎÁÔØÓÑ ÎÁ ÏÄÎÏÊ ÓÔÒÏËÅ É ÚÁËÁÎÞÉ×ÁÔØÓÑ ÎÁ +ÄÒÕÇÏÊ. +%%It is +%%illegal for a string constant to start on one line and end on a later line. +óÔÒÏËÏ×ÁÑ ËÏÎÓÔÁÎÔÁ ÎÅ ÍÏÖÅÔ ÔÁËÖÅ ÓÏÄÅÒÖÁÔØ Ä×ÏÊÎÙÈ ËÁ×ÙÞÅË, {\tt \qq}, É +ÞÅÇÏ-ÎÉÂÕÄØ ÅÝÅ, ÏÔÌÉÞÎÏÇÏ ÏÔ ÐÅÞÁÔÎÙÈ ÓÉÍ×ÏÌÏ× ASCII. +%%Nor can a string constant contain double quotes {\tt \qq} or anything other than +%%printable ASCII characters. + +÷ÓÅ × ÓÔÒÏËÅ ××ÏÄÁ, ÏÔÌÉÞÎÏÅ ÏÔ ÞÉÓÅÌ É ÓÉÍ×ÏÌØÎÙÈ ËÏÎÓÔÁÎÔ, ÒÁÚÂÉ×ÁÅÔÓÑ ÎÁ +ÓÉÍ×ÏÌØÎÙÅ ÚÎÁËÉ\index{ÚÎÁËÉ!ÓÉÍ×ÏÌÉÞÅÓËÉÅ}. +%%Everything in a line of input other than numbers and string constants is broken +%%into symbolic tokens\index{tokens!symbolic}. +óÉÍ×ÏÌØÎÙÊ ÚÎÁË --- ÜÔÏ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÏÄÎÏÇÏ ÉÌÉ ÂÏÌÅÅ ÓÈÏÖÉÈ ÓÉÍ×ÏÌÏ×, +ÇÄÅ ÓÉÍ×ÏÌÙ ``ÓÈÏÖÉ'', ÅÓÌÉ ÏÎÉ ×ÓÔÒÅÞÁÀÔÓÑ ÎÁ ÏÄÎÏÊ ÓÔÒÏËÅ ÔÁÂÌÉÃÙ~\ref{classes}. +%%A symbolic token is a sequence of +%%one or more similar characters, where characters are ``similar'' if they occur +%%on the same row of Table~\ref{classes}. + +\begin{table} +$$\begin{tabular}{c} +\verb|ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz|\\ +{\tt :<=>|}\\ +\verb|#&@$|\\ +\verb|/*\|\\ +{\tt +-}\\ +{\tt !?}\\ +{\tt '`}\\ +\verb|^~|\\ +\verb|{}|\\ +{\tt [}\\ +{\tt ]}\\ +\end{tabular} +$$ +\caption{ëÌÁÓÓÙ ÓÉÍ×ÏÌÏ× ÄÌÑ ÒÁÚÂÉÅÎÉÑ ÎÁ ÚÎÁËÉ} +%%\caption{Character classes for tokenization} +\label{classes} +\end{table} + +ôÁËÉÍ ÏÂÒÁÚÏÍ, \verb|A_alpha| É {\tt +-+} --- ÜÔÏ ÏÔÄÅÌØÎÙÅ ÓÉÍ×ÏÌÉÞÅÓËÉÅ +ÚÎÁËÉ, {\tt !=} ÉÎÔÅÒÐÒÅÔÉÒÕÅÔÓÑ ËÁË Ä×Á ÚÎÁËÁ, Á {\tt x34} --- ÜÔÏ +ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË, ÚÁ ËÏÔÏÒÙÍ ÓÌÅÄÕÅÔ ÞÉÓÌÏ. +%%Thus \verb|A_alpha| and {\tt +-+} are symbolic tokens but {\tt !=} is +%%interpreted as two tokens and {\tt x34} is a symbolic token followed by +%%a number. +÷ÓÌÅÄÓÔ×ÉÅ ÔÏÇÏ, ÞÔÏ Ë×ÁÄÒÁÔÎÙÅ ÓËÏÂËÉ ÐÒÉ×ÅÄÅÎÙ ÎÁ ÏÔÄÅÌØÎÙÈ ÓÔÒÏËÁÈ, +ÓÉÍ×ÏÌÉÞÅÓËÉÍÉ ÚÎÁËÁÍÉ, ×ËÌÀÞÁÀÝÉÍÉ ÉÈ, Ñ×ÌÑÀÔÓÑ ÔÏÌØËÏ {\tt [}, {\tt +[[}, {\tt [[[}, ... É {\tt ]}, {\tt ]]}, ... +%%Since the brackets {\tt [} and {\tt ]} are listed on lines by +%%themselves, the only symbolic tokens involving them are {\tt [}, {\tt +%%[[}, {\tt [[[}, etc.\ and {\tt ]}, {\tt ]]}, etc. + +îÅËÏÔÏÒÙÅ ÓÉÍ×ÏÌÙ ÎÅ ÐÒÉ×ÅÄÅÎÙ × ÔÁÂÌÉÃÅ~\ref{classes}, ÐÏÔÏÍÕ ÞÔÏ ÏÎÉ +ÔÒÅÂÕÀÔ ÓÐÅÃÉÁÌØÎÏÇÏ ÏÂÒÁÝÅÎÉÑ. +%%Some characters are not listed in Table~\ref{classes} because they need +%%special treatment. +þÅÔÙÒÅ ÓÉÍ×ÏÌÁ {\tt ,;()} Ñ×ÌÑÀÔÓÑ ``ÏÄÉÎÏÞËÁÍÉ'': ÚÁÐÑÔÁÑ, ÔÏÞËÁ Ó ÚÁÐÑÔÏÊ ÉÌÉ +ÓËÏÂËÁ --- ÜÔÏ ÏÔÄÅÌØÎÙÊ ÚÎÁË, ÄÁÖÅ ÅÓÌÉ ÏÄÉÎÁËÏ×ÙÅ ÉÚ ÎÉÈ ÉÄÕÔ ÐÏÄÒÑÄ. +%%The four characters {\tt ,;()} are ``loners'': each +%%comma, semicolon, or parenthesis is a separate token +%%even when they occur consecutively. +ôÁËÉÍ ÏÂÒÁÚÏÍ, {\tt (())} --- ÜÔÏ ÞÅÔÙÒÅ ÚÎÁËÁ, Á ÎÅ ÏÄÉÎ ÉÌÉ Ä×Á. +%%Thus {\tt (())} is four tokens, not +%%one or two. +úÎÁË ÐÒÏÃÅÎÔÁ Ñ×ÌÑÅÔÓÑ ×ÅÓØÍÁ ÓÐÅÃÉÁÌØÎÙÍ, ÐÏÔÏÍÕ ÞÔÏ ÏÎ ××ÏÄÉÔ +ËÏÍÍÅÎÔÁÒÉÉ\index{ËÏÍÍÅÎÔÁÒÉÉ}. +%%The percent sign is very special because it introduces +%%comments\index{comments}. +úÎÁË ÐÒÏÃÅÎÔÁ É ×ÓÅ ÐÏÓÌÅ ÎÅÇÏ ÄÏ ËÏÎÃÁ ÓÔÒÏËÉ ÉÇÎÏÒÉÒÕÅÔÓÑ. +%%The percent sign and everything after it up +%%to the end of the line are ignored. + +äÒÕÇÉÍ ÓÐÅÃÉÁÌØÎÙÍ ÓÉÍ×ÏÌÏÍ Ñ×ÌÑÅÔÓÑ ÔÏÞËÁ. +%%Another special character is the period. +ä×Å É ÂÏÌÅÅ ÔÏÞÅË ×ÍÅÓÔÅ ÆÏÒÍÉÒÕÀÔ ÓÉÍ×ÏÌØÎÙÊ ÚÎÁË, ÎÏ ÏÔÄÅÌØÎÁÑ ÔÏÞËÁ +ÉÇÎÏÒÉÒÕÅÔÓÑ, Á ÔÏÞËÁ, ÐÅÒÅÄ ËÏÔÏÒÏÊ ÉÌÉ ÚÁ ËÏÔÏÒÏÊ ÉÄÕÔ ÃÉÆÒÙ, Ñ×ÌÑÅÔÓÑ +ÞÁÓÔØÀ ÞÉÓÌÁ. +%%Two or more periods +%%together form a symbolic token, but a single period is ignored, and a period +%%preceded or followed by digits is part of a number +ôÁËÉÍ ÏÂÒÁÚÏÍ, {\tt ..} É {\tt ...} --- ÜÔÏ ÓÉÍ×ÏÌØÎÙÅ ÚÎÁËÉ, Á {\tt a.b} --- ÜÔÏ +ÐÒÏÓÔÏ Ä×Á ÚÎÁËÁ {\tt a} É {\tt b}. +%%Thus {\tt ..} +%%and {\tt ...} are symbolic tokens while {\tt a.b} is just two tokens {\tt a} +%%and {\tt b}. +ðÒÉÎÑÔÏ ÉÓÐÏÌØÚÏ×ÁÔØ ÔÏÞËÕ ÔÁËÉÍ ÏÂÒÁÚÏÍ ÄÌÑ ÒÁÚÄÅÌÅÎÉÑ ÚÎÁËÏ×, ËÏÇÄÁ ÉÍÑ +ÐÅÒÅÍÅÎÎÏÊ ÉÍÅÅÔ ÄÌÉÎÕ ÂÏÌÅÅ ÏÄÎÏÇÏ ÚÎÁËÁ. +%%It conventional to use periods to separate tokens in this fashion +%%when naming a variable that is more than one token long. + +\subsection{äÅËÌÁÒÁÃÉÉ ÐÅÒÅÍÅÎÎÙÈ} +%%\subsection{Variable Declarations} +\label{vardecl} + +éÍÑ ÐÅÒÅÍÅÎÎÏÊ --- ÜÔÏ ÌÉÂÏ ÓÉÍ×ÏÌØÎÙÊ ÚÎÁË, ÌÉÂÏ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ +ÓÉÍ×ÏÌØÎÙÈ ÚÎÁËÏ×. +%%A variable name is a symbolic token or a sequence of symbolic tokens. +âÏÌØÛÉÎÓÔ×Ï ÓÉÍ×ÏÌØÎÙÈ ÚÎÁËÏ× Ñ×ÌÑÀÔÓÑ ÐÒÁ×ÉÌØÎÙÍÉ ÉÍÅÎÁÍÉ ÐÅÒÅÍÅÎÎÙÈ, ÎÏ +ÞÔÏ ÕÇÏÄÎÏ Ó ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÍ ÚÎÁÞÅÎÉÅÍ ÐÏÄÏÂÎÏ {\tt draw}, {\tt +} ÉÌÉ {\tt ..} +ÎÅÄÏÐÕÓÔÉÍÏ, ÎÁÐÒÉÍÅÒ, ÉÍÅÎÁ ÐÅÒÅÍÅÎÎÙÈ ÎÅ ÍÏÇÕÔ ÂÙÔØ ÍÁËÒÏÓÁÍÉ ÉÌÉ +ÐÒÉÍÉÔÉ×ÁÍÉ MetaPost. +%%Most symbolic tokens are legitimate variable names, but anything with a +%%predefined meaning like {\tt draw}, {\tt +}, or {\tt ..} is disallowed; +%%i.e., variable names cannot be macros or MetaPost primitives. +üÔÏ ×ÔÏÒÏÓÔÅÐÅÎÎÏÅ ÏÇÒÁÎÉÞÅÎÉÅ ÄÏÐÕÓËÁÅÔ ÛÉÒÏËÉÊ ËÌÁÓÓ ÉÍÅÎ ÐÅÒÅÍÅÎÎÙÈ: +{\tt alpha}, \verb|==>|, \verb|@&#$&| É \verb|~~| --- ×ÓÅ ÏÎÉ ÌÅÇÉÔÉÍÎÙÅ +ÉÍÅÎÁ ÐÅÒÅÍÅÎÎÙÈ. +%%This +%%minor restriction allows an amazingly broad class of variable names: +%%{\tt alpha}, \verb|==>|, \verb|@&#$&|, and \verb|~~| are all legitimate +%%variable names. +óÉÍ×ÏÌØÎÙÅ ÚÎÁËÉ ÂÅÚ ÓÐÅÃÉÁÌØÎÏÇÏ ÚÎÁÞÅÎÉÑ ÎÁÚÙ×ÁÀÔÓÑ ÜÔÉËÅÔËÁÍÉ +({\em tags}\index{ÜÔÉËÅÔËÉ}). +%%Such symbolic tokens without special meanings are +%%called {\em tags}\index{tags}. + +éÍÑ ÐÅÒÅÍÅÎÎÏÊ ÍÏÖÅÔ ÂÙÔØ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØÀ ÜÔÉËÅÔÏË, ÐÏÄÏÂÎÏÊ +{\tt f.bot} ÉÌÉ {\tt f.top}. +%%A variable name can be a sequence of tags like {\tt f.bot} or {\tt +%%f.top}. +üÔÁ ÉÄÅÑ ÓÌÕÖÉÔ ÄÌÑ ÓÏÚÄÁÎÉÑ ÎÅËÏÔÏÒÙÈ ×ÏÚÍÏÖÎÏÓÔÅÊ ÚÁÐÉÓÅÊ ðÁÓËÁÌÑ +ÉÌÉ ÓÔÒÕËÔÕÒ óÉ. +%%The idea is to provide some of the functionality of Pascal +%%records or C structures. +ôÁËÖÅ ×ÏÚÍÏÖÎÏ ÓÉÍÕÌÉÒÏ×ÁÔØ ÍÁÓÓÉ×Ù ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ ÉÍÅÎ ÐÅÒÅÍÅÎÎÙÈ, +ÓÏÄÅÒÖÁÝÉÈ ÞÉÓÌÁ É ÓÉÍ×ÏÌØÎÙÅ ÚÎÁËÉ. +%%It is also possible to simulate arrays by +%%using variable names that contain numbers as well as symbolic tokens. +îÁÐÒÉÍÅÒ, ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ {\tt x2r} ÓÏÓÔÏÉÔ ÉÚ ÜÔÉËÅÔËÉ {\tt x}, +ÞÉÓÌÁ 2 É ÜÔÉËÅÔËÉ~{\tt r}. +%%For example, the variable name {\tt x2r} consists of the tag {\tt x}, +%%the number 2, and the tag~{\tt r}. +íÏÇÕÔ ÂÙÔØ ÔÁËÖÅ ÐÅÒÅÍÅÎÎÙÅ, ÉÍÅÎÏ×ÁÎÎÙÅ {\tt x3r} É ÄÁÖÅ {\tt x3.14r}. +%%There can also be variables named {\tt x3r} and even {\tt x3.14r}. +üÔÉ ÐÅÒÅÍÅÎÎÙÅ ÍÏÖÎÏ ÒÁÓÓÍÁÔÒÉ×ÁÔØ ËÁË ÍÁÓÓÉ×\index{ÍÁÓÓÉ×Ù} ÞÅÒÅÚ ËÏÎÓÔÒÕËÃÉÉ, +ÐÏÄÏÂÎÙÅ {\tt x[i]r}, ÇÄÅ {\tt i} ÉÍÅÅÔ ÐÏÄÈÏÄÑÝÅÅ ÞÉÓÌÏ×ÏÅ ÚÎÁÞÅÎÉÅ. +%%These variables can be treated as an +%%array\index{arrays} via constructions like {\tt x[i]r}, where {\tt i} +%%has an appropriate numeric value. +óÕÍÍÁÒÎÙÊ ÏÂÚÏÒ ÓÉÎÔÁËÓÉÓÁ ÄÌÑ ÉÍÅÎ ÐÅÒÅÍÅÎÎÙÈ ÐÏËÁÚÁÎ ÎÁ ÒÉÓ.~\ref{syvar}. +%%The overall syntax for variable names is shown in Figure~\ref{syvar}. + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÐÅÒÅÍÅÎÎÁÑ} \rightarrow \descr{ÜÔÉËÅÔËÁ}\descr{ÓÕÆÆÉËÓ}$\\ +%%$\tt \descr{variable} \rightarrow \descr{tag}\descr{suffix}$\\ +$\tt \descr{ÓÕÆÆÉËÓ} \rightarrow \descr{ÐÕÓÔÏ} \;|\; + \descr{ÓÕÆÆÉËÓ}\descr{ÉÎÄÅËÓ} \;|\; \descr{ÓÕÆÆÉËÓ}\descr{ÜÔÉËÅÔËÁ}$\\ +%%$\tt \descr{suffix} \rightarrow \descr{empty} \;|\; +%% \descr{suffix}\descr{subscript} \;|\; \descr{suffix}\descr{tag}$\\ +$\tt \descr{ÉÎÄÅËÓ} \rightarrow \descr{ÞÉÓÌÏ} \;|\; + \hbox{\tt [}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt ]}$ +%%$\tt \descr{subscript} \rightarrow \descr{number} \;|\; +%% \hbox{\tt [}\descr{numeric expression}\hbox{\tt ]}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ÉÍÅÎ ÐÅÒÅÍÅÎÎÙÈ.} +%%\caption{The syntax for variable names.} +\index{ÓÕÆÆÉËÓ?\tdescr{ÓÕÆÆÉËÓ}}\index{ÉÎÄÅËÓ?\tdescr{ÉÎÄÅËÓ}} +%%\index{suffix?\tdescr{suffix}}\index{subscript?\tdescr{subscript}} +\label{syvar} +\end{figure} + +ðÅÒÅÍÅÎÎÙÅ, ÐÏÄÏÂÎÙÅ {\tt x2} É {\tt y2}, ÏÂÙÞÎÏ ÉÍÅÀÔ ÞÉÓÌÏ×ÏÅ ÚÎÁÞÅÎÉÅ, +ÐÏÜÔÏÍÕ ÍÙ ÍÏÖÅÍ ÉÓÐÏÌØÚÏ×ÁÔØ ÆÁËÔ, ÞÔÏ {\tt z}\tdescr{ÓÕÆÆÉËÓ} --- ÜÔÏ +ÓÏËÒÁÝÅÎÉÅ ÄÌÑ\index{z convention?{\tt z}-ÓÏÇÌÁÛÅÎÉÅ}\label{Dzconv} +$$ (x\descr{ÓÕÆÆÉËÓ},\, y\descr{ÓÕÆÆÉËÓ}), $$ +ÄÌÑ ÇÅÎÅÒÁÃÉÉ ÐÁÒ-ÚÎÁÞÅÎÉÊ, ËÏÇÄÁ ÎÕÖÎÏ. +%%Variables like {\tt x2} and {\tt y2} take on numeric values by default, so we +%%can use the fact that {\tt z}\tdescr{suffix} is an abbreviation for\index{z %%convention?{\tt z} convention}\label{Dzconv} +%%$$ (x\descr{suffix},\, y\descr{suffix}) $$ +%%to generate pair-valued variables when needed. +ó ÄÒÕÇÏÊ ÓÔÏÒÏÎÙ, ÍÁËÒÏÓ {\tt beginfig}\index{beginfig?\texttt{beginfig}} +ÕÎÉÞÔÏÖÁÅÔ ×ÓÅ ÓÕÝÅÓÔ×ÕÀÝÉÅ ÄÏ ÅÇÏ ÉÓÐÏÌÎÅÎÉÑ ÐÅÒÅÍÅÎÎÙÅ, ÎÁÞÉÎÁÀÝÉÅÓÑ Ó +ÜÔÉËÅÔÏË {\tt x} ÉÌÉ {\tt y}, ÔÁË ÞÔÏ ÂÌÏËÉ {\tt beginfig} \ldots\ {\tt endfig} +ÎÅ ×ÚÁÉÍÏÄÅÊÓÔ×ÕÀÔ ÄÒÕÇ Ó ÄÒÕÇÏÍ ÐÒÉ ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÔÁËÏÊ ÓÈÅÍÙ ÉÍÅÎÏ×ÁÎÉÑ. +%%It turns out that the +%%{\tt beginfig}\index{beginfig?\texttt{beginfig}} macro wipes out +%%pre-existing values variables that begin with the tags {\tt x} or {\tt +%%y} so that {\tt beginfig} \ldots\ {\tt endfig} blocks do not interfere +%%with each other when this naming scheme is used. +äÒÕÇÉÍÉ ÓÌÏ×ÁÍÉ, ÐÅÒÅÍÅÎÎÙÅ, ÎÁÞÉÎÁÀÝÉÅÓÑ Ó {\tt x}, {\tt y}, {\tt z}, +ÌÏËÁÌØÎÙ\index{ÐÅÒÅÍÅÎÎÙÅ!ÌÏËÁÌØÎÙÅ}\index{ÌÏËÁÌØÎÏÓÔØ} × ÔÏÊ ËÁÒÔÉÎËÅ, ÇÄÅ ÏÎÉ +ÉÓÐÏÌØÚÕÀÔÓÑ. +%%In other words, +%%variables that start with {\tt x}, {\tt y}, {\tt z} are +%%local\index{variables!local}\index{locality} to the figure they are used +%%in. +ïÂÝÉÊ ÍÅÈÁÎÉÚÍ ÄÌÑ ÓÏÚÄÁÎÉÑ ÌÏËÁÌØÎÙÈ ÐÅÒÅÍÅÎÎÙÈ ÂÕÄÅÔ ÏÂÓÕÖÄÁÔØÓÑ +× ÒÁÚÄÅÌÅ~\ref{grsec}. +%%General mechanisms for making variables local will be discussed in +%%Section~\ref{grsec}. + +ïÂßÑ×ÌÅÎÉÑ ÔÉÐÁ\index{ÄÅËÌÁÒÁÃÉÉ}\index{ÄÅËÌÁÒÁÃÉÉ ÔÉÐÁ} +ÄÅÌÁÅÔ ×ÏÚÍÏÖÎÙÍ ÉÓÐÏÌØÚÏ×ÁÎÉÅ ÐÏÞÔÉ ÌÀÂÏÊ ÓÈÅÍÙ ÉÍÅÎÏ×ÁÎÉÑ ÐÒÉ +ÕÄÁÌÅÎÉÉ ×ÓÅÈ ÐÒÅÄÛÅÓÔ×ÕÀÝÉÈ ÚÎÁÞÅÎÉÊ, ÞÔÏ ÍÏÇÕÔ ×ÙÚ×ÁÔØ +×ÚÁÉÍÏÄÅÊÓÔ×ÉÅ. +%%Type declarations\index{declarations}\index{type declarations} +%%make it possible to use almost any naming scheme while still +%%wiping out any previous value that might cause interference. +îÁÐÒÉÍÅÒ, ÄÅËÌÁÒÁÃÉÑ +$$ \hbox{\tt pair pp, a.b;} $$ +ÄÅÌÁÅÔ {\tt pp} É {\tt a.b} ÎÅÉÚ×ÅÓÔÎÙÍÉ ÐÁÒÁÍÉ. +%%For example, the declaration +%%$$ \hbox{\tt pair pp, a.b;} $$ +%%makes {\tt pp} and {\tt a.b} unknown pairs. +ôÁËÁÑ ÄÅËÌÁÒÁÃÉÑ ÎÅ Ñ×ÌÑÅÔÓÑ ÓÔÒÏÇÏ ÌÏËÁÌØÎÏÊ, Ô.~Ë. {\tt pp} É {\tt a.b} +ÎÅ ×ÏÓÓÔÁÎÁ×ÌÉ×ÁÀÔ Á×ÔÏÍÁÔÉÞÅÓËÉ Ó×ÏÉ ÐÒÅÄÛÅÓÔ×ÕÀÝÉÅ ÚÎÁÞÅÎÉÑ × ËÏÎÃÅ +ÔÅËÕÝÅÇÏ ÒÉÓÕÎËÁ. +%%Such a declaration is not +%%strictly local since {\tt pp} and {\tt a.b} are not automatically +%%restored to their previous values at the end of the current figure. +ïÎÉ ÏÐÑÔØ ÓÔÁÎÏ×ÑÔÓÑ ÎÅÉÚ×ÅÓÔÎÙÍÉ ÐÁÒÁÍÉ ÐÒÉ ÐÏ×ÔÏÒÅÎÉÉ ÜÔÏÊ ÄÅËÌÁÒÁÃÉÉ. +%%Of +%%course, they are restored to unknown pairs if the declaration is +%%repeated. + +äÅËÌÁÒÁÃÉÉ ÒÁÂÏÔÁÀÔ ÏÄÉÎÁËÏ×ÙÍ ÏÂÒÁÚÏÍ ÄÌÑ ÌÀÂÏÇÏ ÄÒÕÇÏÇÏ ÉÚ ÏÓÔÁ×ÛÉÈÓÑ +ÄÅ×ÑÔÉ ÔÉÐÏ×: ÞÉÓÌÏ×ÏÇÏ, ÐÕÔÅ×ÏÇÏ, ÔÒÁÎÓÆÏÒÍÁÃÉÏÎÎÏÇÏ, Ã×ÅÔÏ×ÏÇÏ, +cmyk-Ã×ÅÔÏ×ÏÇÏ, ÓÔÒÏËÏ×ÏÇÏ, ÌÏÇÉÞÅÓËÏÇÏ, ÒÉÓÕÎÏÞÎÏÇÏ É ÐÅÒØÅ×ÏÇÏ. +%%Declarations work the same way for any of the other eight types: +%%numeric, path, transform, color, string, boolean, picture, and pen. +åÄÉÎÓÔ×ÅÎÎÏÅ ÏÇÒÁÎÉÞÅÎÉÅ × ÔÏÍ, ÞÔÏ ×Ù ÎÅ ÍÏÖÅÔÅ ÚÁÄÁÔØ ÔÏÞÎÙÊ ÞÉÓÌÏ×ÏÊ +ÉÎÄÅËÓ × ÄÅËÌÁÒÁÃÉÉ ÐÅÒÅÍÅÎÎÏÊ. +%%The +%%only restriction is that you cannot give explicit numeric subscripts in +%%a variable declaration. +îÅ ÐÉÛÉÔÅ ÏÛÉÂÏÞÎÙÈ ÄÅËÌÁÒÁÃÉÊ ÔÉÐÁ +$$ \hbox{\tt numeric q1, q2, q3;} $$ +ÉÓÐÏÌØÚÕÊÔÅ ÏÂÏÂÝÅÎÎÙÊ ÓÉÍ×ÏÌ ÉÎÄÅËÓÁ\index{ÉÎÄÅËÓ!ÏÂÏÂÝÅÎÎÙÊ} +{\tt []}\index{ÍÁÓÓÉ×Ù}\index{[]?\texttt{[]}!ÍÁÓÓÉ×} +×ÍÅÓÔÏ ÞÉÓÅÌ ÄÌÑ ÏÂßÑ×ÌÅÎÉÑ ×ÓÅÇÏ ÍÁÓÓÉ×Á: +$$ \hbox{\tt numeric q[];} $$ +%%Do not give the illegal declaration +%%$$ \hbox{\tt numeric q1, q2, q3;} $$ +%%use the generic subscript\index{subscript!generic} symbol +%%{\tt []}\index{arrays}\index{[]?\texttt{[]}!array} +%%instead, to declare the whole array: +%%$$ \hbox{\tt numeric q[];} $$ +÷Ù ÍÏÖÅÔÅ ÔÁËÖÅ ÏÐÒÅÄÅÌÉÔØ ``ÍÎÏÇÏÒÁÚÍÅÒÎÙÅ'' +ÍÁÓÓÉ×Ù\index{ÍÁÓÓÉ×Ù!ÍÎÏÇÏÍÅÒÎÙÅ}. +%%You can also declare ``multidimensional'' arrays\index{arrays!multidimensional}. +ðÏÓÌÅ ÄÅËÌÁÒÁÃÉÉ +$$ \hbox{\tt path p[]q[], pq[][];} $$ +{\tt p2q3} É {\tt pq1.4 5} --- ÜÔÏ Ä×Á ÐÕÔÉ. +%%After the declaration +%%$$ \hbox{\tt path p[]q[], pq[][];} $$ +%%{\tt p2q3} and {\tt pq1.4 5} are both paths. + +÷ÎÕÔÒÅÎÎÉÅ\index{×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} ÐÅÒÅÍÅÎÎÙÅ, +ÐÏÄÏÂÎÙÅ {\tt tracingonline}, ÎÅ ÍÏÇÕÔ ÂÙÔØ ÏÂßÑ×ÌÅÎÙ ÎÏÒÍÁÌØÎÙÍ ÏÂÒÁÚÏÍ. +%%Internal\index{internal variables}\index{variables!internal} variables +%%like {\tt tracingonline} cannot be declared in the normal fashion. +÷ÓÅ ×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ, ÏÂÓÕÖÄÁÅÍÙÅ × ÜÔÏÍ ÒÕËÏ×ÏÄÓÔ×Å ÉÍÅÀÔ ÚÎÁÞÅÎÉÑ +ÉÚÎÁÞÁÌØÎÏ É ÎÉËÁË ÎÅ ÍÏÇÕÔ ÂÙÔØ ÄÅËÌÁÒÉÒÏ×ÁÎÙ ÓÎÏ×Á, ÎÏ ÅÓÔØ ÓÐÏÓÏ +ÏÂßÑ×ÉÔØ, ÞÔÏ ÎÏ×ÁÑ ÐÅÒÅÍÅÎÎÁÑ ÄÏÌÖÎÁ ×ÅÓÔÉ ÓÅÂÑ ÐÏÄÏÂÎÏ ×ÎÕÔÒÅÎÎÅÊ. +%%All +%%the internal variables discussed in this manual are predefined and do +%%not have to be declared at all, but there is a way to declare that a +%%variable should behave like a newly-created internal variable. +üÔÏ ÄÅËÌÁÒÁÃÉÑ {\tt +newinternal}\index{newinternal?\texttt{newinternal}}\label{Dnewint}, +ÚÁ ËÏÔÏÒÏÊ ÓÌÅÄÕÅÔ ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×. +%%The +%%declaration is {\tt +%%newinternal}\index{newinternal?\texttt{newinternal}}\label{Dnewint} +%%followed by a list of symbolic tokens. +îÁÐÒÉÍÅÒ, +$$ \hbox{\tt newinternal a, b, c;} $$ +ÏÂÕÓÌÏ×ÉÔ ÐÏ×ÅÄÅÎÉÅ {\tt a}, {\tt b} É {\tt c}, ËÁË É Õ ×ÎÕÔÒÅÎÎÉÈ ÐÅÒÅÍÅÎÎÙÈ. +%%For example, +%%$$ \hbox{\tt newinternal a, b, c;} $$ +%%causes {\tt a}, {\tt b}, and {\tt c} to behave like internal variables. +ôÁËÉÅ ÐÅÒÅÍÅÎÎÙÅ ×ÓÅÇÄÁ ÉÍÅÀÔ ÉÚ×ÅÓÔÎÙÅ ÞÉÓÌÏ×ÙÅ ÚÎÁÞÅÎÉÑ É ÜÔÉ ÚÎÁÞÅÎÉÑ +ÍÏÇÕÔ ÂÙÔØ ÉÚÍÅÎÅÎÙ ÔÏÌØËÏ ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ ÏÐÅÒÁÔÏÒÁ +ÐÒÉÓ×ÁÉ×ÁÎÉÑ\index{ÐÒÉÓ×ÁÉ×ÁÎÉÅ} {\tt:=}\index{:=?\texttt{:=}}. +%%Such variables always have known numeric values, and these values can +%%only be changed by using the assignment\index{assignment} operator +%%{\tt:=}\index{:=?\texttt{:=}}. +÷ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ ÉÎÉÃÉÁÌÉÚÉÒÕÀÔÓÑ ÎÕÌÅÍ É, ËÒÏÍÅ ÔÏÇÏ, ÍÁËÒÏÐÁËÅÔ +Plain\index{ÍÁËÒÏÓÙ Plain} ÄÁÅÔ ÎÅËÏÔÏÒÙÍ ÉÚ ÎÉÈ ÎÅÎÕÌÅ×ÙÅ ÚÎÁÞÅÎÉÑ. +%%Internal variables are initially zero +%%except that the Plain\index{Plain macros} macro package gives some of +%%them nonzero initial values. +(íÁËÒÏÓÙ Plain ÏÂÙÞÎÏ ÚÁÇÒÕÖÁÀÔÓÑ Á×ÔÏÍÁÔÉÞÅÓËÉ × ÎÁÞÁÌÅ ÒÁÂÏÔÙ ËÁË +ÏÐÉÓÁÎÏ × ÒÁÚÄÅÌÅ~\ref{intro}.) +%%(The Plain macros are normally preloaded +%%automatically as explained in Section~\ref{intro}.) + +\section{éÎÔÅÇÒÁÃÉÑ ÔÅËÓÔÁ É ÇÒÁÆÉËÉ} +%%\section{Integrating Text and Graphics} +\label{text} + +MetaPost ÉÍÅÅÔ ÎÅÓËÏÌØËÏ ×ÏÚÍÏÖÎÏÓÔÅÊ ÄÌÑ ×ËÌÀÞÅÎÉÑ ÍÅÔÏË É ÐÒÏÞÅÇÏ +ÔÅËÓÔÁ\index{ÔÅËÓÔ É ÇÒÁÆÉËÁ} × ÇÅÎÅÒÉÒÕÅÍÙÅ ÉÍ ÒÉÓÕÎËÉ. +%%MetaPost has a number of features for including labels and other +%%text\index{text and graphics} in the figures it generates. +ðÒÏÓÔÅÊÛÉÊ ÓÐÏÓÏ ÓÄÅÌÁÔØ ÜÔÏ × ÉÓÐÏÌØÚÏ×ÁÎÉÉ ËÏÍÁÎÄÙ {\tt +label}\index{label?\texttt{label}}\label{Dlabel}\index{label +suffix?\tdescr{ÓÕÆÆÉËÓ ÍÅÔËÉ}} +$$ {\tt label}\descr{ÓÕÆÆÉËÓ ÍÅÔËÉ} \hbox{\tt (} + \descr{×ÙÒÁÖÅÎÉÅ-ÓÔÒÏËÁ ÉÌÉ ËÁÒÔÉÎËÁ} \hbox{\tt,}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ} + \hbox{\tt );} +$$ +%%The simplest +%%way to do this is to use the {\tt +%%label}\index{label?\texttt{label}}\label{Dlabel} statement\index{label +%%suffix?\tdescr{label suffix}} +%%$$ {\tt label}\descr{label suffix} \hbox{\tt (} +%% \descr{string or picture expression} \hbox{\tt,}\, \descr{pair expression} +%% \hbox{\tt );} +%%$$ +\tdescr{÷ÙÒÁÖÅÎÉÅ-ÓÔÒÏËÁ ÉÌÉ ËÁÒÔÉÎËÁ} ÚÁÄÁÅÔ ÍÅÔËÕ, Á +\tdescr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ} ÐÏÚÉÃÉÀ ÄÌÑ ÎÅÅ. +%%The \tdescr{string or picture expression} gives the label and the +%%\tdescr{pair expression} says where to put it. +\tdescr{óÕÆÆÉËÓ ÍÅÔËÉ} ÍÏÖÅÔ ÂÙÔØ \tdescr{ÐÕÓÔÙÍ}, ÞÔÏ ÂÕÄÅÔ ÏÚÎÁÞÁÔØ +ÃÅÎÔÒÉÒÏ×ÁÔØ ÍÅÔËÕ ÎÁ ÚÁÄÁÎÎÙÈ ËÏÏÒÄÉÎÁÔÁÈ. +%%The \tdescr{label +%%suffix} can be \tdescr{empty} in which case the label is just centered +%%on the given coordinates. +åÓÌÉ ×Ù ÒÁÚÍÅÞÁÅÔÅ ÎÅËÏÔÏÒÙÅ ÕÞÁÓÔËÉ ÄÉÁÇÒÁÍÍÙ, ÔÏ ×ÁÍ ×ÅÒÏÑÔÎÏ ÐÏÎÁÄÏÂÉÔÓÑ +ÓÌÅÇËÁ ÓÍÅÓÔÉÔØ ÍÅÔËÕ, ÞÔÏÂÙ ÉÚÂÅÖÁÔØ ÎÁËÌÁÄËÉ. +%%If you are labeling some feature of a diagram +%%you probably want to offset the label slightly to avoid overlapping. +üÔÏ ÉÌÌÀÓÔÒÉÒÕÅÔÓÑ ÎÁ ÒÉÓ.~\ref{fig16}, ÇÄÅ ÍÅÔËÁ {\tt \qq{a}\qq} +ÒÁÚÍÅÝÁÅÔÓÑ ÎÁÄ ÓÅÒÅÄÉÎÏÊ ÕËÁÚÙ×ÁÅÍÏÊ ÌÉÎÉÉ, Á ÍÅÔËÁ {\tt \qq{b}\qq} --- +ÓÌÅ×Á ÏÔ ÓÅÒÅÄÉÎÙ Ó×ÏÅÊ ÌÉÎÉÉ. +%%This is illustrated in Figure~\ref{fig16} where the {\tt \qq{a}\qq} label is +%%placed above the midpoint of the line it refers to and the {\tt \qq{b}\qq} +%%label is to the left of the midpoint of its line. +üÔÏ ÄÏÓÔÉÇÁÅÔÓÑ ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ {\tt label.top}\index{top?\texttt{top}} ÄÌÑ +ÍÅÔËÉ {\tt \qq{a}\qq} É {\tt label.lft}\index{lft?\texttt{lft}} ÄÌÑ +ÍÅÔËÉ {\tt \qq{b}\qq}, ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓÕÎËÅ. +%%This is achieved by +%%using {\tt label.top}\index{top?\texttt{top}} for the {\tt \qq{a}\qq} label +%%and {\tt label.lft}\index{lft?\texttt{lft}} for the {\tt \qq{b}\qq} label as +%%shown in the figure. +\tdescr{óÕÆÆÉËÓ ÍÅÔËÉ} ÕËÁÚÙ×ÁÅÔ ÐÏÚÉÃÉÀ ÍÅÔËÉ ÏÔÎÏÓÉÔÅÌØÎÏ ÚÁÄÁÎÎÙÈ +ËÏÏÒÄÉÎÁÔ. +%%The \tdescr{label suffix} specifies the position +%%of the label relative to the specified coordinates. +ðÏÌÎÏÅ ÍÎÏÖÅÓÔ×Ï ×ÏÚÍÏÖÎÏÓÔÅÊ --- ÜÔÏ\index{rt?\texttt{rt}}\index{bot?\texttt{bot}}% +\index{ulft?\texttt{ulft}}\index{urt?\texttt{urt}}\index{llft?\texttt{llft}}\index{lrt?\texttt{lrt}} +$$ {\tt \descr{ÓÕÆÆÉËÓ ÍÅÔËÉ} \rightarrow + \descr{ÐÕÓÔÏ} \;|\; lft \;|\; rt \;|\; top \;|\; bot \;|\; + ulft \;|\;urt \;|\; llft \;|\; lrt}, +$$ +ÇÄÅ {\tt lft} É {\tt rt} ÏÚÎÁÞÁÀÔ ×ÌÅ×Ï É ×ÐÒÁ×Ï, Á {\tt llft}, {\tt +ulft} É Ô.~Ð. ÚÎÁÞÁÔ ×ÎÉÚ É ×ÌÅ×Ï, ××ÅÒÈ É ×ÌÅ×Ï É Ô.~Ð. +%%The complete set of +%%possibilities is\index{rt?\texttt{rt}}\index{bot?\texttt{bot}}% +%%\index{ulft?\texttt{ulft}}\index{urt?\texttt{urt}}\index{llft?\texttt{llft}}\index{lrt?\t%%exttt{lrt}} +%%$$ \tt \descr{label suffix} \rightarrow +%% \descr{empty} \;|\; lft \;|\; rt \;|\; top \;|\; bot \;|\; +%% ulft \;|\;urt \;|\; llft \;|\; lrt +%%$$ +%%where {\tt lft} and {\tt rt} mean left and right and {\tt llft}, {\tt +%%ulft}, etc.\ mean lower left, upper left, etc. +äÅÊÓÔ×ÉÔÅÌØÎÏÅ ÒÁÓÓÔÏÑÎÉÅ, ÎÁ ËÏÔÏÒÏÅ ÂÕÄÅÔ ÓÍÅÝÅÎÁ ÍÅÔËÁ × ÚÁÄÁÎÎÏÍ +ÎÁÐÒÁ×ÌÅÎÉÉ, ÏÐÒÅÄÅÌÑÅÔÓÑ ×ÎÕÔÒÅÎÎÅÊ +ÐÅÒÅÍÅÎÎÏÊ \index{×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} +{\tt +labeloffset}\index{labeloffset?\texttt{labeloffset}}\label{Dlaboff}. +%%The actual amount by +%%which the label is offset in whatever direction is determined by the +%%internal variable\index{internal variables}\index{variables!internal} +%%{\tt +%%labeloffset}\index{labeloffset?\texttt{labeloffset}}\label{Dlaboff}. + +\begin{figure}[htp] +$$ +\begin{verbatim} +beginfig(17); +a=.7in; b=.5in; +z0=(0,0); +z1=-z3=(a,0); +z2=-z4=(0,b); +draw z1..z2..z3..z4..cycle; +draw z1--z0--z2; +label.top("a", .5[z0,z1]); +label.lft("b", .5[z0,z2]); +dotlabel.bot("(0,0)", z0); +endfig; +\end{verbatim} +\qquad \mathcenter{\includegraphics{manfig-ru-17}} +$$ +\caption{ëÏÄ MetaPost É ÒÅÚÕÌØÔÁÔ ×Ù×ÏÄÁ} +%%\caption{MetaPost code and the resulting output} +\label{fig16} +\end{figure} + +òÉÓ.\ref{fig16} ÔÁËÖÅ ÉÌÌÀÓÔÒÉÒÕÅÔ ËÏÍÁÎÄÕ {\tt dotlabel}\index{dotlabel?\texttt{dotlabel}}\label{Ddotlab}. +%%Figure~\ref{fig16} also illustrates the +%%{\tt dotlabel}\index{dotlabel?\texttt{dotlabel}}\label{Ddotlab} +%%statement. +ïÎÁ × ÔÏÞÎÏÓÔÉ ÔÁËÁÑ ÖÅ ËÁË ËÏÍÁÎÄÁ {\tt label}, ÚÁ ËÏÔÏÒÏÊ ÓÌÅÄÕÅÔ +ËÏÍÁÎÄÁ ÒÉÓÏ×ÁÎÉÑ ÔÏÞËÉ × ÚÁÄÁÎÎÙÈ ËÏÏÒÄÉÎÁÔÁÈ. +%%This is effectively +%%like a {\tt label} statement followed by a statement drawing a dot at +%%the indicated coordinates. +îÁÐÒÉÍÅÒ, +$$ \hbox{\tt dotlabel.bot(\qq(0,0)\qq, z0)} $$ +ÐÏÍÅÝÁÅÔ ÔÏÞËÕ × {\tt z0} É ÚÁÔÅÍ ÒÁÚÍÅÝÁÅÔ ÍÅÔËÕ ``(0,0)'' ÔÏÞÎÏ ÐÏÄ ÔÏÞËÏÊ. +%%For example +%%$$ \hbox{\tt dotlabel.bot("(0,0)", z0)} $$ +%%places a dot at {\tt z0} and then puts the label ``(0,0)'' just below the dot. + +äÒÕÇÏÊ ÁÌØÔÅÒÎÁÔÉ×ÏÊ Ñ×ÌÑÅÔÓÑ ÍÁËÒÏÓ {\tt thelabel}\index{thelabel?\texttt{thelabel}}\label{Dthelab}. +%%Another alternative is the macro +%%{\tt thelabel}\index{thelabel?\texttt{thelabel}}\label{Dthelab}. +ïÎ ÉÍÅÅÔ ÔÁËÏÊ ÖÅ ÓÉÎÔÁËÓÉÓ, ÞÔÏ É ËÏÍÁÎÄÙ {\tt label} É {\tt dotlabel}, ÎÏ +ÏÎ ×ÏÚ×ÒÁÝÁÅÔ ÒÅÚÕÌØÔÁÔ ËÁË \tdescr{ÐÅÒ×ÉÞÎÙÊ ÒÉÓÕÎÏË} ×ÍÅÓÔÏ ÅÇÏ +ÄÅÊÓÔ×ÉÔÅÌØÎÏÇÏ ÉÚÏÂÒÁÖÅÎÉÑ. +%%This has +%%the same syntax as the {\tt label} and {\tt dotlabel} statements except that it +%%returns the label as a \tdescr{picture primary} instead of actually drawing it. +ôÁËÉÍ ÏÂÒÁÚÏÍ, +$$ \hbox{\tt label.bot(\qq(0,0)\qq, z0)} $$ +ÜË×É×ÁÌÅÎÔÎÏ +$$ \hbox{\tt draw thelabel.bot(\qq(0,0)\qq, z0)} $$ +%%Thus +%%$$ \hbox{\tt label.bot("(0,0)", z0)} $$ +%%is equivalent to +%%$$ \hbox{\tt draw thelabel.bot("(0,0)", z0)} $$ + +äÌÑ ÐÒÏÓÔÙÈ ÓÌÕÞÁÅ× ÒÁÚÍÅÞÅÎÎÙÈ ÒÉÓÕÎËÏ×, ×ÁÍ ÍÏÖÅÔ ÏÂÙÞÎÏ ÂÙÔØ ÄÏÓÔÁÔÏÞÎÏ +{\tt label} É {\tt dotlabel}. +%%For simple applications of labeled figures, you can normally get by with +%%just {\tt label} and {\tt dotlabel}. +äÏÐÏÌÎÉÔÅÌØÎÏ ×Ù ÍÏÖÅÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ ËÏÒÏÔËÕÀ ÆÏÒÍÕ ËÏÍÁÎÄÙ {\tt dotlabel}, +ÞÔÏ ÓÜËÏÎÏÍÉÔ ÍÎÏÇÏ ×ÒÅÍÅÎÉ, ËÏÇÄÁ ×Ù ÉÍÅÅÔÅ ÍÎÏÇÏ ÔÏÞÅË {\tt z0}, {\tt z1}, +{\tt z.a}, {\tt z.b}, É Ô.~Ð. É ÈÏÔÉÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ ÓÕÆÆÉËÓÙ {\tt z} ËÁË ÍÅÔËÉ. +%%In fact, you may be able to use a +%%short form of the {\tt dotlabel} statement that saves a lot of typing +%%when you have many points {\tt z0}, {\tt z1}, {\tt z.a}, {\tt z.b}, +%%etc.\ and you want to use the {\tt z} suffixes as labels. +ëÏÍÁÎÄÁ \index{dotlabels?\texttt{dotlabels}}\label{Ddotlbs} +$$ \hbox{\tt dotlabels.rt(0, 1, a);} $$ +ÜË×É×ÁÌÅÎÔÎÁ +$$ \hbox{\tt dotlabel.rt(\qq0\qq,z0); dotlabel.rt(\qq1\qq,z1); dotlabel.rt({\qq}a{\qq},z.a);} $$ +%%The statement\index{dotlabels?\texttt{dotlabels}}\label{Ddotlbs} +%%$$ \hbox{\tt dotlabels.rt(0, 1, a);} $$ +%%is equivalent to +%%$$ \hbox{\tt dotlabel.rt("0",z0); dotlabel.rt("1",z1); dotlabel.rt("a",z.a);} $$ +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÁÒÇÕÍÅÎÔ {\tt dotlabels} --- ÜÔÏ ÓÐÉÓÏË ÓÕÆÆÉËÓÏ× ÄÌÑ +ÐÅÒÅÍÅÎÎÙÈ {\tt z}, Á \tdescr{ÓÕÆÆÉËÓ ÍÅÔËÉ}, ÚÁÄÁ×ÁÅÍÙÊ Ó {\tt dotlabels}, +ÉÓÐÏÌØÚÕÅÔÓÑ ÄÌÑ ÐÏÚÉÃÉÏÎÉÒÏ×ÁÎÉÑ ×ÓÅÈ ÍÅÔÏË. +%%Thus the argument to {\tt dotlabels} is a list of suffixes for which {\tt z} +%%variables are known, and the \tdescr{label suffix} given with {\tt dotlabels} +%%is used to position all the labels. + +åÓÔØ ÅÝÅ ËÏÍÁÎÄÁ {\tt +labels}\index{labels?\texttt{labels}}\label{Dlabels}, ÁÎÁÌÏÇÉÞÎÁÑ +{\tt dotlabels}, ÎÏ ÅÅ ÉÓÐÏÌØÚÏ×ÁÎÉÅ ÎÅ ÒÅËÏÍÅÎÄÕÅÔÓÑ, Ô.~Ë. ÏÎÁ ÓÏÚÄÁÅÔ +ÐÒÏÂÌÅÍÙ ÓÏ×ÍÅÓÔÉÍÏÓÔÉ Ó \MF\index{metafont?\MF}. +%%There is also a {\tt +%%labels}\index{labels?\texttt{labels}}\label{Dlabels} statement that is +%%analogous to {\tt dotlabels} but its use is discouraged because it +%%presents compatibility problems with \MF\index{metafont?\MF}. +îÅËÏÔÏÒÙÅ ×ÅÒÓÉÉ ÓÔÁÎÄÁÒÔÎÏÇÏ ÍÁËÒÏÐÁËÅÔÁ Plain\index{ÍÁËÒÏÓÙ Plain} ÏÐÒÅÄÅÌÑÀÔ +{\tt labels} ËÁË ÓÉÎÏÎÉÍ {\tt dotlabels}. +%%Some +%%versions of the preloaded Plain\index{Plain macros} macro package define +%%{\tt labels} to be synonymous with {\tt dotlabels}. + +äÌÑ ËÏÍÁÎÄ ÒÁÚÍÅÔËÉ, ÔÁËÉÈ ËÁË {\tt label} É {\tt dotlabel}, ÉÓÐÏÌØÚÕÀÝÉÈ +ÓÔÒÏËÏ×ÙÅ ×ÙÒÁÖÅÎÉÑ ÄÌÑ ÔÅËÓÔÁ ÍÅÔÏË, ÓÔÒÏËÉ ÐÅÞÁÔÁÀÔÓÑ × ÓÔÁÎÄÁÒÔÎÏÍ +ÛÒÉÆÔÅ, ÏÐÒÅÄÅÌÑÅÍÏÍ ÓÔÒÏËÏ×ÏÊ ÐÅÒÅÍÅÎÎÏÊ {\tt +defaultfont}\index{defaultfont?\texttt{defaultfont}}\label{Ddffont}. +%%For labeling statements such as {\tt label} and {\tt dotlabel} that use +%%a string expression for the label text, the string gets typeset in a +%%default font as determined by the string variable {\tt +%%defaultfont}\index{defaultfont?\texttt{defaultfont}}\label{Ddffont}. +îÁÞÁÌØÎÏÅ ÚÎÁÞÅÎÉÅ {\tt defaultfont} --- ÜÔÏ ÏÂÙÞÎÏ {\tt \qq{cmr10}\qq}, +ÎÏ ÏÎÏ ÍÏÖÅÔ ÂÙÔØ ÉÚÍÅÎÅÎÏ ÎÁ ÄÒÕÇÏÅ ÉÍÑ ÛÒÉÆÔÁ ÐÒÉÓ×ÁÉ×ÁÎÉÅÍ, ÎÁÐÒÉÍÅÒ, +$$ \hbox{\tt defaultfont:=\qq{ptmr8r}\qq}, $$ +\ttt{ptmr8r} --- ÜÔÏ ÔÉÐÉÞÎÙÊ ÓÐÏÓÏ ÓÏÓÌÁÔØÓÑ ÎÁ ÛÒÉÆÔ Times-Roman × \TeX. +%%The initial value of {\tt defaultfont} is likely to be {\tt \qq{cmr10}\qq}, +%%but it can be changed to a different font name by giving an assignment +%%such as +%%$$ \hbox{\tt defaultfont:=\qq{ptmr8r}\qq} $$ +%%\ttt{ptmr8r} is a typical way to refer to the Times-Roman font in \TeX. +%%The discussion of font names on p.\ \pageref{fontname} explains further. + +åÓÔØ ÅÝÅ ÞÉÓÌÏ×ÏÅ ËÏÌÉÞÅÓÔ×Ï, ÎÁÚÙ×ÁÅÍÏÅ {\tt defaultscale}\index{defaultscale?\texttt{defaultscale}}\label{Ddfscale}, +ÏÐÒÅÄÅÌÑÀÝÅÅ ÒÁÚÍÅÒ ÛÒÉÆÔÁ. +%%There is also a numeric quantity called +%%{\tt defaultscale}\index{defaultscale?\texttt{defaultscale}}\label{Ddfscale} +%%that determines the type size. +ðÏËÁ {\tt default\-scale} ÒÁ×ÎÏ 1, ×Ù ÐÏÌÕÞÁÅÔÅ ``ÎÏÒÍÁÌØÎÙÊ ÒÁÚÍÅÒ'', +ËÏÔÏÒÙÊ ÏÂÙÞÎÏ ÒÁ×ÅÎ 10 ÐÕÎËÔÁÍ, ÎÏ ÜÔÏ ÍÏÖÎÏ ÉÚÍÅÎÉÔØ. +%%When {\tt default\-scale} is 1, you get the ``normal size'' which is +%%usually 10 point, but this can also be changed. +îÁÐÒÉÍÅÒ, +$$ \hbox{\tt defaultscale := 1.2} $$ +ÄÅÌÁÅÔ ÍÅÔËÉ ÎÁ Ä×ÁÄÃÁÔØ ÐÒÏÃÅÎÔÏ× ÂÏÌØÛÅ. +%%For instance +%%$$ \hbox{\tt defaultscale := 1.2} $$ +%%makes labels come out twenty percent larger. +åÓÌÉ ×ÁÍ ÎÅÉÚ×ÅÓÔÅÎ ÎÏÒÍÁÌØÎÙÊ ÒÁÚÍÅÒ É ×Ù ÈÏÔÉÔÅ ÂÙÔØ Õ×ÅÒÅÎÎÙÍÉ × +ËÏÎËÒÅÔÎÏÍ ÒÁÚÍÅÒÅ ÛÒÉÆÔÁ, ÓËÁÖÅÍ 12 ÐÕÎËÔÏ×, ×Ù ÍÏÖÅÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ +ÏÐÅÒÁÔÏÒ {\tt fontsize}\index{fontsize?\texttt{fontsize}}\label{Dfntsiz} +ÄÌÑ ÏÐÒÅÄÅÌÅÎÉÑ ÎÏÒÍÁÌØÎÏÇÏ ÒÁÚÍÅÒÁ, ÎÁÐÒÉÍÅÒ, +$$ \hbox{\tt defaultscale := 12pt/fontsize defaultfont;} $$ +%%If you do not know the +%%normal size and you want to be sure the text comes out at some specific +%%size, say 12 points, you can use the {\tt +%%fontsize}\index{fontsize?\texttt{fontsize}}\label{Dfntsiz} operator to +%%determine the normal size: e.g., +%%$$ \hbox{\tt defaultscale := 12pt/fontsize defaultfont;} $$ + +\label{fontname} +ëÏÇÄÁ ×Ù ÍÅÎÑÅÔÅ {\tt defaultfont}, ÔÏ ÉÍÑ ÎÏ×ÏÇÏ ÛÒÉÆÔÁ ÄÏÌÖÎÏ ÂÙÔØ +ÞÅÍ-ÔÏ, ÞÔÏ \TeX\ ÓÍÏÖÅÔ ÐÏÎÑÔØ, Ô.~Ë. MetaPost ÐÏÌÕÞÁÅÔ ÉÎÆÏÒÍÁÃÉÀ Ï +×ÙÓÏÔÅ É ÛÉÒÉÎÅ ÞÔÅÎÉÅÍ +{\tt tfm}\index{tfm file?{\tt tfm}-ÆÁÊÌ}\index{ÆÁÊÌÙ!tfm?{\tt tfm}}-ÆÁÊÌÁ. +%%When you change {\tt defaultfont}, the new font name should be something +%%that \TeX\ would understand since MetaPost gets height and width +%%information by reading a {\tt tfm}\index{tfm file?{\tt tfm} +%%file}\index{files!tfm?{\tt tfm}} file. +(üÔÏ ÏÂßÑÓÎÑÅÔÓÑ × {\sl The \TeX book\/} \cite{kn:a}.) +%%(This is explained in {\sl The \TeX book\/} \cite{kn:a}.) +äÏÌÖÎÏ ÂÙÔØ ×ÏÚÍÏÖÎÏ ÉÓÐÏÌØÚÏ×ÁÔØ ×ÓÔÒÏÅÎÎÙÅ ÛÒÉÆÔÙ +PostScript\index{PostScript!ÛÒÉÆÔÙ}, ÎÏ ÉÈ ÉÍÅÎÁ ÚÁ×ÉÓÑÔ ÏÔ ÓÉÓÔÅÍÙ. +%%It should be possible to use built-in +%%PostScript\index{PostScript!fonts} fonts, but the names for +%%them are system-dependent. +îÅËÏÔÏÒÙÅ ÔÉÐÉÞÎÙÅ ÉÍÅÎÁ ÛÒÉÆÔÏ× --- ÜÔÏ {\tt ptmr8r} ÄÌÑ +Times-Roman\index{Times-Roman}, \ttt{pplr8r} ÄÌÑ Palatino\index{Palatino} +É \ttt{phvr} ÄÌÑ Helvetica\index{Helvetica}. +%%Some typical ones are {\tt ptmr8r} for +%%Times-Roman\index{Times-Roman}, \ttt{pplr8r} for Palatino\index{Palatino}, +%%and \ttt{phvr} for Helvetica\index{Helvetica}. +äÏËÕÍÅÎÔ Fontname, ÄÏÓÔÕÐÎÙÊ × +\url{http://tug.org/fontname}, ÓÏÄÅÒÖÉÔ ÍÎÏÇÏ ÉÎÆÏÒÍÁÃÉÉ Ï ÉÍÅÎÁÈ ÛÒÉÆÔÏ× +É \TeX. +%%The Fontname document, +%%available at \url{http://tug.org/fontname}, has much more information +%%about font names and \TeX. +\TeX\index{TeX?\TeX!ÛÒÉÆÔÙ}-ÛÒÉÆÔ, ÔÁËÏÊ ËÁË {\tt cmr10}, Ñ×ÌÑÅÔÓÑ ÎÅÍÎÏÇÏ +ÏÐÁÓÎÙÍ, ÐÏÔÏÍÕ ÞÔÏ ÏÎ ÎÅ ÉÍÅÅÔ ÓÉÍ×ÏÌÁ ÐÒÏÂÅÌ É ÎÅËÏÔÏÒÙÈ ÄÒÕÇÉÈ ÓÉÍ×ÏÌÏ× +ASCII. +%%A \TeX\index{TeX?\TeX!fonts} font such +%%as {\tt cmr10} is a little dangerous because it does not have a space +%%character or certain ASCII symbols. + +MetaPost ÎÅ ÉÓÐÏÌØÚÕÅÔ ÉÎÆÏÒÍÁÃÉÀ Ï ÌÉÇÁÔÕÒÁÈ\index{ÌÉÇÁÔÕÒÙ} É +ËÅÒÎÉÎÇÁÈ\index{ËÅÒÎÉÎÇ}, ÞÔÏ ÓÏÄÅÒÖÉÔÓÑ × ÛÒÉÆÔÁÈ \TeX. +%%MetaPost does not use the ligatures\index{ligatures} and +%%kerning\index{kerning} information that comes with a \TeX\ font. +âÏÌÅÅ ÔÏÇÏ, ÓÁÍ MetaPost ÎÅ ÍÏÖÅÔ ÉÎÔÅÒÐÒÅÔÉÒÏ×ÁÔØ ×ÉÒÔÕÁÌØÎÙÅ ÛÒÉÆÔÙ. +%%Further, MetaPost itself does not interpret virtual fonts. + +\subsection{îÁÂÏÒ ×ÁÛÉÈ ÍÅÔÏË} +%%\subsection{Typesetting Your Labels} + +\label{Dbtex} +\index{ÍÅÔËÉ, ÎÁÂÏÒ} +%%\index{labels, typesetting} + +\TeX\index{TeX?\TeX} ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎ ÄÌÑ ÆÏÒÍÁÔÉÒÏ×ÁÎÉÑ ÓÌÏÖÎÙÈ ÍÅÔÏË. +%%\TeX\index{TeX?\TeX} may be used to format complex labels. +åÓÌÉ ×Ù ÎÁÐÉÛÉÔÅ \index{btex?\texttt{btex}}\index{etex?\texttt{etex}} +$$ {\tt btex}\, \descr{ËÏÍÁÎÄÙ ÐÅÞÁÔÉ}\, {\tt etex} $$ +×Ï ×ÈÏÄÎÏÍ ÆÁÊÌÅ MetaPost, ÔÏ \tdescr{ËÏÍÁÎÄÙ ÐÅÞÁÔÉ} ÂÕÄÕÔ ÏÂÒÁÂÏÔÁÎÙ +\TeX\ É ÔÒÁÎÓÌÉÒÏ×ÁÎÙ × ×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÕ, ÔÏÞÎÅÅ × \tdescr{ÐÅÒ×ÉÞÎÙÊ +ÒÉÓÕÎÏË}, ÞÔÏ ÓÍÏÖÅÔ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ × ËÏÍÁÎÄÅ {\tt label} ÉÌÉ {\tt dotlabel}. +%%If you say\index{btex?\texttt{btex}}\index{etex?\texttt{etex}} +%%$$ {\tt btex}\, \descr{typesetting commands}\, {\tt etex} $$ +%%in a MetaPost input file, the \tdescr{typesetting commands} get processed by +%%\TeX\ and translated into a picture expression +%%(actually a \tdescr{picture primary}) that can be used in a {\tt label} +%%or {\tt dotlabel} statement. +ðÒÏÂÅÌÙ ÐÏÓÌÅ {\tt btex} ÉÌÉ ÐÅÒÅÄ {\tt etex} ÉÇÎÏÒÉÒÕÀÔÓÑ. +%%Any spaces after {\tt btex} or before {\tt etex} are ignored. +îÁÐÒÉÍÅÒ, ËÏÍÁÎÄÁ +$$ \hbox{\verb|label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u)|} $$ +ÎÁ ÒÉÓ.~\ref{fig17} ÐÏÍÅÓÔÉÔ ÍÅÔËÕ $\sqrt x$ ÓÎÉÚÕ É ×ÐÒÁ×Ï ÏÔ +ÔÏÞËÉ {\tt (3,sqrt 3)*u}. +%%For instance, the statement +%%$$ \hbox{\verb|label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u)|} $$ +%%in Figure~\ref{fig17} places the label $\sqrt x$ at the lower right of the +%%point {\tt (3,sqrt 3)*u}. + +\begin{figure}[htp] +$$ +\begin{verbatim} +beginfig(18); +numeric u; +u = 1cm; +draw (0,2u)--(0,0)--(4u,0); +pickup pencircle scaled 1pt; +draw (0,0){up} + for i=1 upto 8: ..(i/2,sqrt(i/2))*u endfor; +label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u); +label.bot(btex $x$ etex, (2u,0)); +label.lft(btex $y$ etex, (0,u)); +endfig; +\end{verbatim} +\qquad \mathcenter{\includegraphics{manfig-ru-18}} +$$ +\caption{ðÒÏÉÚ×ÏÌØÎÙÊ \TeX\ × ËÁÞÅÓÔ×Å ÍÅÔËÉ} +%%\caption{Arbitrary \TeX\ as labels} +\label{fig17} +\end{figure} + +òÉÓ.~\ref{fig18} ÉÌÌÀÓÔÒÉÒÕÅÔ ÎÅËÏÔÏÒÙÅ ÂÏÌÅÅ ÓÌÏÖÎÙÅ ×ÅÝÉ, ÞÔÏ ÍÏÖÎÏ +ÓÄÅÌÁÔØ Ó ÍÅÔËÁÍÉ. +%%Figure~\ref{fig18} illustrates some of the more complicated things that can +%%be done with labels. +÷ÓÌÅÄÓÔ×ÉÅ ÔÏÇÏ, ÞÔÏ ÒÅÚÕÌØÔÁÔÏÍ {\tt btex} \ldots {\tt etex} Ñ×ÌÑÅÔÓÑ +ËÁÒÔÉÎËÁ, ÉÍ ÍÏÖÎÏ ÏÐÅÒÉÒÏ×ÁÔØ ËÁË ËÁÒÔÉÎËÏÊ. +%%Since the result of {\tt btex} \ldots {\tt etex} is +%%a picture, it can be operated on like a picture. +÷ ÞÁÓÔÎÏÓÔÉ, Ë ËÁÒÔÉÎËÁÍ ×ÏÚÍÏÖÎÏ ÐÒÉÍÅÎÑÔØ ÔÒÁÎÓÆÏÒÍÁÃÉÉ. +%%In particular, it is possible +%%to apply transformations to pictures. +íÙ ÐÏËÁ ÎÅ ÏÂÓÕÖÄÁÌÉ ÓÉÎÔÁËÓÉÓ ÄÌÑ ÜÔÏÇÏ, ÎÏ \tdescr{ÒÉÓÕÎÏË-×ÔÏÒÉÞÎÏÓÔØ} +ÍÏÖÅÔ ÂÙÔØ \index{×ÒÁÝÁÅÍÙÊ ÔÅËÓÔ}\index{rotated?\texttt{rotated}} +$$ \descr{ÒÉÓÕÎÏË-×ÔÏÒÉÞÎÏÓÔØ}\, {\tt rotated}\, \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ} $$ +%%We have not discussed the syntax for +%%this yet, but a \tdescr{picture secondary} +%%can be\index{rotated text}\index{rotated?\texttt{rotated}} +%%$$ \descr{picture secondary}\, {\tt rotated}\, \descr{numeric primary} $$ +üÔÏ ÉÓÐÏÌØÚÕÅÔÓÑ ÎÁ ÒÉÓ.~\ref{fig18} ÄÌÑ ×ÒÁÝÅÎÉÑ ÍÅÔËÉ ``$y$ axis'' ÔÁË, +ÞÔÏ ÏÎÁ ÒÁÓÐÏÌÁÇÁÅÔÓÑ ÐÏ-×ÅÒÔÉËÁÌÉ. +%%This is used in Figure~\ref{fig18} to rotate the label ``$y$ axis'' so that +%%it runs vertically. + +\begin{figure}[htp] +$$ +\begin{verbatim} +beginfig(19); +numeric ux, uy; +120ux=1.2in; 4uy=2.4in; +draw (0,4uy)--(0,0)--(120ux,0); +pickup pencircle scaled 1pt; +draw (0,uy){right} + for ix=1 upto 8: + ..(15ix*ux, uy*2/(1+cosd 15ix)) + endfor; +label.bot(btex $x$ axis etex, (60ux,0)); +label.lft(btex $y$ axis etex rotated 90, + (0,2uy)); +label.lft( + btex $\displaystyle y={2\over1+\cos x}$ etex, + (120ux, 4uy)); +endfig; +\end{verbatim} +\qquad \mathcenter{\includegraphics{manfig-ru-19}} +$$ +\caption{íÁÔÅÍÁÔÉÞÅÓËÉÅ ÍÅÔËÉ \TeX\ É ÍÅÔËÉ, ×ÒÁÝÁÅÍÙÅ MetaPost} +%%\caption{\TeX\ labels with display math, and rotated by MetaPost} +\label{fig18} +\end{figure} + +äÒÕÇÏÊ ÓÌÏÖÎÏÓÔØÀ ÎÁ ÒÉÓ.~\ref{fig18} Ñ×ÌÑÅÔÓÑ ÉÓÐÏÌØÚÏ×ÁÎÉÅ ÕÒÁ×ÎÅÎÉÑ +$$y={2\over 1+\cos x}$$ +ËÁË ÍÅÔËÉ. +%%Another complication in Figure~\ref{fig18} is the use of the displayed equation +%%$$y={2\over 1+\cos x}$$ +%%as a label. +âÕÄÅÔ ÂÏÌÅÅ ÅÓÔÅÓÔ×ÅÎÎÏ ÚÁËÏÄÉÒÏ×ÁÔØ ÜÔÕ ÍÅÔËÕ ËÁË +$$ \hbox{\verb|$$y={2\over 1+\cos x}$$|}, $$ +ÎÏ ÜÔÏ ÎÅ ÓÒÁÂÏÔÁÅÔ, ÐÏÔÏÍÕ ÞÔÏ \TeX\ ÎÁÂÉÒÁÅÔ ÍÅÔËÉ × +``ÇÏÒÉÚÏÎÔÁÌØÎÏÍ ÒÅÖÉÍÅ''. +%%It would be more natural to code this as +%%$$ \hbox{\verb|$$y={2\over 1+\cos x}$$|} $$ +%%but this would not work because +%%\TeX\ typesets the labels in ``horizontal mode.'' + +äÌÑ ÐÅÞÁÔÉ \emph{ÐÅÒÅÍÅÎÎÏÇÏ} ÔÅËÓÔÁ, ËÁË ÍÅÔËÉ, ÉÓÐÏÌØÚÕÊÔÅ +ÐÏÌÅÚÎÏÅ ÓÒÅÄÓÔ×Ï \texttt{TEX}, ÏÐÉÓÁÎÎÏÅ ÎÁ ÓÔÒ.\ \pageref{dTEX}. +%%For a way to typeset \emph{variable} text as labels, see the +%%\texttt{TEX} utility routine described on p.\ \pageref{dTEX}. + +äÁÌÅÅ Ï ÔÏÍ, ËÁË \TeX-ÔÅËÓÔ ÔÒÁÎÓÌÉÒÕÅÔÓÑ × ÆÏÒÍÕ, ÐÏÎÑÔÎÕÀ MetaPost: +ÐÒÏÃÅÓÓÏÒ MetaPost ÐÒÏÐÕÓËÁÅÔ ÂÌÏË {\tt +btex}\index{btex?\texttt{btex}} \ldots\ {\tt +etex}\index{etex?\texttt{etex}}, ÐÏÌÁÇÁÑÓØ ÎÁ ÐÒÅÐÒÏÃÅÓÓÏÒ, +ËÏÔÏÒÙÊ ÄÏÌÖÅÎ ÐÅÒÅ×ÅÓÔÉ ÜÔÏÔ ÂÌÏË × ËÏÍÁÎÄÙ ÎÉÚËÏÇÏ ÕÒÏ×ÎÑ MetaPost. +%%Here is how \TeX\ material gets translated into a form MetaPost +%%understands: The MetaPost processor skips over {\tt +%%btex}\index{btex?\texttt{btex}} \ldots\ {\tt +%%etex}\index{etex?\texttt{etex}} blocks and depends on a preprocessor to +%%translate them into low level MetaPost commands. +åÓÌÉ {\tt fig.mp} --- ÜÔÏ ÇÌÁ×ÎÙÊ ÆÁÊÌ, ÔÏ ÔÒÁÎÓÌÉÒÏ×ÁÎÎÙÊ \TeX-ÔÅËÓÔ +ÐÏÍÅÝÁÅÔÓÑ × ÆÁÊÌ Ó ÉÍÅÎÅÍ {\tt fig.mpx}\index{ÆÁÊÌÙ!mpx?{\tt mpx}}. +%%If the main file is +%%{\tt fig.mp}, the translated \TeX\ material is placed in a file named +%%{\tt fig.mpx}\index{files!mpx?{\tt mpx}}. +üÔÏ ÏÂÙÞÎÏ ÄÅÌÁÅÔÓÑ ÎÅÚÁÍÅÔÎÏ ÄÌÑ ÐÏÌØÚÏ×ÁÔÅÌÑ, ÎÏ ×ÙÚÙ×ÁÅÔ ÏÛÉÂËÕ, ÅÓÌÉ +ÏÄÉÎ ÉÚ ÂÌÏËÏ× {\tt btex} $\ldots$ {\tt etex} ÓÏÄÅÒÖÉÔ ÏÛÉÂÏÞÎÕÀ ËÏÍÁÎÄÕ +\TeX\index{TeX?\TeX!ÏÛÉÂËÉ}. +%%This is normally done +%%silently without any user intervention but it could fail if one of the +%%{\tt btex} $\ldots$ {\tt etex} blocks contains an erroneous +%%\TeX\index{TeX?\TeX!errors} command. +ðÏÓÌÅ ÏÛÉÂËÉ, ÏÛÉÂÏÞÎÙÊ ÔÅËÓÔ \TeX\ ÓÏÈÒÁÎÑÅÔÓÑ × ÆÁÊÌÅ +{\tt mpxerr.tex}\index{mpxerr.tex?\texttt{mpxerr.tex}} É ÓÏÏÂÝÅÎÉÑ Ï ÏÛÉÂËÁÈ +ÐÏÑ×ÌÑÀÔÓÑ × {\tt +mpxerr.log}\index{mpxerr.log?\texttt{mpxerr.log}}. +%%Then the erroneous \TeX\ input is +%%saved in the file {\tt mpxerr.tex}\index{mpxerr.tex?\texttt{mpxerr.tex}} +%%and the error messages appear in {\tt +%%mpxerr.log}\index{mpxerr.log?\texttt{mpxerr.log}}. + +ðÒÅÐÒÏÃÅÓÓÏÒ ÄÌÑ ÍÅÔÏË \TeX\ {\it ÐÏÎÉÍÁÅÔ\/} ×ÉÒÔÕÁÌØÎÙÅ ÛÒÉÆÔÙ, Ô.~Å. ×Ù +ÍÏÖÅÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ ËÏÍÁÎÄÙ ×ÁÛÅÇÏ ÏÂÙÞÎÏÇÏ \TeX\ ÄÌÑ ÐÅÒÅËÌÀÞÅÎÉÑ ÛÒÉÆÔÏ× +×ÎÕÔÒÉ ÍÅÔËÉ. +%%The preprocessor for \TeX\ labels {\it does\/} understand virtual +%%fonts, so you can use your normal \TeX\ font switching commands inside +%%the label. + +\label{Dverbatimtex} +ïÐÒÅÄÅÌÅÎÉÑ ÍÁËÒÏÓÏ× \TeX\ ÉÌÉ ÌÀÂÙÅ ÄÒÕÇÉÅ ×ÓÐÏÍÏÇÁÔÅÌØÎÙÅ ËÏÍÁÎÄÙ \TeX\ +ÍÏÇÕÔ ÚÁËÌÀÞÁÔØÓÑ × ÂÌÏË {\tt verbatimtex}\index{verbatimtex?\texttt{verbatimtex}} +\ldots\ {\tt etex}\index{etex?\texttt{etex}}. +%%\TeX\ macro definitions or any other auxiliary \TeX\ commands can be +%%enclosed in a {\tt verbatimtex}\index{verbatimtex?\texttt{verbatimtex}} +%%\ldots\ {\tt etex}\index{etex?\texttt{etex}} block. +òÁÚÎÉÃÁ ÍÅÖÄÕ {\tt btex} É {\tt verbatimtex} × ÔÏÍ, ÞÔÏ ÐÅÒ×ÙÊ ÇÅÎÅÒÉÒÕÅÔ +×ÙÒÁÖÅÎÉÅ-ÒÉÓÕÎÏË, Á ×ÔÏÒÏÊ ÔÏÌØËÏ ÄÏÂÁ×ÌÑÅÔ ÄÁÎÎÙÅ ÄÌÑ ÏÂÒÁÂÏÔËÉ \TeX. +%%The difference +%%between {\tt btex} and {\tt verbatimtex} is that the former generates a +%%picture expression while the latter only adds material for \TeX\ to +%%process. +îÁÐÒÉÍÅÒ, ÅÓÌÉ ×Ù ÈÏÔÉÔÅ, ÉÓÐÏÌØÚÕÑ \TeX, ÎÁÐÅÞÁÔÁÔØ ÍÅÔËÉ, ÉÓÐÏÌØÚÕÑ ÍÁËÒÏÓÙ ÉÚ +{\tt mymac.tex}, ÔÏ ×ÁÛ ×ÈÏÄÎÏÊ ÆÁÊÌ ÄÌÑ MetaPost ÂÕÄÅÔ ×ÙÇÌÑÄÅÔØ ÐÏÄÏÂÎÏ ÞÅÍÕ-ÔÏ +ÔÁËÏÍÕ: +%%For instance, if you want \TeX\ to typeset labels using macros +%%defined in {\tt mymac.tex}, your MetaPost input file would look +%%something like this: +\begin{eqnarray*} +&& \verb|verbatimtex \input mymac etex|\\ +&& \verb|beginfig(1);|\\ +&& \qquad \dots\\ +&& \verb|label(btex|\, \descr{\TeX-ÔÅËÓÔ, ÉÓÐÏÌØÚÕÀÝÉÊ \hbox{\tt mymac.tex}}\, + \verb|etex, | \descr{ÎÅËÏÔÏÒÙÅ ËÏÏÒÄÉÎÁÔÙ} \hbox{\tt );}\\ +%%&& \verb|label(btex|\, \descr{\TeX\ material using \hbox{\tt mymac.tex}}\, +%% \verb|etex, | \descr{some coordinates} \hbox{\tt );}\\ +&& \qquad \dots +\end{eqnarray*} + +\label{Dtroffmode} +äÌÑ Unix\footnote{Unix --- ÜÔÏ ÚÁÒÅÇÉÓÔÒÉÒÏ×ÁÎÎÁÑ ÔÏÒÇÏ×ÁÑ ÍÁÒËÁ Unix Systems +Laboratories.}\index{Unix} É ÄÒÕÇÉÈ ÏÓÎÏ×ÁÎÎÙÈ ÎÁ Web2C ÓÉÓÔÅÍ +ÏÐÃÉÑ MetaPost {\tt -troff} ÓËÁÖÅÔ ÐÒÅÐÒÏÃÅÓÓÏÒÕ, ÞÔÏ ÂÌÏËÉ {\tt btex} +$\ldots$ {\tt etex} É {\tt verbatimtex} $\ldots$ {\tt etex} +ÐÒÅÄÓÔÁ×ÌÅÎÙ × troff\index{troff} ×ÍÅÓÔÏ \TeX. +%%On Unix\footnote{Unix is a registered trademark of Unix Systems +%%Laboratories.}\index{Unix\regmark} and other Web2C-based systems, the +%%option {\tt -troff} to MetaPost tells the preprocessor that {\tt btex} +%%$\ldots$ {\tt etex} and {\tt verbatimtex} $\ldots$ {\tt etex} blocks +%%are in troff\index{troff} instead of \TeX. +ëÏÇÄÁ ÉÓÐÏÌØÚÕÅÔÓÑ ÜÔÁ ÏÐÃÉÑ, MetaPost ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ ×ÎÕÔÒÅÎÎÀÀ ÐÅÒÅÍÅÎÎÕÀ +\ttindex{troffmode} ×~1\index{prologues?\texttt{prologues}}. +%%When using this option, +%%MetaPost sets the internal variable +%%\ttindex{troffmode} to~1\index{prologues?\texttt{prologues}}. + +\label{Dprologues} +õÓÔÁÎÏ×ËÁ \ttt{prologues} ÍÏÖÅÔ ÂÙÔØ ÐÏÌÅÚÎÁ ÔÁËÖÅ É Ó \TeX, Á ÎÅ ÔÏÌØËÏ +ÄÌÑ troff. +%%Setting \ttt{prologues} can be useful with \TeX, too, not just troff. +äÁÌÅÅ ÐÒÉ×ÏÄÑÔÓÑ ÎÅËÏÔÏÒÙÅ ÒÁÚßÑÓÎÅÎÉÑ: +%%Here is some explanation: + +\begin{itemize} +\item ëÏÇÄÁ \ttt{prologues} ÒÁ×ÎÏ 0, ÞÔÏ ÕÓÔÁÎÁ×ÌÉ×ÁÅÔÓÑ ÐÏ-ÕÍÏÌÞÁÎÉÀ, +×ÙÈÏÄÎÙÅ ÆÁÊÌÙ MetaPost ÎÅ ÓÏÄÅÒÖÁÔ ÉÓÐÏÌØÚÕÅÍÙÈ ÛÒÉÆÔÏ×. +%%\item When \ttt{prologues} is 0, which is the default, the MetaPost +%%output files do not have embedded fonts. +ûÒÉÆÔÙ × ÒÅÚÕÌØÔÁÔÅ-×Ù×ÏÄÅ ÂÕÄÕÔ ×ÅÒÏÑÔÎÏ Courier\index{Courier} ÉÌÉ +Times-Roman\index{Times-Roman}. +%%Fonts in the resulting +%%output will probably render as Courier\index{Courier} or %%Times-Roman\index{Times-Roman}. + +\item ëÏÇÄÁ \ttt{prologues} ÒÁ×ÎÏ 1, ×Ù×ÏÄ MetaPost ÏÂßÑ×ÌÑÅÔÓÑ +``ÓÔÒÕËÔÕÒÉÒÏ×ÁÎÎÙÍ PostScript''\index{PostScript!ÓÔÒÕËÔÕÒÎÙÊ} (EPSF\index{EPSF}), +ÎÏ ÜÔÏ ÎÅ ×ÐÏÌÎÅ ×ÅÒÎÏ. +%%\item When \ttt{prologues} is 1, the MetaPost output claims to be +%%``structured PostScript''\index{PostScript!structured} (EPSF\index{EPSF}), +%%but it is not completely conformant. +üÔÏÔ ×ÁÒÉÁÎÔ ÐÏÄÄÅÒÖÉ×ÁÅÔÓÑ ÄÌÑ ÏÂÒÁÔÎÏÊ ÓÏ×ÍÅÓÔÉÍÏÓÔÉ ÓÏ ÓÔÁÒÙÍÉ +troff-ÄÏËÕÍÅÎÔÁÍÉ, ÎÏ ÅÇÏ ÉÓÐÏÌØÚÏ×ÁÎÉÅ ËÁË ÕÓÔÁÒÅ×ÛÅÇÏ ÎÅ ÒÅËÏÍÅÎÄÕÅÔÓÑ. +%%This variant is kept for backward +%%compatibility with old (troff) documents, but its use is deprecated. +éÚ ÉÓÔÏÒÉÞÅÓËÉÈ ÓÏÏÂÒÁÖÅÎÉÊ, MetaPost ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ \ttt{prologues} ×~1, +ËÏÇÄÁ ÏÐÃÉÑ {\tt -troff} ÐÒÉ×ÏÄÉÔÓÑ × ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÅ. +%%For historical reasons, MetaPost sets \ttt{prologues} to~1 when the {\tt +%%-troff} option is given on the command line. + +\item ëÏÇÄÁ \ttt{prologues} ÒÁ×ÎÏ 2, ×Ù×ÏÄ MetaPost --- ÜÔÏ EPSF, × ËÏÔÏÒÏÍ +ÐÒÅÄÐÏÌÁÇÁÅÔÓÑ, ÞÔÏ ÔÅËÓÔ ÎÁÂÒÁÎ PostScript\index{PostScript!ÛÒÉÆÔÙ}-ÛÒÉÆÔÁÍÉ, +ÐÒÅÄÏÓÔÁ×ÌÑÅÍÙÍÉ ``ÓÒÅÄÏÊ'', ÔÁËÏÊ ËÁË ÐÒÏÓÍÏÔÒÝÉË ÄÏËÕÍÅÎÔÁ ÉÌÉ ×ÓÔÒÏÅÎÎÏÅ +ÐÒÉÌÏÖÅÎÉÅ, ÉÓÐÏÌØÚÕÀÝÉÅ ÜÔÏÔ ×Ù×ÏÄ. +%%\item When \ttt{prologues} is 2, the MetaPost output is EPSF and assumes +%%that the text comes from PostScript\index{PostScript!fonts} fonts +%%provided by the ``environment'', such as the document viewer or +%%embedded application using the output. +MetaPost ÂÕÄÅÔ ÐÙÔÁÔØÓÑ ÕÓÔÁÎÏ×ÉÔØ ËÏÄÉÒÏ×ËÕ ÛÒÉÆÔÁ ÐÒÁ×ÉÌØÎÏ, ÏÓÎÏ×Ù×ÁÑÓØ +ÎÁ ËÏÍÁÎÄÁÈ \ttt{fontmapfile} É \ttt{fontmapline}. +%%MetaPost will attempt to +%%set up the font encodings correctly, based on \ttt{fontmapfile} and +%%\ttt{fontmapline} commands. + +\item ëÏÇÄÁ \ttt{prologues} ÒÁ×ÎÏ 3, ×Ù×ÏÄ MetaPost ÂÕÄÅÔ EPSF, ÓÏÄÅÒÖÁÝÉÊ +ÛÒÉÆÔÙ PostScript (ÉÌÉ ÐÏÄÍÎÏÖÅÓÔ×Á ÛÒÉÆÔÏ×), ÉÓÐÏÌØÚÕÅÍÙÅ ÎÁ ÏÓÎÏ×Å ËÏÍÁÎÄ +\ttt{fontmapfile} É \ttt{fontmapline}. +%%\item When \ttt{prologues} is 3, the MetaPost output will be EPSF but +%%will contain the PostScript font(s) (or a subset) used based on the +%%\ttt{fontmapfile} and \ttt{fontmapline} commands. +üÔÏ ÚÎÁÞÅÎÉÅ ÐÏÌÅÚÎÏ ÄÌÑ ÇÅÎÅÒÁÃÉÉ ÓÁÍÏÄÏÓÔÁÔÏÞÎÏÊ PostScript-ÇÒÁÆÉËÉ. +%%This value is useful +%%for generating stand-alone PostScript graphics. +\end{itemize} + +óÔÏÉÔ ÏÔÍÅÔÉÔØ, ÞÔÏ ÓÔÁÎÄÁÒÔÎÏÅ ÚÎÁÞÅÎÉÅ \ttt{prologues:=0} ÄÏÓÔÁÔÏÞÎÏ ÄÌÑ +ÇÒÁÆÉËÉ, ×ËÌÀÞÁÅÍÏÊ × ÄÏËÕÍÅÎÔÙ \TeX. +%%It is worth noting that the default value \ttt{prologues:=0} is sufficient +%%for graphics included in \TeX-based documents. +ðÅÒÅÍÅÎÎÁÑ \ttt{prologues} ÔÁËÖÅ ÎÅ ÎÕÖÎÁ ÐÒÉ ÏÂÒÁÂÏÔËÅ MetaPost-ÆÁÊÌÏ× +ÞÅÒÅÚ ÕÔÉÌÉÔÕ \ttindex{mptopdf} (ÉÚ ÄÉÓÔÒÉÂÕÔÉ×Á \ConTeXt), ÐÏÔÏÍÕ ÞÔÏ +PDF-ÆÁÊÌÙ ÅÓÔÅÓÔ×ÅÎÎÏ ÓÁÍÏÄÏÓÔÁÔÏÞÎÙ. +%%Also, the \ttt{prologues} variable is irrelevant +%%when processing MetaPost files through the \ttindex{mptopdf} utility +%%(part of the \ConTeXt\ distribution), because PDF files are, by nature, +%%stand-alone. +âÏÌÅÅ ÔÏÇÏ, ÚÎÁÞÅÎÉÅ \ttt{prologues} ÎÅ ÉÍÅÅÔ ÜÆÆÅËÔÁ ÎÁ ÛÒÉÆÔÙ \MF\ × +×ÁÛÉÈ MetaPost-ÆÁÊÌÁÈ, Ô.~Å. MetaPost ÎÉËÏÇÄÁ ÎÅ ×ÓÔÒÁÉ×ÁÅÔ ÔÁËÉÅ ÛÒÉÆÔÙ +× Ó×ÏÊ ×Ù×ÏÄ. +%%Moreover, the value of \ttt{prologues} has no effect on +%%\MF\ fonts in your MetaPost files, i.\,e., MetaPost never embeds such +%%fonts. +ôÏÌØËÏ ÄÒÁÊ×ÅÒÙ ×Ù×ÏÄÁ, ÎÁÐÒÉÍÅÒ, \ttt{dvips} ÉÌÉ pdf\LaTeX, ÍÏÇÕÔ ×ÓÔÒÏÉÔØ +ÔÁËÉÅ ÛÒÉÆÔÙ. +%%Only output drivers, e.\,g., \ttt{dvips} or pdf\LaTeX\ will +%%handle those. + +äÅÔÁÌÉ ÔÏÇÏ, ËÁË ×ËÌÀÞÁÔØ ÒÉÓÕÎËÉ PostScript × ÄÏËÕÍÅÎÔ, ÓÄÅÌÁÎÎÙÊ × +\TeX\ ÉÌÉ troff, ÓÉÓÔÅÍÏ-ÚÁ×ÉÓÉÍÙ. +%%The details on how to include PostScript figures in a paper +%%done in \TeX\ or troff are system-dependent. +ïÎÉ ÍÏÇÕÔ ÏÂÙÞÎÏ ÂÙÔØ ÎÁÊÄÅÎÙ × ÓÔÒÁÎÉÃÁÈ ÒÕËÏ×ÏÄÓÔ×Á (man pages) ÉÌÉ +× ÄÒÕÇÏÊ ÓÅÔÅ×ÏÊ ÄÏËÕÍÅÎÔÁÃÉÉ, ÎÏ ÐÏÓÍÏÔÒÉÔÅ ÓÎÁÞÁÌÁ +× ÒÁÚÄÅÌ~\ref{Dteximport} ÜÔÏÇÏ ÒÕËÏ×ÏÄÓÔ×Á ÄÌÑ ËÒÁÔËÉÈ ÉÎÓÔÒÕËÃÉÊ, +ËÏÔÏÒÙÅ ×Ï ÍÎÏÇÉÈ ÓÌÕÞÁÑÈ ÏËÁÖÕÔÓÑ ÄÏÓÔÁÔÏÞÎÙÍÉ. +%%They can generally be found +%%in manual pages and other on-line documentation, but have a look at +%%section~\ref{Dteximport} of this manual for some brief instructions that +%%in many cases should work. +òÕËÏ×ÏÄÓÔ×Ï ÄÌÑ ÛÉÒÏËÏ ÉÓÐÏÌØÚÕÅÍÏÊ ÐÒÏÇÒÁÍÍÙ Dvips ÎÁÈÏÄÉÔÓÑ × ÆÁÊÌÅ +\ttt{dvips.texi}, ×ËÌÀÞÅÎÎÏÍ × ÂÏÌØÛÉÎÓÔ×Ï ÓÔÁÎÄÁÒÔÎÙÈ ÄÉÓÔÒÉÂÕÔÉ×Ï× É +ÄÏÓÔÕÐÎÏÍ × ÓÅÔÉ × \url{http://tug.org/texinfohtml/dvips.html} É × ÄÒÕÇÉÈ +ÍÅÓÔÁÈ, Á ÔÁËÖÅ × ÄÒÕÇÉÈ ÆÏÒÍÁÔÁÈ. +%%The manual for the +%%widely-used Dvips processor is in a file \ttt{dvips.texi}, included in +%%most distributions, and is available online at +%%\url{http://tug.org/texinfohtml/dvips.html}, among many other places and +%%formats. + +\label{Dmakempx} +÷ ÓÉÓÔÅÍÁÈ, ÏÓÎÏ×ÁÎÎÙÈ ÎÁ Web2C, ÐÒÅÐÒÏÃÅÓÓÏÒ ÎÁÚÙ×ÁÅÔÓÑ +\ttindex{makempx} --- ÏÎ ×ÙÚÙ×ÁÅÔ ÐÒÏÇÒÁÍÍÕ \ttindex{mpto}; +ÄÏËÕÍÅÎÔÁÃÉÑ ÐÏ Web2C ÏÐÉÓÙ×ÁÅÔ ÉÈ ÂÏÌÅÅ ÐÏÄÒÏÂÎÏ. +%%On Web2C-based systems, the preprocessor is named \ttindex{makempx}, +%%which calls another utility \ttindex{mpto}; the Web2C documentation +%%describes them in more detail. +ïÄÎÁËÏ, ÕÐÏÍÑÎÅÍ ÚÄÅÓØ ÏÄÎÏ Ó×ÏÊÓÔ×Ï: +ÅÓÌÉ ÐÅÒÅÍÅÎÎÁÑ ÓÒÅÄÙ \ttindex{MPTEXPRE} ÓÏÄÅÒÖÉÔ ÉÍÑ ÓÕÝÅÓÔ×ÕÀÝÅÇÏ +ÆÁÊÌÁ, ÔÏ {\tt makempx} ÂÕÄÅÔ ÐÏÍÅÝÁÔØ ÅÇÏ × ÎÁÞÁÌÏ ÐÒÉ ×Ù×ÏÄÅ. +%%We'll mention one feature here, though: +%%if the environment variable \ttindex{MPTEXPRE} is set to the name of an +%%existing file, {\tt makempx} will prepend it to the output. +÷Ù ÍÏÖÅÔÅ ÜÔÏ ÉÓÐÏÌØÚÏ×ÁÔØ, ÎÁÐÒÉÍÅÒ, ÄÌÑ ×ËÌÀÞÅÎÉÑ ÐÒÅÁÍÂÕÌ \LaTeX. +%%You can use +%%this to include \LaTeX\ preambles, for instance. +íÁËÒÏÓ \ttt{TEX}, ÏÐÉÓÁÎÎÙÊ ÎÁ ÓÔÒ.~\pageref{dTEX}, ÏÂÅÓÐÅÞÉ×ÁÅÔ ÄÒÕÇÏÊ +ÓÐÏÓÏ ÔÁËÏÇÏ ×ËÌÀÞÅÎÉÑ. +%%The \ttt{TEX} +%%macro described on p.\ \pageref{dTEX} provides another way to handle this. + +\subsection{æÁÊÌÙ-ËÁÒÔÙ ÛÒÉÆÔÏ×} +%%\subsection{Font map files} +\label{Sfontmapfile}\label{Sfontmapline} + +åÓÌÉ \ttt{prologues} ÕÓÔÁÎÏ×ÌÅÎÏ ×~2, ÔÏ ÌÀÂÙÅ ÉÓÐÏÌØÚÕÅÍÙÅ × ×Ù×ÏÄÅ +ÛÒÉÆÔÙ Á×ÔÏÍÁÔÉÞÅÓËÉ ÐÅÒÅËÏÄÉÒÕÀÔÓÑ ÓÏÇÌÁÓÎÏ ÔÁÂÌÉÃÅ, ÕËÁÚÁÎÎÏÊ × +ÏÔÄÅÌØÎÏÊ ÚÁÐÉÓÉ ÛÒÉÆÔÏ×ÏÇÏ ÆÁÊÌÁ-ËÁÒÔÙ É ×ËÌÀÞÁÅÍÏÊ × ÆÁÊÌ ×Ù×ÏÄÁ. +%%If \ttt{prologues} is set to~2, any used fonts in the output file are +%%automatically re-encoded, and the encoding vector file specified in +%%the fontmap entry will be embedded in the output file. +åÓÌÉ \ttt{prologues} ÕÓÔÁÎÏ×ÌÅÎÏ ×~3, ÔÏ MetaPost ÂÕÄÅÔ ÔÁËÖÅ ÐÙÔÁÔØÓÑ +×ËÌÀÞÉÔØ ÉÓÐÏÌØÚÕÅÍÙÅ PostScript\index{PostScript!ÛÒÉÆÔÙ} ÛÒÉÆÔÙ ÉÌÉ ÉÈ +ÐÏÄÍÎÏÖÅÓÔ×Á. +%%If \ttt{prologues} is set to~3, MetaPost will also attempt to include +%%(a subset of) the used PostScript\index{PostScript!fonts} fonts. +þÔÏÂÙ ÜÔÏ ÒÁÂÏÔÁÌÏ, ÎÕÖÎÏ ÐÏÌÕÞÅÎÉÅ ÉÎÆÏÒÍÁÃÉÉ ÉÚ ÛÒÉÆÔÏ×ÏÇÏ +ÆÁÊÌÁ-ËÁÒÔÙ. +%For this to work, it needs to acquire font map information. + +ëÏÄ, ÏÓÎÏ×ÁÎÎÙÊ ÎÁ ÛÒÉÆÔÏ×ÏÊ ÂÉÂÌÉÏÔÅËÅ, ÉÓÐÏÌØÚÕÅÔÓÑ pdf\TeX. +%%The code is based on the font library used by pdf\TeX. +óÌÅÄÕÑ ÚÁ pdf\TeX, ÏÂÎÁÒÕÖÉ×ÁÅÍ Ä×Á ÎÏ×ÙÈ Ó×ÑÚÁÎÎÙÈ Ó ÔÅÍÏÊ ÐÒÉÍÉÔÉ×Á: +\ttindex{fontmapfile} É \ttindex{fontmapline}. +%%Following in +%%the footsteps of pdf\TeX, there are two new associated primitives: +%%\ttindex{fontmapfile} and \ttindex{fontmapline}. +äÁÌÅÅ ÓÌÅÄÕÅÔ ÐÒÏÓÔÏÊ ÐÒÉÍÅÒ, ÕËÁÚÙ×ÁÀÝÉÊ ÆÁÊÌ-ËÁÒÔÕ ÄÌÑ ÛÒÉÆÔÏ× +Latin Modern × ËÏÄÉÒÏ×ËÅ YandY (\LaTeX\ LY1): +%%Here is a simple +%%example, specifying the map file for Latin Modern fonts in YandY +%%(\LaTeX\ LY1) encoding: +\begin{center}\begin{tabular}{l} +\verb|prologues:=2;|\\ +\verb|fontmapfile "texnansi-lm.map";|\\ +\verb|beginfig(1);|\\ +\verb| draw "Hell|{\tt\'o, vil\'a}\verb|g" infont "texnansi-lmr10";|\\ +%%\verb| draw "Helló, világ" infont "texnansi-lmr10";|\\ +\verb|endfig;| +\end{tabular}\end{center} + +éÓÐÏÌØÚÕÑ \ttt{fontmapline}, ÍÏÖÎÏ ÕËÁÚÁÔØ ÉÎÆÏÒÍÁÃÉÀ Ï ÛÒÉÆÔÅ +×ÎÕÔÒÉ ÒÉÓÕÎËÁ: +%%Using \ttt{fontmapline}, you can specify font mapping information +%%inside the figure: +\begin{center}\begin{tabular}{l} +\verb|prologues:=2;|\\ +\verb|fontmapline "pplbo8r URWPalladioL-Bold "&ditto&|\\ +\verb| ".167 SlantFont"&ditto&" <8r.enc <uplb8a.pfb";|\\ +\verb|beginfig(1);|\\ +\verb| draw "Hello, world" infont "pplbo8r";|\\ +\verb|endfig;| +\end{tabular}\end{center} +üÔÏ ÂÕÄÅÔ ÐÏÐÙÔËÁ ÐÅÒÅËÏÄÉÒÏ×ÁÔØ PostScript-ÛÒÉÆÔ +URWPalladioL-Bold\index{URWPalladioL-Bold}\index{Palatino}, +ÞÅÊ tfm-ÆÁÊÌ --- ÜÔÏ pplbo8r.tfm. +%%This will attempt to reencode the PostScript font +%%URWPalladioL-Bold\index{URWPalladioL-Bold}\index{Palatino} +%%whose tfm file is pplbo8r.tfm. +ëÏÄÉÒÏ×ËÁ ÏÐÒÅÄÅÌÑÅÔÓÑ × ÆÁÊÌÅ 8r.enc É ÂÕÄÅÔ ×ËÌÀÞÁÔÓÑ × ÆÁÊÌ ×Ù×ÏÄÁ. +%%The encoding is found in the file +%%8r.enc, and will be included into the output file. + +åÓÌÉ ÜÔÏÔ ÖÅ ÐÒÉÍÅÒ ÚÁÐÕÓËÁÔØ Ó \ttt{prologues:=3}, ÔÏ MetaPost ÂÕÄÅÔ +×ËÌÀÞÁÔØ ÐÏÄÍÎÏÖÅÓÔ×Ï ÛÒÉÆÔÁ, ÞÔÏ ÒÁÓÐÏÌÏÖÅÎÏ × uplb8a.pfb, × ×Ù×ÏÄ. +%%If the same example was run with \ttt{prologues:=3}, MetaPost would +%%include a subset of the font that resides in uplb8a.pfb into the +%%output. +÷ ÜÔÏÍ ÓÌÕÞÁÅ ÐÏÄÍÎÏÖÅÓÔ×Ï ÛÒÉÆÔÁ ÐÅÒÅÓÔÒÁÉ×ÁÅÔÓÑ ÔÁË, ÞÔÏ ÏÎÏ ÂÕÄÅÔ +×ÅÒÎÏ ÚÁËÏÄÉÒÏ×ÁÎÏ ÎÁ ×ÎÕÔÒÅÎÎÅÍ ÕÒÏ×ÎÅ, ÐÏÜÔÏÍÕ 8r.enc ÎÅ ÂÕÄÅÔ +×ËÌÀÞÁÔØÓÑ. +%%In this case, the subset of the font is reorganized so that it +%%has the correct encoding internally, 8r.enc will not be embedded also. + +áÒÇÕÍÅÎÔ Ë ÏÂÅÉÍ ËÏÍÁÎÄÁÍ ÉÍÅÅÔ ÓÉÍ×ÏÌ ÏÐÃÉÏÎÁÌØÎÏÇÏ ÆÌÁÇÁ × ÓÁÍÏÍ +ÎÁÞÁÌÅ. +%%The argument to both commands has an optional flag character at the very +%%beginning. +üÔÏÔ ÏÐÃÉÏÎÁÌØÎÙÊ ÆÌÁÇ ÉÍÅÅÔ ÔÏ ÖÅ ÓÁÍÏÅ ÚÎÁÞÅÎÉÅ ËÁË É × pdf\TeX: +%%This optional flag has the same meaning as in pdf\TeX: +$$\begin{tabular}{|c|l|} \hline +\multicolumn1{|c|}{ïÐÃÉÑ}& \multicolumn1{c|}{úÎÁÞÅÎÉÅ}\\ \hline +%%\multicolumn1{|c|}{Option}& \multicolumn1{c|}{Meaning}\\ \hline + + & ÒÁÓÛÉÒÉÔØ ÓÐÉÓÏË ÛÒÉÆÔÁ, ÉÇÎÏÒÉÒÕÑ ÐÏ×ÔÏÒÅÎÉÑ \\ +%% + & extend the font list, but ignore duplicates \\ + = & ÒÁÓÛÉÒÉÔØ ÓÐÉÓÏË ÛÒÉÆÔÁ, ÚÁÍÅÝÁÑ ÐÏ×ÔÏÒÅÎÉÑ \\ +%% = & extend the font list, replacing duplicates \\ + $-$ & ÕÄÁÌÉÔØ ×ÓÅ ÐÏÄÈÏÄÑÝÉÅ ÛÒÉÆÔÙ ÉÚ ÓÐÉÓËÁ ÛÒÉÆÔÁ \\ +%% $-$ & remove all matching fonts from the font list \\ +\hline +\end{tabular} +$$ +âÅÚ ÏÐÃÉÊ ÔÅËÕÝÉÊ ÓÐÉÓÏË ÂÕÄÅÔ ÐÏÌÎÏÓÔØÀ ÚÁÍÅÝÅÎ. +%%Without any option, the current list will be completely replaced. + +åÓÌÉ \ttt{prologues} ÕÓÔÁÎÏ×ÌÅÎ × Ä×Á ÉÌÉ ÔÒÉ É ËÏÍÁÎÄÙ +\ttt{fontmapfile} ÏÔÓÕÔÓÔ×ÕÀÔ, ÔÏ MetaPost ÂÕÄÅÔ ÐÙÔÁÔØÓÑ +ÎÁÊÔÉ ÔÉÐÏ×ÏÊ ÆÁÊÌ-ËÁÒÔÕ, ÎÁÞÉÎÁÑ Ó {\tt mpost.map}. +%%If \ttt{prologues} is set to two or three, yet there are no +%%\ttt{fontmapfile} statements, MetaPost will attempt to locate a +%%default map file, with a preference to read {\tt mpost.map}. +åÓÌÉ ÜÔÏ ÎÅ ÐÒÉ×ÅÄÅÔ Ë ÕÓÐÅÈÕ, ÔÏ ÏÎ ÂÕÄÅÔ ÔÁËÖÅ ÐÒÏÂÏ×ÁÔØ {\tt troff.map} +ÉÌÉ {\tt pdftex.map}, × ÚÁ×ÉÓÉÍÏÓÔÉ ÏÔ ÐÒÉÓÕÔÓÔ×ÉÑ ÕÓÔÁÎÏ×ËÉ ÒÅÖÉÍÁ troff. +%%If that +%%fails, it will also attempt either {\tt troff.map} or {\tt +%%pdftex.map}, depending on whether or not troff mode is enabled. +åÓÌÉ \ttt{prologues} ÕÓÔÁÎÏ×ÌÅÎÏ ×~1, ÔÏ MetaPost ÐÙÔÁÅÔÓÑ ÞÉÔÁÔØ ÆÁÊÌ Ó ÉÍÅÎÅÍ +{\tt psfonts.map}, ÉÇÎÏÒÉÒÕÑ ÌÀÂÕÀ ËÏÍÁÎÄÕ {\tt fontmapfile}. +%%If +%%\ttt{prologues} is set to~1, MetaPost attempts to read a file called +%%{\tt psfonts.map}, regardless of any {\tt fontmapfile} +%%statement. +ðÏ×ÔÏÒÉÍ, ÜÔÏ ÔÏÌØËÏ ÄÌÑ ÏÂÒÁÔÎÏÊ ÓÏ×ÍÅÓÔÉÍÏÓÔÉ. +%%Again, this is for backward compatibility only. + +\subsection{ïÐÅÒÁÔÏÒ \texttt{infont}} +%%\subsection{The \texttt{infont} operator} +\label{Sinfont} + +ëÁË Ó \TeX, ÔÁË É Ó troff ×ÓÀ ÒÅÁÌØÎÕÀ ÒÁÂÏÔÕ ÐÏ ÄÏÂÁ×ÌÅÎÉÀ ÔÅËÓÔÁ Ë +ËÁÒÔÉÎËÅ ÄÅÌÁÅÔ ÐÒÉÍÉÔÉ×ÎÙÊ ÏÐÅÒÁÔÏÒ MetaPost Ó ÉÍÅÎÅÍ +{\tt infont}\index{infont?\texttt{infont}}. +%%Regardless of whether you use \TeX\ or troff, all the real work of +%%adding text to pictures is done by a MetaPost primitive operator called +%%{\tt infont}\index{infont?\texttt{infont}}. +ïÎ --- \tdescr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ +ÏÐÅÒÁÔÏÒ}\index{ÐÅÒ×ÉÞÎÙÊ binop?\tdescr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ +ÏÐÅÒÁÔÏÒ}}, ÂÅÒÕÝÉÊ ÌÅ×ÙÍ ÁÒÇÕÍÅÎÔÏÍ \tdescr{ÓÔÒÏËÏ×ÕÀ ×ÔÏÒÉÞÎÏÓÔØ} +É ÐÒÁ×ÙÍ --- \tdescr{ÓÔÒÏËÏ×ÕÀ ÐÅÒ×ÉÞÎÏÓÔØ}. +%%It is a \tdescr{primary +%%binop}\index{primary binop?\tdescr{primary binop}} that takes a +%%\tdescr{string secondary} as its left argument and a \tdescr{string +%%primary} as its right argument. +ìÅ×ÙÊ ÁÒÇÕÍÅÎÔ --- ÜÔÏ ÔÅËÓÔ, Á ÐÒÁ×ÙÊ --- ÉÍÑ ÛÒÉÆÔÁ. +%%The left argument is text, and the right argument is a font name. +òÅÚÕÌØÔÁÔ ÏÐÅÒÁÃÉÉ --- ÜÔÏ \tdescr{ÒÉÓÕÎÏË-×ÔÏÒÉÞÎÏÓÔØ}, ËÏÔÏÒÙÊ ÍÏÖÎÏ +ÔÒÁÎÓÆÏÒÍÉÒÏ×ÁÔØ ÍÎÏÇÉÍÉ ÓÐÏÓÏÂÁÍÉ. +%%The result of the operation is a +%%\tdescr{picture secondary} that can then be transformed in various ways. +ïÄÎÁ ÉÚ ×ÏÚÍÏÖÎÏÓÔÅÊ --- ÜÔÏ Õ×ÅÌÉÞÅÎÉÅ × ÚÁÄÁÎÎÏÅ ÞÉÓÌÏ ÒÁÚ +ÞÅÒÅÚ ÓÉÎÔÁËÓÉÓ\index{scaled?\texttt{scaled}} +$$ \descr{ÒÉÓÕÎÏË-×ÔÏÒÉÞÎÏÓÔØ}\, \hbox{\tt scaled}\, \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ} $$ +%%One possibility is enlargement by a given factor via the +%%syntax\index{scaled?\texttt{scaled}} +%%$$ \descr{picture secondary}\, \hbox{\tt scaled}\, \descr{numeric primary} $$ +ôÁËÉÍ ÏÂÒÁÚÏÍ, {\tt label(\qq text\qq,z0)} ÜË×É×ÁÌÅÎÔÎÏ +$$ \hbox{\tt label({\qq}ÔÅËÓÔ{\qq} infont defaultfont scaled defaultscale, z0)} $$ +%%Thus {\tt label("text",z0)} is equivalent to +%%$$ \hbox{\tt label("text" infont defaultfont scaled defaultscale, z0)} $$ + +åÓÌÉ ÉÓÐÏÌØÚÏ×ÁÔØ ÓÔÒÏËÏ×ÕÀ ËÏÎÓÔÁÎÔÕ ÄÌÑ ÌÅ×ÏÇÏ ÁÒÇÕÍÅÎÔÁ {\tt infont} ÏËÁÖÅÔÓÑ +ÎÅÕÄÏÂÎÙÍ, ÔÏ ÍÏÖÎÏ ÉÓÐÏÌØÚÏ×ÁÔØ\index{char?\texttt{char}}\label{Dchar} +$$ {\tt char}\, \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ} $$ +ÄÌÑ ×ÙÂÏÒÁ ÓÉÍ×ÏÌÁ ÐÏ ÅÇÏ ÞÉÓÌÏ×ÏÊ ÐÏÚÉÃÉÉ × ÛÒÉÆÔÅ. +%%If it is not convenient to use a string constant for the left argument of +%%{\tt infont}, you can use\index{char?\texttt{char}}\label{Dchar} +%%$$ {\tt char}\, \descr{numeric primary} $$ +%%to select a character based on its numeric position in the font. +ôÁËÉÍ ÏÂÒÁÚÏÍ, +$$ \hbox{\tt char(n+64) infont \qq{ptmr8r}\qq} $$ +--- ÜÔÏ ËÁÒÔÉÎËÁ, ÓÏÄÅÒÖÁÝÁÑ ÓÉÍ×ÏÌ {\tt n+64} ÛÒÉÆÔÁ \ttt{ptmr8r}, +ËÏÔÏÒÙÊ ÏÂÙÞÎÏ ÉÓÐÏÌØÚÕÅÔÓÑ \TeX\ ÄÌÑ ÓÓÙÌËÉ ÎÁ Times-Roman. +%%Thus +%%$$ \hbox{\tt char(n+64) infont \qq{ptmr8r}\qq} $$ +%%is a picture containing character {\tt n+64} of the font \ttt{ptmr8r}, +%%which is a typical \TeX\ way to refer to Times-Roman. +óÍ. ÓÔÒ.\ \pageref{fontname} ÄÌÑ ÄÁÌØÎÅÊÛÅÇÏ ÏÂÓÕÖÄÅÎÉÑ. +%%See p.\ \pageref{fontname} for further discussion. + +óÁÍ MetaPost ÎÅ ÐÅÒÅËÏÄÉÒÕÅÔ Ó×ÏÊ ××ÏÄ, Ô.~Å. ËÏÇÄÁ ×Ù +ÉÓÐÏÌØÚÕÅÔÅ ÓÔÒÏËÕ {\tt infont} ÄÌÑ ÍÅÔÏË (×ÍÅÓÔÏ {\tt btex} \ldots\ +{\tt etex}), ÓÔÒÏËÁ ÄÏÌÖÎÁ ÂÙÔØ ÚÁÄÁÎÁ × ËÏÄÉÒÏ×ËÅ ÛÒÉÆÔÁ. +%%Bare MetaPost does not do any kind of input reencoding, so when +%%you use {\tt infont} string for labels (instead of {\tt btex} \ldots\ +%%{\tt etex}), the string has to be specified in the font encoding. + +\subsection{éÚÍÅÒÅÎÉÅ ÔÅËÓÔÁ} +%%\subsection{Measuring Text} +\label{meas} + +MetaPost ÄÅÌÁÅÔ ÄÏÓÔÕÐÎÙÍÉ ÆÉÚÉÞÅÓËÉÅ ÒÁÚÍÅÒÙ \index{ÒÁÚÍÅÒ} +ËÁÒÔÉÎÏË, ÇÅÎÅÒÉÒÕÅÍÙÈ ÏÐÅÒÁÔÏÒÏÍ {\tt infont}. +%%MetaPost makes readily available the physical dimensions\index{size} of +%%pictures generated by the {\tt infont} operator. +õÎÁÒÎÙÅ ÏÐÅÒÁÔÏÒÙ {\tt +llcorner}\index{llcorner?\texttt{llcorner}}\label{Dcornop}, {\tt +lrcorner}\index{lrcorner?\texttt{lrcorner}}, {\tt +urcorner}\index{urcorner?\texttt{urcorner}}, {\tt +ulcorner}\index{ulcorner?\texttt{ulcorner}} É {\tt +center}\index{center?\texttt{center}}\label{Dcenter} Ó ÁÒÇÕÍÅÎÔÏÍ +\tdescr{ÒÉÓÕÎÏË-ÐÅÒ×ÉÞÎÏÓÔØ} ×ÏÚ×ÒÁÝÁÀÔ ÕÇÌÙ Ó×ÏÅÊ ``ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÉ'', +ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{bbox}. +%%There are unary +%%operators {\tt +%%llcorner}\index{llcorner?\texttt{llcorner}}\label{Dcornop}, {\tt +%%lrcorner}\index{lrcorner?\texttt{lrcorner}}, {\tt +%%urcorner}\index{urcorner?\texttt{urcorner}}, {\tt +%%ulcorner}\index{ulcorner?\texttt{ulcorner}}, and {\tt +%%center}\index{center}\label{Dcenter} that take a \tdescr{picture +%%primary} and return the corners of its ``bounding box'' as illustrated +%%in Figure~\ref{bbox}. +ïÐÅÒÁÔÏÒ {\tt center} ÔÁËÖÅ ÄÏÐÕÓËÁÅÔ ÏÐÅÒÁÎÄÙ +\tdescr{ÐÕÔØ-ÐÅÒ×ÉÞÎÏÓÔØ} É \tdescr{ÐÅÒÏ-ÐÅÒ×ÉÞÎÏÓÔØ}. +%%The {\tt center} operator also accepts +%%\tdescr{path primary} and \tdescr{pen primary} operands. +MetaPost ×ÅÒÓÉÉ 0.30 É ÎÏ×ÅÅ ÄÏÐÕÓËÁÅÔ ÄÌÑ {\tt llcorner}, {\tt lrcorner}, $\ldots$ +×ÓÅ ÔÒÉ ÔÉÐÁ ÁÒÇÕÍÅÎÔÏ×. +%%In MetaPost +%%Version 0.30 and higher, {\tt llcorner}, {\tt lrcorner}, etc. accept +%%all three argument types as well. + +ïÇÒÁÎÉÞÅÎÉÑ ÎÁ ÔÉÐ ÁÒÇÕÍÅÎÔÁ ÄÌÑ corner-ÏÐÅÒÁÔÏÒÏ× ÎÅ ÏÞÅÎØ ×ÁÖÎÙ, +ÐÏÔÏÍÕ ÞÔÏ ÉÈ ÇÌÁ×ÎÏÅ ÎÁÚÎÁÞÅÎÉÅ ÐÏÚ×ÏÌÉÔØ ËÏÍÁÎÄÁÍ {\tt label} É {\tt +dotlabel} ÃÅÎÔÒÉÒÏ×ÁÔØ Ó×ÏÊ ÔÅËÓÔ ÐÒÁ×ÉÌØÎÏ. +%%The argument type restrictions on the corner operators are not very +%%important because their main purpose is to allow {\tt label} and {\tt +%%dotlabel} statements to center their text properly. +úÁÒÁÎÅÅ ÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ\index{bbox?\texttt{bbox}}\label{Dbbox} +$$ {\tt bbox}\, \descr{ÒÉÓÕÎÏË-ÐÅÒ×ÉÞÎÏÓÔØ} $$ +ÎÁÈÏÄÉÔ ÐÒÑÍÏÕÇÏÌØÎÙÊ ÐÕÔØ, ÐÒÅÄÓÔÁ×ÌÑÀÝÉÊ ÏÈ×ÁÔÙ×ÁÀÝÕÀ ÒÁÍËÕ ÄÌÑ ÄÁÎÎÏÇÏ +ÒÉÓÕÎËÁ. +%%The predefined +%%macro\index{bbox?\texttt{bbox}}\label{Dbbox} +%%$$ {\tt bbox}\, \descr{picture primary} $$ +%%finds a rectangular path that represents the bounding box of a given picture. +åÓÌÉ {\tt p} --- ÜÔÏ ËÁÒÔÉÎËÁ, ÔÏ {\tt bbox p} ÜË×É×ÁÌÅÎÔÎÏ +$$\begin{verbatim} +(llcorner p-{}-lrcorner p-{}-urcorner p-{}-ulcorner p-{}-cycle), +\end{verbatim} +$$ +ÚÁ ÉÓËÌÀÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ ÐÅÒ×ÏÅ ÄÏÐÕÓËÁÅÔ ÎÅÂÏÌØÛÏÊ ÐÒÏÍÅÖÕÔÏË ×ÏËÒÕÇ {\tt p} +ËÁË ÕËÁÚÁÎÏ ×ÎÕÔÒÅÎÎÅÊ ÐÅÒÅÍÅÎÎÏÊ \index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} {\tt +bboxmargin}\index{bboxmargin?\texttt{bboxmargin}}\label{Dbbmargin}. +%%If {\tt p} is a picture, {\tt bbox p} is equivalent to +%%$$\begin{verbatim} +%%(llcorner p--lrcorner p--urcorner p--ulcorner p--cycle)} +%%\end{verbatim} +%%$$ +%%except that it allows for a small amount of extra space around {\tt p} +%%as specified by the internal variable\index{internal +%%variables}\index{variables!internal} {\tt +%%bboxmargin}\index{bboxmargin?\texttt{bboxmargin}}\label{Dbbmargin}. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-20} $$ +\caption{ïÈ×ÁÔÙ×ÁÀÝÁÑ ÒÁÍËÁ É ÅÅ ÕÇÌÏ×ÙÅ ÔÏÞËÉ.} +%%\caption{A bounding box and its corner points.} +\label{bbox} +\end{figure} + +úÁÍÅÔØÔÅ, ÞÔÏ MetaPost ×ÙÞÉÓÌÑÅÔ ÏÈ×ÁÔÙ×ÁÀÝÕÀ ÒÁÍËÕ ÒÉÓÕÎËÁ {\tt +btex}\index{btex?\texttt{btex}} \ldots\ {\tt +etex}\index{etex?\texttt{etex}} ÔÅÍ ÖÅ ÓÐÏÓÏÂÏÍ, ÞÔÏ É \TeX\index{TeX?\TeX}. +%%Note that MetaPost computes the bounding box of a {\tt +%%btex}\index{btex?\texttt{btex}} \ldots\ {\tt +%%etex}\index{etex?\texttt{etex}} picture just the way +%%\TeX\index{TeX?\TeX} does. +üÔÏ ×ÐÏÌÎÅ ÅÓÔÅÓÔ×ÅÎÎÏ, ÎÏ ×Ï×ÌÅËÁÅÔ × ÒÁÓÓÍÏÔÒÅÎÉÅ ÆÁËÔÁ ÔÏÇÏ, ÞÔÏ +\TeX\ ÉÍÅÅÔ Ó×ÏÊÓÔ×Á ÔÉÐÁ {\tt\string\strut}\index{strut?{\tt\string\strut}} É +{\tt\string\rlap}\index{rlap?{\tt\string\rlap}}, ÞÔÏ ÐÏÚ×ÏÌÑÀÔ ÐÏÌØÚÏ×ÁÔÅÌÑÍ \TeX\ +ÌÇÁÔØ Ï ÒÁÚÍÅÒÁÈ ÒÁÍËÉ. +%%This is quite natural, but it has certain +%%implications in view of the fact that \TeX\ has features like +%%{\tt\string\strut}\index{strut?{\tt\string\strut}} and +%%{\tt\string\rlap}\index{rlap?{\tt\string\rlap}} that allow \TeX\ users +%%to lie about the dimensions of a box. + +ëÏÇÄÁ ËÏÍÁÎÄÙ \TeX, ÌÇÕÝÉÅ Ï ÒÁÚÍÅÒÁÈ ÒÁÍËÉ, ÔÒÁÎÓÌÉÒÕÀÔÓÑ × ÎÉÚËÏÕÒÏ×ÎÅ×ÙÊ +ËÏÄ Meta\-Post, ËÏÍÁÎÄÁ {\tt +setbounds}\index{setbounds?\texttt{setbounds}}\label{Dsetbnd} +ÌÖÅÔ:\index{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ?\tdescr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ}} +$$ {\tt setbounds}\, \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ}\, {\tt to}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} +$$ +ÄÅÌÁÅÔ \tdescr{ÐÅÒÅÍÅÎÎÕÀ-ËÁÒÔÉÎËÕ} ÔÁËÏÊ, ËÁË ÅÓÌÉ ÂÙ ÅÅ ÏÈ×ÁÔÙ×ÁÀÝÁÑ +ÒÁÍËÁ ÂÙÌÁ ÔÁËÏÊ ÖÅ ËÁË ÚÁÄÁÎÎÙÊ ÐÕÔØ. +%%When \TeX\ commands that lie about the dimensions of a box are +%%translated in to low-level MetaPost code, a {\tt +%%setbounds}\index{setbounds?\texttt{setbounds}}\label{Dsetbnd} statement +%%does the lying:\index{picture variable?\tdescr{picture variable}} +%%$$ {\tt setbounds}\, \descr{picture variable}\, {\tt to}\, \descr{path expression} +%%$$ +%%makes the \tdescr{picture variable} behave as if its bounding box were +%%the same as the given path. +üÔÏÔ ÐÕÔØ ÄÏÌÖÅÎ ÂÙÔØ ÃÉËÌÉÞÅÓËÉÍ, Ô.~Å. ÚÁÍËÎÕÔÙÍ. +%%The path has to be a cycle, i.e., it must +%%be a closed path. +äÌÑ ÐÏÌÕÞÅÎÉÑ ÎÁÓÔÏÑÝÅÊ ÏÈ×ÁÔÙ×ÁÀÝÅÊ ÒÁÍËÉ ÔÁËÏÊ ËÁÒÔÉÎËÉ ÐÒÉÓ×ÏÊÔÅ +ÐÏÌÏÖÉÔÅÌØÎÏÅ ÚÎÁÞÅÎÉÅ ×ÎÕÔÒÅÎÎÅÊ ÐÅÒÅÍÅÎÎÏÊ\index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} {\tt +truecorners}\index{truecorners?\texttt{truecorners}}\label{Dtruecorn}:\footnote{ó×ÏÊÓÔ×Á +{\tt setbounds} É {\tt truecorners} ÐÒÉÓÕÔÓÔ×ÕÀÔ ÔÏÌØËÏ × MetaPost ×ÅÒÓÉÉ 0.30 +É ÎÏ×ÅÅ.}, Ô.~Å. +$$ \hbox{\verb|show urcorner btex $\bullet$\rlap{ A} etex|} $$ +ÐÒÏÉÚ×ÏÄÉÔ ``\verb|>> (4.9813,6.8078)|'', Á +$$ \hbox{\verb|truecorners:=1; show urcorner btex $\bullet$\rlap{ A} etex|} $$ +ÐÒÏÉÚ×ÏÄÉÔ ``\verb|>> (15.7742,6.8078)|''. +%%To get the true bounding box of such a +%%picture, assign a positive value to the internal variable\index{internal +%%variables}\index{variables!internal} {\tt +%%truecorners}\index{truecorners?\texttt{truecorners}}\label{Dtruecorn}:\footnote{The +%%{\tt setbounds} and {\tt truecorners} features are only found in +%%MetaPost version 0.30 and higher.} i.e., +%%$$ \hbox{\verb|show urcorner btex $\bullet$\rlap{ A} etex|} $$ +%%produces ``\verb|>> (4.9813,6.8078)|'' while +%%$$ \hbox{\verb|truecorners:=1; show urcorner btex $\bullet$\rlap{ A} etex|} $$ +%%produces ``\verb|>> (15.7742,6.8078)|.'' + +\section{ðÒÏÄ×ÉÎÕÔÁÑ ÇÒÁÆÉËÁ} +%%\section{Advanced Graphics} +\label{adv.gr} + +÷ÓÅ ÐÒÉÍÅÒÙ ÐÒÅÄÙÄÕÝÉÈ ÒÁÚÄÅÌÏ× ÂÙÌÉ ÐÒÏÓÔÙÍ ÒÉÓÏ×ÁÎÉÅÍ ÌÉÎÉÊ Ó ÄÏÂÁ×ÌÅÎÉÅÍ +ÍÅÔÏË. +%%All the examples in the previous sections have been simple line drawings +%%with labels added. +üÔÏÔ ÒÁÚÄÅÌ ÏÐÉÓÙ×ÁÅÔ ÚÁÔÅÎÅÎÉÅ É ÓÒÅÄÓÔ×Á ÄÌÑ ÇÅÎÅÒÁÃÉÉ ÎÅ ÓÔÏÌØ ÐÒÏÓÔÙÈ +ÌÉÎÉÊ. +%%This section describes shading and tools for +%%generating not-so-simple line drawings. +úÁÔÅÎÅÎÉÅ ÄÅÌÁÅÔÓÑ ËÏÍÁÎÄÏÊ {\tt fill}\index{fill?\texttt{fill}}\label{Dfill}. +%%Shading is done with the {\tt +%%fill}\index{fill?\texttt{fill}}\label{Dfill} statement. +÷ Ó×ÏÅÊ ÐÒÏÓÔÅÊÛÅÊ ÆÏÒÍÅ ËÏÍÁÎÄÁ {\tt fill} ÔÒÅÂÕÅÔ \tdescr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}, +ÚÁÄÁÀÝÅÅ ÇÒÁÎÉÃÕ ÒÅÇÉÏÎÁ ÄÌÑ ÚÁÐÏÌÎÅÎÉÑ. +%%In its simplest +%%form, the {\tt fill} statement requires a \tdescr{path expression} that +%%gives the boundary of the region to be filled. +÷ ÓÉÎÔÁËÓÉÓÅ +$$ {\tt fill}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} $$ +ÁÒÇÕÍÅÎÔ ÄÏÌÖÅÎ ÂÙÔØ ÃÉËÌÉÞÅÓËÉÍ ÐÕÔÅÍ, Ô.~Å. ÐÕÔÅÍ, ËÏÔÏÒÙÊ ÏÐÉÓÙ×ÁÅÔÓÑ +ÚÁÍËÎÕÔÏÊ ËÒÉ×ÏÊ ÞÅÒÅÚ {\tt ..cycle} ÉÌÉ {\tt -{}-cycle}. +%%In the syntax +%%$$ {\tt fill}\, \descr{path expression} $$ +%%the argument should be a cyclic path, i.e., a path that describes a +%%closed curve via the {\tt ..cycle} or {\tt --cycle} notation. +îÁÐÒÉÍÅÒ, ËÏÍÁÎÄÁ {\tt fill} ÎÁ ÒÉÓ.~\ref{fig20} ÓÔÒÏÉÔ ÚÁÍËÎÕÔÙÊ +ÐÕÔØ ÐÒÏÄÏÌÖÅÎÉÅÍ ÐÒÉÂÌÉÚÉÔÅÌØÎÏ ÐÏÌÕËÒÕÇÏ×ÏÇÏ ÐÕÔÉ~{\tt p}. +%%For +%%example, the {\tt fill} statement in Figure~\ref{fig20} builds a closed +%%path by extending the roughly semicircular path~{\tt p}. +üÔÏÔ ÐÕÔØ ÉÍÅÅÔ ÏÒÉÅÎÔÁÃÉÀ ÐÒÏÔÉ× ÞÁÓÏ×ÏÊ ÓÔÒÅÌËÉ, ÎÏ ÜÔÏ ÎÅ ÉÍÅÅÔ ÚÎÁÞÅÎÉÅ, +ÐÏÔÏÍÕ ÞÔÏ ËÏÍÁÎÄÁ {\tt fill} ÉÓÐÏÌØÚÕÅÔ ÐÒÁ×ÉÌÏ ``ÎÅÎÕÌÅ×ÏÇÏ ×ÅÒÔÑÝÅÇÏÓÑ +ÞÉÓÌÁ''\index{×ÅÒÔÑÝÅÅÓÑ ÞÉÓÌÏ} (non-zero winding number) +PostScript\index{PostScript}~\cite{ad:red2}. +%%This path has +%%a counter-clockwise orientation, but that does not matter because the +%%{\tt fill} statement uses PostScript's\index{PostScript} non-zero +%%winding\index{winding number} number rule~\cite{ad:red2}. + +\begin{figure}[htp] +$$ \begin{verbatim} +beginfig(21); +path p; +p = (-1cm,0)..(0,-1cm)..(1cm,0); +fill p{up}..(0,0){-1,-2}..{up}cycle; +draw p..(0,1cm)..cycle; +endfig; +\end{verbatim} +\qquad \mathcenter{\includegraphics{manfig-ru-21}} +$$ +\caption{MetaPost ËÏÄ É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ×Ù×ÏÄ.} +%%\caption{MetaPost code and the corresponding output.} +\label{fig20} +\end{figure} + +ïÂÝÁÑ ËÏÍÁÎÄÁ\index{withcolor?\texttt{withcolor}}\label{Dwithcolor} {\tt fill} +$$ {\tt fill}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\, + {\tt withcolor}\, \descr{×ÙÒÁÖÅÎÉÅ-Ã×ÅÔ} +$$ +ÕËÁÚÙ×ÁÅÔ ÕÒÏ×ÅÎØ ÓÅÒÏÇÏ ÉÌÉ (ÅÓÌÉ Õ ×ÁÓ ÅÓÔØ Ã×ÅÔÎÏÊ ÐÒÉÎÔÅÒ) ÎÅËÏÔÏÒÙÊ +Ã×ÅÔ ÒÁÄÕÇÉ. +%%The general {\tt fill} statement\index{withcolor?\texttt{withcolor}}\label{Dwithcolor} +%%$$ {\tt fill}\, \descr{path expression}\, +%% {\tt withcolor}\, \descr{color expression} +%%$$ +%%specifies a shade of gray or (if you have a color printer) some +%%rainbow color. +$\descr{÷ÙÒÁÖÅÎÉÅ-Ã×ÅÔ}$ ÍÏÖÅÔ ÉÍÅÔØ ÐÑÔØ ×ÏÚÍÏÖÎÙÈ ÚÎÁÞÅÎÉÊ, +ÐÅÒÅ×ÏÄÉÍÙÈ Ë ÞÅÔÙÒÅÍ ×ÏÚÍÏÖÎÙÍ Ã×ÅÔÏ×ÙÍ ÍÏÄÅÌÑÍ: +%%The $\descr{color expression}$ can have five possible +%%values, mapping to four possible color models: + +$$ +\begin{tabular}{ll} +äÅÊÓÔ×ÉÔÅÌØÎÙÊ ××ÏÄ & ðÅÒÅ×ÏÄÉÍÏÅ ÚÎÁÞÅÎÉÅ\\\hline +%%Actual input & Remapped meaning\\\hline +{\tt withcolor} $\descr{rgb-Ã×ÅÔ} c$ & withrgbcolor\index{withrgbcolor?\texttt{withrgbcolor}}\label{Dwithrgbcolor} $c$\\ +%%{\tt withcolor} $\descr{rgbcolor} c$ & %%withrgbcolor\index{withrgbcolor?\texttt{withrgbcolor}}\label{Dwithrgbcolor} $c$\\ +{\tt withcolor} $\descr{cmyk-Ã×ÅÔ} c$ & withcmykcolor\index{withrgbcolor?\texttt{withcmykcolor}}\label{Dwithcmykcolor} $c$\\ +%%{\tt withcolor} $\descr{cmykcolor} c$ & %%withcmykcolor\index{withrgbcolor?\texttt{withcmykcolor}}\label{Dwithcmykcolor} $c$\\ +{\tt withcolor} $\descr{ÞÉÓÌÏ} c$ & withgreyscale\index{withrgbcolor?\texttt{withgreyscale}}\label{Dwithgreyscale} $c$\\ +%%{\tt withcolor} $\descr{numeric} c$ & %%withgreyscale\index{withrgbcolor?\texttt{withgreyscale}}\label{Dwithgreyscale} $c$\\ +{\tt withcolor} $\descr{ÌÏÖØ}$ & withoutcolor\index{withrgbcolor?\texttt{withoutcolor}}\label{Dwithoutcolor} \\ +%%{\tt withcolor} $\descr{false}$ & %%withoutcolor\index{withrgbcolor?\texttt{withoutcolor}}\label{Dwithoutcolor} \\ +{\tt withcolor} $\descr{ÉÓÔÉÎÁ}$ & $\descr{ÔÅËÕÝÁÑ ÔÉÐÏ×ÁÑ ÍÏÄÅÌØ Ã×ÅÔÁ}$\\ +%%{\tt withcolor} $\descr{true}$ & $\descr{current default color model}$\\ +\end{tabular} +$$ + +äÌÑ ÕËÁÚÁÎÎÙÈ ÍÏÄÅÌÅÊ Ã×ÅÔÁ ÅÓÔØ ÔÁËÖÅ +$$ {\tt fill}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\, + {\tt withrgbcolor}\, \descr{×ÙÒÁÖÅÎÉÅ-rgb-Ã×ÅÔ} +$$ +$$ {\tt fill}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\, + {\tt withcmykcolor}\, \descr{×ÙÒÁÖÅÎÉÅ-cmyk-Ã×ÅÔ} +$$ +$$ {\tt fill}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\, + {\tt withgreyscale}\, \descr{ÞÉÓÌÏ} +$$ +$$ {\tt fill}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\, + {\tt withoutcolor} +$$ +%%For the specific color models, there are also: +%%$$ {\tt fill}\, \descr{path expression}\, +%% {\tt withrgbcolor}\, \descr{rgbcolor expression} +%%$$ +%%$$ {\tt fill}\, \descr{path expression}\, +%% {\tt withcmykcolor}\, \descr{cmykcolor expression} +%%$$ +%%$$ {\tt fill}\, \descr{path expression}\, +%% {\tt withgreyscale}\, \descr{numeric} +%%$$ +%%$$ {\tt fill}\, \descr{path expression}\, +%% {\tt withoutcolor} +%%$$ + +ïÂßÅËÔ-ÉÚÏÂÒÁÖÅÎÉÅ ÎÅ ÍÏÖÅÔ ÉÍÅÔØ ÂÏÌÅÅ ÏÄÎÏÊ Ã×ÅÔÏ×ÏÊ ÍÏÄÅÌÉ, ÐÏÓÌÅÄÎÅÅ +ÕËÁÚÁÎÉÅ \ttt{withcolor}, \ttt{withrgbcolor}, \ttt{withcmykcolor}, +\ttt{withgreyscale} ÉÌÉ \ttt{withoutcolor} ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ ÍÏÄÅÌØ Ã×ÅÔÁ +ÄÌÑ ÌÀÂÏÇÏ ÏÔÄÅÌØÎÏÇÏ ÏÂßÅËÔÁ. +%%An image object cannot have more then one color model, the last +%%\ttt{withcolor}, \ttt{withrgbcolor}, \ttt{withcmykcolor}, +%%\ttt{withgreyscale} or \ttt{withoutcolor} specification sets the color +%%model for any particular object. + +íÏÄÅÌØ \ttt{withoutcolor} ÔÒÅÂÕÅÔ ÎÅÂÏÌØÛÉÈ ÒÁÚßÑÓÎÅÎÉÊ: ×ÙÂÏÒ ÜÔÏÊ +ÍÏÄÅÌÉ ÏÚÎÁÞÁÅÔ, ÞÔÏ MetaPost ÎÅ ÂÕÄÅÔ ÐÉÓÁÔØ ËÏÍÁÎÄÕ ×ÙÂÏÒÁ Ã×ÅÔÁ +× ×ÙÈÏÄÎÏÊ ÆÁÊÌ PostScript ÄÌÑ ÜÔÏÇÏ ÏÂßÅËÔÁ. +%%The model \ttt{withoutcolor} needs a bit more explanation: selecting +%%this model means that MetaPost will not write a color selection +%%statement to the PostScript output file for this object. + +`ôÅËÕÝÁÑ ÔÉÐÏ×ÁÑ' ÍÏÄÅÌØ Ã×ÅÔÁ ÍÏÖÅÔ ÂÙÔØ ÕÓÔÁÎÏ×ÌÅÎÁ ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ +×ÎÕÔÒÅÎÎÅÊ ÐÅÒÅÍÅÎÎÏÊ \ttindex{defaultcolormodel}. +%%The `current default' color model can be set up using the internal +%%variable \ttindex{defaultcolormodel}. +ôÁÂÌÉÃÁ~\ref{dfltcmod} ÐÅÒÅÞÉÓÌÑÅÔ ÅÅ ÄÏÐÕÓÔÉÍÙÅ ÚÎÁÞÅÎÉÑ. +\begin{table} +\centering +\begin{tabular}{|c|l|} +\hline +úÎÁÞÅÎÉÅ & íÏÄÅÌØ Ã×ÅÔÁ\\\hline +1 & ÎÅÔ ÍÏÄÅÌÉ\\ +3 & ÏÔÔÅÎËÉ ÓÅÒÏÇÏ\\ +5 & rgb (ÐÏ-ÕÍÏÌÞÁÎÉÀ)\\ +7 & cmyk\\ +\hline +\end{tabular} +\caption{ðÏÄÄÅÒÖÉ×ÁÅÍÙÅ ÍÏÄÅÌÉ Ã×ÅÔÁ.} +\label{dfltcmod} +\end{table} +%%\begin{table} +%%\centering +%%\begin{tabular}{|Ó|l|} +%%\hline +%%Value & Color model\\\hline +%%1 & no model\\ +%%3 & greyscale\\ +%%5 & rgb (default)\\ +%%7 & cmyk\\ +%%\hline +%%\end{tabular} +%%\caption{Supported color models.} +%%\label{dfltcmod} +%%\end{table} + +òÉÓ.~\ref{fig21} ÉÌÌÀÓÔÒÉÒÕÅÔ ÎÅÓËÏÌØËÏ ÐÒÉÍÅÎÅÎÉÊ ËÏÍÁÎÄÙ {\tt fill} ÄÌÑ +ÚÁÐÏÌÎÅÎÉÑ ÏÂÌÁÓÔÅÊ ÏÔÔÅÎËÁÍÉ ÓÅÒÏÇÏ. +%%Figure~\ref{fig21} illustrates several applications of the fill command +%%to fill areas with shades of gray. +ðÕÔÉ ×ËÌÀÞÁÀÔ ÐÅÒÅÓÅÞÅÎÉÑ ËÒÕÇÏ× {\tt a} É {\tt b} É ÐÕÔØ {\tt ab}, +ÏÈ×ÁÔÙ×ÁÀÝÉÊ ÏÂÌÁÓÔØ ×ÎÕÔÒÉ ÏÂÏÉÈ ËÒÕÇÏ×. +%%The paths involved are intersecting +%%circles {\tt a} and {\tt b} and a path {\tt ab} that bounds the region +%%inside both circles. +ëÒÕÇÉ {\tt a} É {\tt b} ÐÒÏÉÓÈÏÄÑÔ ÏÔ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÏÇÏ ÐÕÔÉ {\tt +fullcircle}\index{fullcircle?\texttt{fullcircle}}\label{Dfcirc}, +ÐÒÉÂÌÉÚÉÔÅÌØÎÏ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÇÏ ËÒÕÇÕ Ó ÅÄÉÎÉÞÎÙÍ ÄÉÁÍÅÔÒÏÍ É +Ó ÃÅÎÔÒÏÍ × ÎÁÞÁÌÅ ËÏÏÒÄÉÎÁÔ. +%%Circles {\tt a} and {\tt b} are derived from a +%%predefined path {\tt +%%fullcircle}\index{fullcircle?\texttt{fullcircle}}\label{Dfcirc} that +%%approximates a circle of unit diameter centered on the origin. +åÓÔØ ÔÁËÖÅ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÐÕÔØ {\tt +halfcircle}\index{halfcircle?\texttt{halfcircle}}\label{Dhcirc} --- +ÐÏÌÏ×ÉÎÁ {\tt fullcircle} ÎÁÄ ÏÓØÀ $x$. +%%There is also a predefined path {\tt +%%halfcircle}\index{halfcircle?\texttt{halfcircle}}\label{Dhcirc} that is +%%the part of {\tt fullcircle} above the $x$ axis. +ðÕÔØ~{\tt ab} ÚÁÔÅÍ ÉÎÉÃÉÁÌÉÚÉÒÕÅÔÓÑ, ÉÓÐÏÌØÚÕÑ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ +{\tt buildcycle}, ËÏÔÏÒÙÊ ÂÕÄÅÔ ÏÂÓÕÖÄÁÔØÓÑ ×ÓËÏÒÅ. +%%Path~{\tt ab} is then +%%initialized using a predefined macro {\tt buildcycle} that will be +%%discussed shortly. + +\begin{figure}[htp] +$$ \begin{verbatim} +beginfig(22); +path a, b, aa, ab; +a = fullcircle scaled 2cm; +b = a shifted (0,1cm); +aa = halfcircle scaled 2cm; +ab = buildcycle(aa, b); +picture pa, pb; +pa = thelabel(btex $A$ etex, (0,-.5cm)); +pb = thelabel(btex $B$ etex, (0,1.5cm)); +fill a withcolor .7white; +fill b withcolor .7white; +fill ab withcolor .4white; +unfill bbox pa; +draw pa; +unfill bbox pb; +draw pb; +label.lft(btex $U$ etex, (-1cm,.5cm)); +draw bbox currentpicture; +endfig; +\end{verbatim} +\qquad \mathcenter{\includegraphics{manfig-ru-22}} +$$ +\caption{MetaPost ËÏÄ É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ×Ù×ÏÄ.} +%%\caption{MetaPost code and the corresponding output.} +\index{fullcircle?\texttt{fullcircle}}\index{halfcircle?\texttt{halfcircle}}\index{buildcycle?\texttt{buildcycle}} +\label{fig21} +\end{figure} + +úÁÐÏÌÎÅÎÉÅ ËÒÕÇÁ {\tt a} Ó×ÅÔÌÙÍ ÓÅÒÙÍ Ã×ÅÔÏÍ {\tt .7white} É ÚÁÔÅÍ ÔÁËÏÅ +ÖÅ ÚÁÐÏÌÎÅÎÉÅ ËÒÕÇÁ {\tt b} Ä×ÁÖÄÙ ÚÁÐÏÌÎÑÅÔ ÏÂÌÁÓÔØ, ÇÄÅ ËÒÕÇÉ ÐÅÒÅÓÅËÁÀÔÓÑ. +%%Filling circle {\tt a} with the light gray color {\tt .7white} and then +%%doing the same with circle {\tt b} doubly fills the region where the +%%disks overlap. +åÓÔØ ÐÒÁ×ÉÌÏ, ÞÔÏ ËÁÖÄÁÑ ËÏÍÁÎÄÁ {\tt fill} ÐÒÉÓ×ÁÉ×ÁÅÔ ÄÁÎÎÙÊ Ã×ÅÔ +×ÓÅÍ ÔÏÞËÁÍ ÐÏËÒÙ×ÁÅÍÏÇÏ ÒÅÇÉÏÎÁ, ÕÎÉÞÔÏÖÁÑ ×ÓÅ, ÞÔÏ ÔÁÍ ÂÙÌÏ, ×ËÌÀÞÁÑ +ÌÉÎÉÉ, ÔÅËÓÔ É ÚÁÐÏÌÎÅÎÎÙÅ ÏÂÌÁÓÔÉ. +%%The rule is that each {\tt fill} statement assigns the +%%given color to all points in the region covered, wiping out whatever was +%%there previously including lines and text as well as filled regions. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ×ÁÖÎÏ ÚÁÄÁ×ÁÔØ ËÏÍÁÎÄÙ {\tt fill} × ÐÒÁ×ÉÌØÎÏÍ ÐÏÒÑÄËÅ. +%%Thus it is important to give {\tt fill} commands in the right order. +÷ ÐÒÉÍÅÒÅ ×ÙÛÅ ÐÅÒÅËÒÙ×ÁÅÍÁÑ ÏÂÌÁÓÔØ ÐÏÌÕÞÁÅÔ ÏÄÉÎÁËÏ×ÙÊ Ã×ÅÔ Ä×ÁÖÄÙ, +ÏÓÔÁ×ÁÑÓØ Ó×ÅÔÌÏÓÅÒÏÊ ÐÏÓÌÅ ÐÅÒ×ÙÈ Ä×ÕÈ ËÏÍÁÎÄ {\tt fill}. +%%In the above example, the overlap region gets the same color twice, leaving +%%it light gray after the first two {\tt fill} statements. +ôÒÅÔØÑ ËÏÍÁÎÄÁ {\tt fill} ÐÒÉÓ×ÁÉ×ÁÅÔ ÂÏÌÅÅ ÔÅÍÎÙÊ Ã×ÅÔ {\tt .4white} +ÐÅÒÅËÒÙ×ÁÅÍÏÊ ÏÂÌÁÓÔÉ. +%%The third fill +%%statement assigns the darker color {\tt .4white} to the overlap region. + +ðÏÓÌÅ ÜÔÏÇÏ ËÒÕÇÉ É ÉÈ ÐÅÒÅÓÅÞÅÎÉÅ ÐÏÌÕÞÁÀÔ Ó×ÏÉ ÏËÏÎÞÁÔÅÌØÎÙÅ Ã×ÅÔÁ, ÎÏ +× ÎÉÈ ÎÅÔ ×ÙÒÅÚÏË ÄÌÑ ÍÅÔÏË. +%%At this point the circles and the overlap region have their final colors +%%but there are no cutouts for the labels. +÷ÙÒÅÚËÉ ÐÏÌÕÞÁÀÔÓÑ ËÏÍÁÎÄÁÍÉ {\tt +unfill}\index{unfill?\texttt{unfill}}\label{Dunfill}, ËÏÔÏÒÙÅ +ÂÙÓÔÒÏ ÕÎÉÞÔÏÖÁÀÔ\index{ÓÔÉÒÁÎÉÅ} ÏÂÌÁÓÔÉ, ÏÈ×ÁÔÙ×ÁÀÝÉÉ {\tt bbox +pa}\index{bbox?\texttt{bbox}} É {\tt bbox pb}. +%%The cutouts are achieved by +%%the {\tt unfill}\index{unfill?\texttt{unfill}}\label{Dunfill} statements +%%that effectively erase\index{erasing} the regions bounded by {\tt bbox +%%pa}\index{bbox?\texttt{bbox}} and {\tt bbox pb}. +âÏÌÅÅ ÔÏÞÎÏ, {\tt unfill} --- ÜÔÏ ÓÏËÒÁÝÅÎÉÅ ÚÁÐÏÌÎÅÎÉÑ Ó {\tt withcolor +background}, ÇÄÅ {\tt background} ÏÂÙÞÎÏ ÒÁ×ÅÎ {\tt white}, ÞÔÏ ÐÏÄÈÏÄÉÔ +ÐÒÉ ÐÅÞÁÔÉ ÎÁ ÂÅÌÏÊ ÂÕÍÁÇÅ. +%%More precisely, {\tt +%%unfill} is shorthand for filling {\tt withcolor background}, where {\tt +%%background} is normally equal to {\tt white} as is appropriate for +%%printing on white paper. +åÓÌÉ ÎÅÏÂÈÏÄÉÍÏ, ÔÏ ×Ù ÍÏÖÅÔÅ ÐÒÉÓ×ÏÉÔØ ÎÏ×ÙÊ Ã×ÅÔ {\tt +background}\index{background?\texttt{background}}\label{Dbground}. +%%If necessary, you can assign a new color value to {\tt +%%background}\index{background?\texttt{background}}\label{Dbground}. + +íÅÔËÉ ÄÏÌÖÎÙ ÂÙÔØ ÐÏÍÅÝÅÎÙ × ËÁÒÔÉÎËÉ {\tt pa} É {\tt pb} ÄÌÑ ×ÏÚÍÏÖÎÏÓÔÉ +ÉÚÍÅÒÅÎÉÑ ÉÈ ÏÈ×ÁÔÙ×ÁÀÝÉÈ ÒÁÍÏË ÄÏ ÉÈ ÒÉÓÏ×ÁÎÉÑ. +%%The labels need to be stored in pictures {\tt pa} and {\tt pb} to allow +%%for measuring their bounding box before actually drawing them. +íÁËÒÏÓ {\tt thelabel}\index{thelabel?\texttt{thelabel}} ÓÏÚÄÁÅÔ +ÔÁËÉÅ ËÁÒÔÉÎËÉ É ÓÄ×ÉÇÁÅÔ ÉÈ × ÐÏÚÉÃÉÉ, ÇÄÅ ÏÎÉ ÇÏÔÏ×Ù ÄÌÑ ÒÉÓÏ×ÁÎÉÑ. +%%The macro {\tt thelabel}\index{thelabel?\texttt{thelabel}} creates such +%%pictures and shifts them into position so that they are ready to draw. +éÓÐÏÌØÚÏ×ÁÎÉÅ ÉÔÏÇÏ×ÙÈ ËÁÒÔÉÎÏË × ËÏÍÁÎÄÅ {\tt draw} × +ÆÏÒÍÅ\index{draw?\texttt{draw}} +$$ {\tt draw}\, \descr{×ÙÒÁÖÅÎÉÅ-ÒÉÓÕÎÏË} $$ +ÄÏÂÁ×ÌÑÅÔ ÉÈ Ë ÔÅËÕÝÅÊ ËÁÒÔÉÎËÅ {\tt +currentpicture}\index{currentpicture?\texttt{currentpicture}} +ÔÁË, ÞÔÏ ÏÎÉ ÐÅÒÅÚÁÐÉÓÙ×ÁÀÔ ÞÁÓÔØ ÔÏÇÏ, ÞÔÏ ÕÖÅ +ÎÁÒÉÓÏ×ÁÎÏ. +%%Using the resulting pictures in {\tt draw} statements of the +%%form\index{draw?\texttt{draw}} +%%$$ {\tt draw}\, \descr{picture expression} $$ +%%adds them to {\tt currentpicture}\index{currentpicture?\texttt{currentpicture}} +%%so that they overwrite a portion of what has +%%already been drawn. +îÁ ÒÉÓ.~\ref{fig21} ÐÅÒÅÚÁÐÉÓÙ×ÁÀÔÓÑ ÓÁÍÉ ÂÅÌÙÅ ÐÒÑÍÏÕÇÏÌØÎÉËÉ, +ÓÏÚÄÁÎÎÙÅ {\tt unfill}. +%%In Figure~\ref{fig21} just the white rectangles produced by +%%{\tt unfill} get overwritten. + +\subsection{ðÏÓÔÒÏÅÎÉÅ ÃÉËÌÏ×} +%%\subsection{Building Cycles} +\label{buildcy} + +ëÏÍÁÎÄÁ {\tt buildcycle}\index{buildcycle?\texttt{buildcycle}} +ËÏÎÓÔÒÕÉÒÕÅÔ ÐÕÔÉ ÄÌÑ ÉÓÐÏÌØÚÏ×ÁÎÉÑ Ó ÍÁËÒÏÓÁÍÉ {\tt fill} ÉÌÉ {\tt unfill}. +%%The {\tt buildcycle}\index{buildcycle?\texttt{buildcycle}} command +%%constructs paths for use with the {\tt fill} or {\tt unfill} macros. +ëÏÇÄÁ ÚÁÄÁÀÔÓÑ Ä×Á ÉÌÉ ÂÏÌÅÅ ÐÕÔÅÊ, ÔÁËÉÈ ËÁË {\tt aa} É {\tt b}, +ÍÁËÒÏÓ {\tt buildcycle} ÐÙÔÁÅÔÓÑ ÓÏÅÄÉÎÉÔØ ÉÈ ÞÁÓÔÉ ×ÍÅÓÔÅ, ÆÏÒÍÉÒÕÑ +ÃÉËÌÉÞÅÓËÉÊ ÐÕÔØ. +%%When given two or more paths such as {\tt aa} and {\tt b}, the {\tt +%%buildcycle} macro tries to piece them together so as to form a cyclic +%%path. +÷ ÒÁÓÓÍÏÔÒÅÎÎÏÍ ÓÌÕÞÁÅ ÐÕÔØ {\tt aa} Ñ×ÌÑÅÔÓÑ ÐÏÌÕËÒÕÇÏÍ, ÎÁÞÉÎÁÀÝÉÍÓÑ +ÓÐÒÁ×Á ÏÔ ÐÅÒÅÓÅÞÅÎÉÑ Ó ÐÕÔÅÍ {\tt b}, ÚÁÔÅÍ ÐÒÏÈÏÄÑÝÉÍ ÞÅÒÅÚ +{\tt b} É ÚÁËÁÎÞÉ×ÁÀÝÉÍÓÑ ÓÎÁÒÕÖÉ ËÒÕÇÁ ÓÌÅ×Á, ËÁË ÐÏËÁÚÁÎÏ ÎÁ +ÒÉÓ.~\ref{fig22}a. +%%In this case path {\tt aa} is a semicircle that starts just to +%%the right of the intersection with path {\tt b}, then passes through +%%{\tt b} and ends just outside the circle on the left as shown in +%%Figure~\ref{fig22}a. + +òÉÓ.~\ref{fig22}b ÐÏËÁÚÙ×ÁÅÔ ËÁË {\tt buildcycle} ÆÏÒÍÉÒÕÅÔ ÚÁÍËÎÕÔÙÊ ÃÉËÌ +ÉÚ ËÕÓËÏ× ÐÕÔÅÊ {\tt aa} É {\tt b}. +%%Figure~\ref{fig22}b shows how {\tt buildcycle} forms a closed cycle from +%%the pieces of paths {\tt aa} and {\tt b}. +íÁËÒÏÓ {\tt buildcycle} ÎÁÈÏÄÉÔ Ä×Á ÐÅÒÅÓÅÞÅÎÉÑ\index{ÐÅÒÅÓÅÞÅÎÉÑ}, +ÐÏÍÅÞÅÎÎÙÅ 1 É 2 ÎÁ ÒÉÓ.~\ref{fig22}b. +%%The {\tt buildcycle} macro +%%detects the two intersections\index{intersections} labeled 1 and 2 in +%%Figure~\ref{fig22}b. +úÁÔÅÍ ÏÎ ËÏÎÓÔÒÕÉÒÕÅÔ ÃÉËÌÉÞÅÓËÉÊ ÐÕÔØ, ÐÏËÁÚÁÎÎÙÊ ×ÙÄÅÌÅÎÎÙÍ ÎÁ +ÒÉÓÕÎËÅ, Ä×ÉÇÁÑÓØ ×ÄÏÌØ ÐÕÔÉ {\tt aa} ÏÔ ÐÅÒÅÓÅÞÅÎÉÑ~1 Ë ÐÅÒÅÓÅÞÅÎÉÀ~2 +É ÚÁÔÅÍ ÐÒÏÔÉ× ÞÁÓÏ×ÏÊ ÓÔÒÅÌËÉ ÐÏ ÐÕÔÉ {\tt b} ÏÂÒÁÔÎÏ Ë ÐÅÒÅÓÅÞÅÎÉÀ~1. +%%Then it constructs the cyclic path shown in bold +%%in the figure by going forward along path {\tt aa} from intersection~1 +%%to intersection~2 and then forward around the counter-clockwise path +%%{\tt b} back to intersection~1. +ëÁÖÅÔÓÑ ÏÞÅ×ÉÄÎÙÍ, ÞÔÏ {\tt buildcycle(a,b)} ÂÕÄÅÔ ÐÒÏÉÚ×ÏÄÉÔØ ÔÁËÏÊ ÖÅ +ÒÅÚÕÌØÔÁÔ, ÎÏ ÏÓÎÏ×ÁÎÉÑ ÄÌÑ ÜÔÏÇÏ ÎÅÓËÏÌØËÏ ÐÕÔÁÎÎÙÅ. +%%It turns out that {\tt buildcycle(a,b)} +%%would have produced the same result, but the reasoning behind this is a +%%little confusing. + +\begin{figure}[htp] +$$ {\includegraphics{manfig-ru-123} \atop (a)} + \qquad {\includegraphics{manfig-ru-223} \atop (b)} +$$ +\caption[äÅÍÏÎÓÔÒÁÃÉÑ ÐÏÓÔÒÏÅÎÉÑ ÃÉËÌÁ] + {(a)~ðÏÌÕËÒÕÇÏ×ÏÊ ÐÕÔØ~{\tt aa} + Ó ÐÕÎËÔÉÒÎÏÊ ÌÉÎÉÅÊ, ÏÔÍÅÞÁÀÝÅÊ ÐÕÔØ {\tt b}; (b)~ÐÕÔÉ~{\tt aa} É {\tt b} + Ó ÞÁÓÔÑÍÉ, ×ÙÄÅÌÑÅÍÙÍÉ {\tt buildcycle} É ÐÏËÁÚÁÎÎÙÍÉ ÖÉÒÎÙÍÉ ÌÉÎÉÑÍÉ.} +%%\caption[A demonstration of cycle building] +%% {(a)~The semicircular path~{\tt aa} +%% with a dashed line marking path {\tt b}; (b)~paths~{\tt aa} and {\tt b} +%% with the portions selected by {\tt buildcycle} shown by heavy lines.} +\label{fig22} +\end{figure} + +ðÒÏÝÅ ×ÓÅÇÏ ÉÓÐÏÌØÚÏ×ÁÔØ ÍÁËÒÏÓ {\tt buildcycle} × ÓÉÔÕÁÃÉÑÈ, ÐÏÄÏÂÎÙÈ +ÒÉÓ.~\ref{fig23}, ÇÄÅ ÅÓÔØ ÂÏÌÅÅ Ä×ÕÈ ÁÒÇÕÍÅÎÔÏ×-ÐÕÔÅÊ É ËÁÖÄÁÑ ÐÁÒÁ +ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÙÈ ÐÕÔÅÊ ÉÍÅÅÔ ÕÎÉËÁÌØÎÏÅ ÐÅÒÅÓÅÞÅÎÉÅ. +%%It is a easier to use the {\tt buildcycle} macro in situations like +%%Figure~\ref{fig23} where there are more than two path arguments and each +%%pair of consecutive paths has a unique intersection. +îÁÐÒÉÍÅÒ, ÐÒÑÍÁÑ~{\tt q0.5} É ËÒÉ×ÁÑ~{\tt p2} ÐÅÒÅÓÅËÁÀÔÓÑ ÔÏÌØËÏ +× ÔÏÞËÅ~$P$; ËÒÉ×ÁÑ {\tt p2} É ÐÒÑÍÁÑ ~{\tt q1.5} --- ÔÏÌØËÏ × ÔÏÞËÅ~$Q$. +%%For instance, the +%%line~{\tt q0.5} and the curve~{\tt p2} intersect only at point~$P$; and +%%the curve {\tt p2} and the line~{\tt q1.5} intersect only at point~$Q$. +æÁËÔÉÞÅÓËÉ ËÁÖÄÁÑ ÉÚ ÔÏÞÅË $P$, $Q$, $R$, $S$ Ñ×ÌÑÅÔÓÑ ÕÎÉËÁÌØÎÙÍ +ÐÅÒÅÓÅÞÅÎÉÅÍ É ÒÅÚÕÌØÔÁÔ\index{buildcycle?\texttt{buildcycle}} ËÏÍÁÎÄÙ +$$ \hbox{\tt buildcycle(q0.5, p2, q1.5, p4)} $$ +ÂÅÒÅÔ {\tt q0.5} ÏÔ $S$ ÄÏ~$P$, ÚÁÔÅÍ {\tt p2} ÏÔ $P$ ÄÏ~$Q$, ÚÁÔÅÍ +{\tt q1.5} ÏÔ $Q$ ÄÏ~$R$ É, ÎÁËÏÎÅÃ, {\tt p4} ÏÔ $R$ ÏÂÒÁÔÎÏ ÄÏ~$S$. +%%In fact, each of the points $P$, $Q$, $R$, $S$ is a unique intersection, +%%and the result of\index{buildcycle?\texttt{buildcycle}} +%%$$ \hbox{\tt buildcycle(q0.5, p2, q1.5, p4)} $$ +%%takes {\tt q0.5} from $S$ to~$P$, then {\tt p2} from $P$ to~$Q$, then +%%{\tt q1.5} from $Q$ to~$R$, and finally {\tt p4} from $R$ back to~$S$. +éÓÓÌÅÄÏ×ÁÎÉÅ ËÏÄÁ MetaPost ÄÌÑ ÒÉÓ.~\ref{fig23} ÏÔËÒÙ×ÁÅÔ, ÞÔÏ +×Ù ÄÏÌÖÎÙ ÉÄÔÉ ÎÁÚÁÄ ×ÄÏÌØ {\tt p2} ÎÁ ÐÅÒÅÈÏÄÅ ÏÔ $P$ ÄÏ~$Q$. +%%An examination of the MetaPost code for Figure~\ref{fig23} reveals that +%%you have to go backwards along {\tt p2} in order to get from $P$ to~$Q$. +÷ÓÅ ÒÁÂÏÔÁÅÔ ×ÐÏÌÎÅ ÓÏ×ÅÒÛÅÎÎÏ ÄÏ ÔÅÈ ÐÏÒ, ÐÏËÁ ÔÏÞËÉ +ÐÅÒÅÓÅÞÅÎÉÑ\index{ÐÅÒÅÓÅÞÅÎÉÅ} ÏÐÒÅÄÅÌÑÀÔÓÑ ÕÎÉËÁÌØÎÏ, ÎÏ ÍÏÖÅÔ ÏÂÕÓÌÏ×ÉÔØ +ÎÅÏÖÉÄÁÎÎÙÅ ÒÅÚÕÌØÔÁÔÙ, ËÏÇÄÁ ÐÁÒÙ ÐÕÔÅÊ ÐÅÒÅÓÅËÁÀÔÓÑ ÂÏÌÅÅ ÏÄÎÏÇÏ ÒÁÚÁ. +%%This works perfectly well as long as the +%%intersection\index{intersection} points are uniquely defined but it can +%%cause unexpected results when pairs of paths intersect more than once. + +\begin{figure}[htp] +$$ \begin{verbatim} +beginfig(24); +h=2in; w=2.7in; +path p[], q[], pp; +for i=2 upto 4: ii:=i**2; + p[i] = (w/ii,h){1,-ii}...(w/i,h/i)...(w,h/ii){ii,-1}; +endfor +q0.5 = (0,0)--(w,0.5h); +q1.5 = (0,0)--(w/1.5,h); +pp = buildcycle(q0.5, p2, q1.5, p4); +fill pp withcolor .7white; +z0=center pp; +picture lab; lab=thelabel(btex $f>0$ etex, z0); +unfill bbox lab; draw lab; +draw q0.5; draw p2; draw q1.5; draw p4; +dotlabel.top(btex $P$ etex, p2 intersectionpoint q0.5); +dotlabel.rt(btex $Q$ etex, p2 intersectionpoint q1.5); +dotlabel.lft(btex $R$ etex, p4 intersectionpoint q1.5); +dotlabel.bot(btex $S$ etex, p4 intersectionpoint q0.5); +endfig; +\end{verbatim} +\atop \mathcenter{\includegraphics{manfig-ru-24}} +$$ +\caption{MetaPost-ËÏÄ É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ×Ù×ÏÄ.} +%%\caption{MetaPost code and the corresponding output.} +\label{fig23} +\end{figure} + +ïÂÝÅÅ ÐÒÁ×ÉÌÏ ÄÌÑ ÍÁËÒÏÓÁ {\tt buildcycle}: +$$ \hbox{\tt buildcycle(}p_1\hbox{\tt,}\, p_2\hbox{\tt,}\, + p_3\hbox{\tt,}\, \ldots \hbox{\tt,} p_k \hbox{\tt )} +$$ +×ÙÂÉÒÁÅÔ ÐÅÒÅÓÅÞÅÎÉÅ ÍÅÖÄÕ ËÁÖÄÙÍ $p_i$ É $p_{i+1}$ ÔÁË, ÞÔÏÂÙ ÜÔÏ +ÂÙÌÏ ËÁË ÍÏÖÎÏ ÄÁÌØÛÅ ÎÁ $p_i$ É ËÁË ÍÏÖÎÏ ÂÌÉÖÅ ÎÁ +$p_{i+1}$\footnote{ðÅÒ×ÙÍ ÎÁÈÏÄÉÔÓÑ ÐÅÒÅÓÅÞÅÎÉÅ ÍÅÖÄÕ $p_k$ É $p_1$, +ÚÁÔÅÍ $p_1$ É $p_2$, $\ldots$ (ÐÒÉÍ. ÐÅÒÅ×.)}. +%%The general rule for the {\tt buildcycle} macro is that +%%$$ \hbox{\tt buildcycle(}p_1\hbox{\tt,}\, p_2\hbox{\tt,}\, +%% p_3\hbox{\tt,}\, \ldots \hbox{\tt,} p_k \hbox{\tt )} +%%$$ +%%chooses the intersection between each $p_i$ and $p_{i+1}$ to be as late +%%as possible on $p_i$ and as early as possible on $p_{i+1}$. +îÅÔ ÐÒÏÓÔÏÇÏ ÐÒÁ×ÉÌÁ ÄÌÑ ÒÁÚÒÅÛÅÎÉÑ ËÏÎÆÌÉËÔÏ× ÍÅÖÄÕ ÜÔÉÍÉ Ä×ÕÍÑ ÃÅÌÑÍÉ, +ÔÁË ÞÔÏ ×ÁÍ ÓÌÅÄÕÅÔ ÉÚÂÅÇÁÔØ ÓÌÕÞÁÅ×, ËÏÇÄÁ ÏÄÎÁ ÔÏÞËÁ ÐÅÒÅÓÅÞÅÎÉÑ ÓÌÕÞÁÅÔÓÑ +ÄÁÌØÛÅ ÎÁ $p_i$ É ÄÒÕÇÁÑ ÔÏÞËÁ ÐÅÒÅÓÅÞÅÎÉÑ\index{ÐÅÒÅÓÅÞÅÎÉÅ} ÓÌÕÞÁÅÔÓÑ +ÂÌÉÖÅ ÎÁ $p_{i+1}$. +%%There is no +%%simple rule for resolving conflicts between these two goals, so you +%%should avoid cases where one intersection point occurs later on $p_i$ +%%and another intersection\index{intersection} point occurs earlier on +%%$p_{i+1}$. + +õÓÔÁÎÏ×ËÁ ÎÁ ÓÁÍÙÅ ÄÁÌØÎÉÅ ÐÅÒÅÓÅÞÅÎÉÑ ÄÌÑ $p_i$ É ÓÁÍÙÅ ÂÌÉÖÎÉÅ ÄÌÑ +$p_{i+1}$ ×ÅÄÅÔ Ë ÕÓÔÒÁÎÅÎÉÑ ÎÅÑÓÎÏÓÔÉ ÐÒÅÄÐÏÞÔÅÎÉÅÍ ÉÄÕÝÉÈ ×ÐÅÒÅÄÉ +ÐÏÄÐÕÔÅÊ. +%%The preference for intersections as late as possible on $p_i$ and as +%%early as possible on $p_{i+1}$ leads to ambiguity resolution in favor of +%%forward-going subpaths. +äÌÑ ÃÉËÌÉÞÅÓËÉÈ ÐÕÔÅÊ, ËÁË ÐÕÔØ~{\tt b} ÎÁ +ÒÉÓ.~\ref{fig22}, ``ÂÌÉÚËÏ'' É ``ÄÁÌÅËÏ'' ÏÔÎÏÓÉÔÅÌØÎÙ ÐÏ ÏÔÎÏÛÅÎÉÀ +Ë ÎÁÞÁÌØÎÏÊ/ËÏÎÅÞÎÏÊ ÔÏÞËÅ, ËÏÔÏÒÁÑ ÒÁÓÐÏÌÏÖÅÎÁ ÔÁÍ, ËÕÄÁ ×Ù ÐÏÐÁÄÁÅÔÅ +ÏÂÒÁÔÎÏ, ÓËÁÚÁ× ``{\tt ..cycle}''. +%%For cyclic paths such as path~{\tt b} in +%%Figure~\ref{fig22} ``early'' and ``late'' are relative to a start/finish +%%point which is where you get back to when you say ``{\tt ..cycle}''. +äÌÑ ÐÕÔÉ~{\tt b} ÜÔÁ ÔÏÞËÁ ÕÓÔÁÎÁ×ÌÉ×ÁÅÔÓÑ ÎÁ ÓÁÍÕÀ ÐÒÁ×ÕÀ ÔÏÞËÕ ÎÁ ËÒÕÇÅ. +%%For the path~{\tt b}, this turns out to be the rightmost point on the +%%circle. + +âÏÌÅÅ ÐÒÑÍÏÊ ÐÕÔØ ÄÌÑ ÒÁÂÏÔÙ Ó ÐÕÔÅ×ÙÍÉ ÐÅÒÅÓÅÞÅÎÉÑÍÉ × ÉÓÐÏÌØÚÏ×ÁÎÉÉ +\tdescr{×ÔÏÒÉÞÎÏÇÏ ÂÉÎÁÒÎÏÇÏ +ÏÐÅÒÁÔÏÒÁ}\index{×ÔÏÒÉÞÎÙÊ binop?\tdescr{×ÔÏÒÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}} +{\tt +intersection\-point}\index{intersectionpoint?\texttt{intersectionpoint}}\label{Disecpt}, +ÎÁÈÏÄÑÝÅÇÏ ÔÏÞËÉ $P$, $Q$, $R$ É~$S$ ÎÁ ÒÉÓ.~\ref{fig23}. +%%A more direct way to deal with path intersections is via the +%%\tdescr{secondary binop}\index{secondary binop?\tdescr{secondary binop}} +%%{\tt +%%intersection\-point}\index{intersectionpoint?\texttt{intersectionpoint}}\label{Disecpt} +%%that finds the points $P$, $Q$, $R$, and~$S$ in Figure~\ref{fig23}. +üÔÏÔ ÍÁËÒÏÓ ÎÁÈÏÄÉÔ ÔÏÞËÕ, ÇÄÅ Ä×Á ÄÁÎÎÙÈ ÐÕÔÉ ÐÅÒÅÓÅËÁÀÔÓÑ. +%%This macro finds a point where two given paths intersect. +åÓÌÉ ÓÕÝÅÓÔ×ÕÅÔ ÂÏÌÅÅ ÏÄÎÏÊ ÔÏÞËÉ ÐÅÒÅÓÅÞÅÎÉÑ, ÔÏ ÏÎ ×ÙÂÉÒÁÅÔ ÏÄÎÕ; ÅÓÌÉ +ÔÏÞÅË ÐÅÒÅÓÅÞÅÎÉÑ ÎÅÔ, ÔÏ ÍÁËÒÏÓ ÇÅÎÅÒÉÒÕÅÔ ÓÏÏÂÝÅÎÉÅ Ï ÏÛÉÂËÅ. +%%If there is +%%more than one intersection point, it just chooses one; if there is no +%%intersection, the macro generates an error message. + +\subsection{ðÁÒÁÍÅÔÒÉÞÅÓËÁÑ ÒÁÂÏÔÁ Ó ÐÕÔÑÍÉ} +%%\subsection{Dealing with Paths Parametrically} + +íÁËÒÏÓ {\tt +intersectionpoint}\index{intersectionpoint?\texttt{intersectionpoint}} +ÏÓÎÏ×ÁÎ ÎÁ ÐÒÉÍÉÔÉ×ÎÏÊ ÏÐÅÒÁÃÉÉ Ó ÉÍÅÎÅÍ {\tt +intersectiontimes}\index{intersectiontimes?\texttt{intersectiontimes}}\label{Disectt}. +%%The {\tt +%%intersectionpoint}\index{intersectionpoint?\texttt{intersectionpoint}} +%%macro is based on a primitive operation called {\tt +%%intersectiontimes}\index{intersectiontimes?\texttt{intersectiontimes}}\label{Disectt}. +üÔÏÔ \tdescr{×ÔÏÒÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} --- ÏÄÉÎ ÉÚ ÎÅÓËÏÌØËÉÈ ÏÐÅÒÁÔÏÒÏ×, +ÒÁÂÏÔÁÀÝÉÈ Ó ÐÕÔÑÍÉ ÐÁÒÁÍÅÔÒÉÞÅÓËÉ. +%%This \tdescr{secondary binop} is one of several operations that deal +%%with paths parametrically. +ïÎ ÎÁÈÏÄÉÔ ÐÅÒÅÓÅÞÅÎÉÅ ÍÅÖÄÕ Ä×ÕÍÑ ÐÕÔÑÍÉ, ÚÁÄÁÎÉÅÍ ÐÁÒÁÍÅÔÒÁ ``×ÒÅÍÑ'' ÎÁ +ËÁÖÄÏÍ ÉÚ ÐÕÔÅÊ. +%%It locates an intersection between two paths +%%by giving the ``time'' parameter on each path. +üÔÏ ÓÓÙÌËÁ ÎÁ ÓÈÅÍÕ ÐÁÒÁÍÅÔÒÉÚÁÃÉÉ ÉÚ ÒÁÚÄÅÌÁ~\ref{curves}, ÏÐÒÅÄÅÌÑÀÝÅÇÏ +ÐÕÔÉ ËÁË ËÕÓÏÞÎÙÅ ËÕÂÉÞÅÓËÉÅ ËÒÉ×ÙÅ $\bigl(X(t),Y(t)\bigr)$, ÇÄÅ ÄÉÁÐÁÚÏÎ $t$ +ÏÔ ÎÕÌÑ ÄÏ ÞÉÓÌÁ ÏÔÒÅÚËÏ× ËÒÉ×ÏÊ. +%%This refers to the +%%parameterization scheme from Section~\ref{curves} that described paths +%%as piecewise cubic curves $\bigl(X(t),Y(t)\bigr)$ where $t$ ranges from +%%zero to the number of curve segments. +äÒÕÇÉÍÉ ÓÌÏ×ÁÍÉ, ÐÕÔØ ÚÁÄÁÅÔÓÑ, ËÁË ÐÒÏÈÏÄÑÝÉÊ ÞÅÒÅÚ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ +ÔÏÞÅË, ÇÄÅ $t=0$ × ÐÅÒ×ÏÊ ÔÏÞËÅ, $t=1$ × ÓÌÅÄÕÀÝÅÊ, $t=2$ × ÓÌÅÄÕÀÝÅÊ É Ô.~Ä. +%%In other words, when a path is +%%specified as passing through a sequence of points, where $t=0$ at the +%%first point, then $t=1$ at the next, and $t=2$ at the next, etc. +òÅÚÕÌØÔÁÔÏÍ +$$ \hbox{\tt a intersectiontimes b} $$ +ÂÕÄÅÔ $(-1,-1)$, ÅÓÌÉ ÐÅÒÅÓÅÞÅÎÉÑ ÎÅÔ; × ÐÒÏÔÉ×ÎÏÍ ÓÌÕÞÁÅ, ×Ù ÐÏÌÕÞÉÔÅ +ÐÁÒÕ $(t_a,t_b)$, ÇÄÅ $t_a$ --- ÜÔÏ ×ÒÅÍÑ ÎÁ ÐÕÔÉ {\tt a}, ËÏÇÄÁ ÏÎ +ÐÅÒÅÓÅËÁÅÔ ÐÕÔØ~{\tt b}, É $t_b$ --- ÜÔÏ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÅ ×ÒÅÍÑ ÎÁ +ÐÕÔÉ~{\tt b}. +%%The result of +%%$$ \hbox{\tt a intersectiontimes b} $$ +%%is $(-1,-1)$ if there is no intersection; otherwise you get +%%a pair $(t_a,t_b)$, where $t_a$ is a time on path {\tt a} when it intersects +%%path~{\tt b}, and $t_b$ is the corresponding time on path~{\tt b}. +îÁÐÒÉÍÅÒ, ÐÒÅÄÐÏÌÏÖÉÍ, ÞÔÏ ÐÕÔØ~{\tt a} ÏÂÏÚÎÁÞÅÎ ÔÏÎËÏÊ ÌÉÎÉÅÊ ÎÁ +ÒÉÓ.~\ref{fig24} É ÐÕÔØ~{\tt b} ÏÂÏÚÎÁÞÅÎ ÂÏÌÅÅ ÔÏÌÓÔÏÊ ÌÉÎÉÅÊ. +%%For example, suppose path~{\tt a} is denoted by the thin line in +%%Figure~\ref{fig24} and path~{\tt b} is denoted by the thicker line. +åÓÌÉ ÍÅÔËÉ ÐÏËÁÚÙ×ÁÀÔ ÚÎÁÞÅÎÉÑ ×ÒÅÍÅÎÉ ÎÁ ÐÕÔÑÈ, ÔÏ ÐÁÒÁ ÚÎÁÞÅÎÉÊ ×ÒÅÍÅÎÉ, +×ÙÞÉÓÌÅÎÎÁÑ × +$$ \hbox{\tt a intersectiontimes b} $$ +ÄÏÌÖÎÁ ÂÙÔØ ÏÄÎÏÊ ÉÚ +$$ (0.25,1.77),\ (0.75,1.40) {\rm ÉÌÉ}\ (2.58,0.24) $$ +É ËÁËÁÑ ÉÚ ÔÒÅÈ ÂÕÄÅÔ ×ÙÂÒÁÎÁ ÚÁ×ÉÓÉÔ ÏÔ ÉÎÔÅÒÐÒÅÔÁÔÏÒÁ MetaPost. +%%If +%%the labels indicate time values on the paths, the pair of time values +%%computed by +%%$$ \hbox{\tt a intersectiontimes b} $$ +%%must be one of +%%$$ (0.25,1.77),\ (0.75,1.40), {\rm or}\ (2.58,0.24), $$ +%%depending on which of the three intersection points is chosen by the +%%MetaPost interpreter. +ôÏÞÎÏÅ ÐÒÁ×ÉÌÏ ×ÙÂÏÒÁ ÉÚ ÍÎÏÇÉÈ ÔÏÞÅË ÐÅÒÅÓÅÞÅÎÉÑ ÎÅÓËÏÌØËÏ ÓÌÏÖÎÏ×ÁÔÏÅ, ÎÏ +× ÄÁÎÎÏÍ ÐÒÉÍÅÒÅ ×Ù ÐÏÌÕÞÉÔÅ $(0.25,1.77)$. +%%The exact rules for choosing among multiple +%%intersection points are a little complicated, but it turns out that you +%%get the time values $(0.25,1.77)$ in this example. +íÅÎØÛÉÅ ÚÎÁÞÅÎÉÑ ×ÒÅÍÅÎÉ ÐÒÅÄÐÏÞÔÉÔÅÌØÎÅÅ ÂÏÌØÛÉÈ, ÔÁË ÞÔÏ $(t_a,t_b)$ +ÐÒÅÄÐÏÞÔÉÔÅÌØÎÅÅ, ÞÅÍ $(t'_a,t'_b)$ ÐÏËÁ $t_a<t'_a$ É $t_b<t'_b$. +%%Smaller time values +%%are preferred over larger ones so that $(t_a,t_b)$ is preferred to +%%$(t'_a,t'_b)$ whenever $t_a<t'_a$ and $t_b<t'_b$. +ëÏÇÄÁ ÎÅÔ ÐÒÏÓÔÏÇÏ ÓÐÏÓÏÂÁ ÍÉÎÉÍÉÚÉÒÏ×ÁÔØ ÏÂÅ ËÏÍÐÏÎÅÎÔÙ $t_a$ É $t_b$, +$t_a$ ÐÏÌÕÞÁÅÔ ÂÏÌØÛÉÊ ÐÒÉÏÒÉÔÅÔ, ÎÏ ÐÒÁ×ÉÌÁ ÓÔÁÎÏ×ÑÔÓÑ ÂÏÌÅÅ ÓÌÏÖÎÙÍÉ, +ËÏÇÄÁ ÍÅÖÄÕ $t_a$ É $t'_a$\index{ÐÅÒÅÓÅÞÅÎÉÅ} ÎÅÔ ÃÅÌÙÈ ÞÉÓÅÌ. +%%When no single +%%alternative minimizes both the $t_a$ and $t_b$ components the $t_a$ +%%component tends to get priority, but the rules get more complicated when +%%there are no integers between $t_a$ and $t'_a$\index{intersection}. +(âÏÌØÛÅ ÄÅÔÁÌÅÊ ÓÍ. × {\sl The \MF book} \cite[Chapter 14]{kn:c}). +%%(For more details, see {\sl The \MF book} \cite[Chapter 14]{kn:c}). + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-25} $$ +\caption{ä×Á ÐÅÒÅÓÅËÁÀÝÉÈÓÑ ÐÕÔÉ Ó ÏÔÍÅÔËÁÍÉ ÚÎÁÞÅÎÉÊ ×ÒÅÍÅÎÉ ÎÁ ËÁÖÄÏÍ.} +%%\caption{Two intersecting paths with time values marked on each path.} +\label{fig24} +\end{figure} + +ïÐÅÒÁÔÏÒ {\tt intersectiontimes} ÂÏÌÅÅ ÇÉÂËÉÊ, ÞÅÍ {\tt +intersectionpoint}, ÐÏÔÏÍÕ ÞÔÏ ÓÕÝÅÓÔ×ÕÅÔ ÍÎÏÇÏ ×ÓÅÇÏ, ÞÔÏ ÍÏÖÎÏ ÓÄÅÌÁÔØ +ÓÏ ÚÎÁÞÅÎÉÑÍÉ ×ÒÅÍÅÎÉ ÎÁ ÐÕÔÉ. +%%The {\tt intersectiontimes} operator is more flexible than {\tt +%%intersectionpoint} because there are a number of things that can be done +%%with time values on a path. +ïÄÎÏ ÉÚ ÓÁÍÙÈ ×ÁÖÎÙÈ --- ÜÔÏ ÚÁÄÁÔØ ×ÏÐÒÏÓ: ``çÄÅ ÐÒÏÈÏÄÉÔ ÐÕÔØ {\tt p} ×Ï +×ÒÅÍÑ {\tt t}?'' +%%One of the most important is just to ask +%%``where is path {\tt p} at time {\tt t}?'' +ëÏÎÓÔÒÕËÃÉÑ\index{point +of?\texttt{point of}}\label{Dpntof} +$$ {\tt point}\, \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\, {\tt of}\, \descr{ÐÕÔØ-ÐÅÒ×ÉÞÎÏÓÔØ} $$ +ÏÔ×ÅÞÁÅÔ ÎÁ ÜÔÏÔ ×ÏÐÒÏÓ. +%%The construction\index{point +%%of?\texttt{point of}}\label{Dpntof} +%%$$ {\tt point}\, \descr{numeric expression}\, {\tt of}\, \descr{path primary} $$ +%%answers this question. +åÓÌÉ \tdescr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} ÍÅÎØÛÅ ÎÕÌÑ ÉÌÉ ÂÏÌØÛÅ +ÚÎÁÞÅÎÉÑ ×ÒÅÍÅÎÉ, ÐÒÉÓ×ÏÅÎÎÏÇÏ ÐÏÓÌÅÄÎÅÊ ÔÏÞËÅ ÎÁ ÐÕÔÉ, ÔÏ +ËÏÎÓÔÒÕËÃÉÑ {\tt point of} ÏÂÙÞÎÏ ×ÏÚ×ÒÁÝÁÅÔ ÐÏÓÌÅÄÎÀÀ ÔÏÞËÕ ÐÕÔÉ. +%%If the \tdescr{numeric expression} is less than +%%zero or greater than the time value assigned to the last point on the +%%path, the {\tt point of} construction normally yields an endpoint of the +%%path. +ðÏÜÔÏÍÕ ÐÒÉÎÑÔÏ ÉÓÐÏÌØÚÏ×ÁÔØ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÕÀ ËÏÎÓÔÁÎÔÕ {\tt +infinity}\index{infinity?\texttt{infinity}}\label{Dinf} (ÒÁ×ÎÕÀ +4095.99998) ËÁË \tdescr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} × ËÏÎÓÔÒÕËÃÉÉ {\tt point of}, +ËÏÇÄÁ ÉÍÅÅÍ ÄÅÌÏ Ó ËÏÎÃÏÍ ÐÕÔÉ. +%%Hence, it is common to use the predefined constant {\tt +%%infinity}\index{infinity?\texttt{infinity}}\label{Dinf} (equal to +%%4095.99998) as the \tdescr{numeric expression} in a {\tt point of} +%%construction when dealing with the end of a path. + +ôÁËÏÅ ``ÂÅÓËÏÎÅÞÎÏÅ'' ÚÎÁÞÅÎÉÅ ×ÒÅÍÅÎÉ ÎÅ ÒÁÂÏÔÁÅÔ ÄÌÑ ÃÉËÌÉÞÅÓËÏÇÏ ÐÕÔÉ, +Ô.~Ë. ÚÎÁÞÅÎÉÑ ×ÒÅÍÅÎÉ, ×ÙÈÏÄÑÝÉÅ ÚÁ ÎÏÒÍÁÌØÎÙÊ ÄÉÁÐÁÚÏÎ, ÍÏÇÕÔ × ÜÔÏÍ +ÓÌÕÞÁÅ ÏÂÒÁÂÁÔÙ×ÁÔØÓÑ ÍÏÄÕÌØÎÏÊ ÁÒÉÆÍÅÔÉËÏÊ, Ô.~Å. ÄÌÑ ÃÉËÌÉÞÅÓËÏÇÏ ÐÕÔÉ~{\tt p} +ÞÅÒÅÚ ÔÏÞËÉ $z_0$, $z_1$, $z_2$, \ldots, $z_{n-1}$ Ó ÏÂÙÞÎÙÍ +ÄÉÁÐÁÚÏÎÏÍ ÐÁÒÁÍÅÔÒÏ× $0\leqslant t<n$, +$$ \hbox{\tt point t of p} $$ +ÍÏÖÅÔ ÂÙÔØ ×ÙÞÉÓÌÅÎÏ ÄÌÑ ÌÀÂÏÇÏ~$t$ ÐÒÅÄ×ÁÒÉÔÅÌØÎÙÍ ×ÚÑÔÉÅÍ $t$ ÐÏ ÍÏÄÕÌÀ~$n$. +%%Such ``infinite'' time values do not work for a cyclic path, since time +%%values outside of the normal range can be handled by modular arithmetic +%%in that case; i.e., a cyclic path~{\tt p} through points $z_0$, $z_1$, +%%$z_2$, \ldots, $z_{n-1}$ has the normal parameter range $0\le t<n$, but +%%$$ \hbox{\tt point t of p} $$ +%%can be computed for any~$t$ by first reducing $t$ modulo~$n$. +åÓÌÉ ÍÏÄÕÌØ $n$ ÎÅÄÏÓÔÕÐÅÎ, ÔÏ\index{length?\texttt{length}}\label{Dlength} +$$ {\tt length}\, \descr{ÐÕÔØ-ÐÅÒ×ÉÞÎÏÓÔØ} $$ +ÄÁÅÔ ÃÅÌÏÅ ÚÎÁÞÅÎÉÅ ×ÅÒÈÎÅÇÏ ÐÒÅÄÅÌÁ ÎÏÒÍÁÌØÎÏÇÏ ÄÉÁÐÁÚÏÎÁ ÐÁÒÁÍÅÔÒÁ-×ÒÅÍÅÎÉ +ÄÌÑ ÚÁÄÁÎÎÏÇÏ ÐÕÔÉ. +%%If the +%%modulus~$n$ is not readily +%%available,\index{length?\texttt{length}}\label{Dlength} +%%$$ {\tt length}\, \descr{path primary} $$ +%%gives the integer value of the upper limit of the normal time parameter +%%range for the specified path. + +MetaPost ÉÓÐÏÌØÚÕÅÔ ÔÁËÉÅ ÖÅ ÓÏÏÔ×ÅÔÓÔ×ÉÑ ÍÅÖÄÕ ÚÎÁÞÅÎÉÑÍÉ ×ÒÅÍÅÎÉ +É ÔÏÞËÁÍÉ ÎÁ ÐÕÔÉ ÐÒÉ ×ÙÞÉÓÌÅÎÉÉ ÏÐÅÒÁÔÏÒÁ {\tt +subpath}\index{subpath?\texttt{subpath}}\label{Dsubpth}. +%%MetaPost uses the same correspondence between time values and points on +%%a path to evaluate the {\tt +%%subpath}\index{subpath?\texttt{subpath}}\label{Dsubpth} operator. +óÉÎÔÁËÓÉÓ ÜÔÏÇÏ ÏÐÅÒÁÔÏÒÁ +$$ {\tt subpath}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\, {\tt of}\, \descr{ÐÕÔØ-ÐÅÒ×ÉÞÎÏÓÔØ} $$ +%%The syntax for this operator is +%%$$ {\tt subpath}\, \descr{pair expression}\, {\tt of}\, \descr{path primary} $$ +åÓÌÉ ÚÎÁÞÅÎÉÅ \tdescr{×ÙÒÁÖÅÎÉÑ-ÐÁÒÙ} ÂÕÄÅÔ $(t_1,t_2)$ É +\tdescr{ÐÕÔØ-ÐÅÒ×ÉÞÎÏÓÔØ} --- ÜÔÏ $p$, ÔÏ ÒÅÚÕÌØÔÁÔ ÂÕÄÅÔ ÐÕÔÅÍ, ÞÔÏ +ÓÌÅÄÕÅÔ ËÁË É $p$ ÏÔ {\tt point $t_1$ of $p$} ÄÏ {\tt point $t_2$ of $p$}. +%%If the value of the \tdescr{pair expression} is $(t_1,t_2)$ and the +%%\tdescr{path primary} is $p$, the result is a path that follows $p$ from +%%{\tt point $t_1$ of $p$} to {\tt point $t_2$ of $p$}. +åÓÌÉ $t_2<t_1$, ÔÏ ÐÏÄÐÕÔØ ÉÄÅÔ ÏÂÒÁÔÎÏ ×ÄÏÌØ~$p$. +%%If $t_2<t_1$, the subpath runs backwards along~$p$. + +÷ÁÖÎÙÊ ÏÐÅÒÁÔÏÒ, ÏÓÎÏ×ÁÎÎÙÊ ÎÁ ÏÐÅÒÁÔÏÒÅ {\tt subpath}, --- ÜÔÏ +\tdescr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}\index{ÔÒÅÔÉÞÎÙÊ binop?\tdescr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}} +{\tt cutbefore}\index{cutbefore?\texttt{cutbefore}}\label{Dcutb}. +%%An important operation based on the {\tt subpath} operator is the +%%\tdescr{tertiary binop}\index{tertiary binop?\tdescr{tertiary binop}} +%%{\tt cutbefore}\index{cutbefore?\texttt{cutbefore}}\label{Dcutb}. +äÌÑ ÐÅÒÅÓÅËÁÀÝÉÈÓÑ ÐÕÔÅÊ $p_1$ É $p_2$, +$$ p_1\ {\tt cutbefore}\ p_2 $$ +ÜË×É×ÁÌÅÎÔÎÏ +$$ \hbox{\tt subpath (xpart($p_1$ intersectiontimes $p_2$), length $p_1$) of $p_1$} +$$ +Ó ÔÅÍ ÉÓËÌÀÞÅÎÉÅÍ, ÞÔÏ ÏÎ ÔÁËÖÅ ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ ÐÅÒÅÍÅÎÎÕÀ-ÐÕÔØ {\tt +cuttings}\index{cuttings?\texttt{cuttings}}\label{Dcuttings} × ÞÁÓÔØ +$p_1$, ÞÔÏ ÏÔÂÒÁÓÙ×ÁÅÔÓÑ. +%%For intersecting paths $p_1$ and $p_2$, +%%$$ p_1\ {\tt cutbefore}\ p_2 $$ +%%is equivalent to +%%$$ \hbox{\tt subpath (xpart($p_1$ intersectiontimes $p_2$), length $p_1$) of $p_1$} +%%$$ +%%except that it also sets the path variable {\tt +%%cuttings}\index{cuttings?\texttt{cuttings}}\label{Dcuttings} to the +%%portion of $p_1$ that gets cut off. +äÒÕÇÉÍÉ ÓÌÏ×ÁÍÉ, {\tt cutbefore} ×ÏÚ×ÒÁÝÁÅÔ Ó×ÏÊ ÐÅÒ×ÙÊ ÁÒÇÕÍÅÎÔ ÂÅÚ +ÞÁÓÔÉ ÄÏ ÐÅÒÅÓÅÞÅÎÉÑ. +%%In other words, {\tt cutbefore} +%%returns its first argument with the part before the intersection cut +%%off. +ðÒÉ ÍÎÏÖÅÓÔ×ÅÎÎÙÈ ÐÅÒÅÓÅÞÅÎÉÑÈ ÏÎ ÐÙÔÁÅÔÓÑ ÏÔÂÒÏÓÉÔØ ÎÁÉÍÅÎØÛÕÀ ÞÁÓÔØ. +%%With multiple intersections, it tries to cut off as little as +%%possible. +åÓÌÉ ÐÕÔÉ ÎÅ ÐÅÒÅÓÅËÁÀÔÓÑ, ÔÏ {\tt cutbefore} ×ÏÚ×ÒÁÝÁÅÔ Ó×ÏÊ ÐÅÒ×ÙÊ +ÁÒÇÕÍÅÎÔ. +%%If the paths do not intersect, {\tt cutbefore} returns its +%%first argument. + +åÓÔØ ÔÁËÖÅ ÁÎÁÌÏÇÉÞÎÙÊ \tdescr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}\index{ÔÒÅÔÉÞÎÙÊ +binop?\tdescr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}, ÎÁÚÙ×ÁÅÍÙÊ {\tt +cutafter}\index{cutafter?\texttt{cutafter}}\label{Dcuta}, ËÏÔÏÒÙÊ ÒÁÂÏÔÁÅÔ +ÐÒÉÍÅÎÅÎÉÅÍ {\tt cutbefore} Ó ÉÎ×ÅÒÔÉÒÏ×ÁÎÎÙÍ ×ÒÅÍÅÎÅÍ ×ÄÏÌØ Ó×ÏÅÇÏ ÐÅÒ×ÏÇÏ +ÁÒÇÕÍÅÎÔÁ. +%%There is also an analogous \tdescr{tertiary binop}\index{tertiary +%%binop?\tdescr{tertiary binop}} called {\tt +%%cutafter}\index{cutafter?\texttt{cutafter}}\label{Dcuta} that works by +%%applying {\tt cutbefore} with time reversed along its first argument. +ôÁËÉÍ ÏÂÒÁÚÏÍ, +$$ p_1\ {\tt cutafter}\ p_2 $$ +ÐÙÔÁÅÔÓÑ ÏÔÒÅÚÁÔØ ÞÁÓÔØ $p_1$ ÐÏÓÌÅ ÐÏÓÌÅÄÎÅÇÏ ÐÅÒÅÓÅÞÅÎÉÑ Ó $p_2$. +%%Thus +%%$$ p_1\ {\tt cutafter}\ p_2 $$ +%%tries to cut off the part of $p_1$ after its last intersection with $p_2$. + +äÒÕÇÏÊ ÏÐÅÒÁÔÏÒ\index{direction of?\texttt{direction of}}\label{Ddirof} +$$ {\tt direction}\, \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\, {\tt of}\, \descr{ÐÕÔØ-ÐÅÒ×ÉÞÎÏÓÔØ} +$$ +ÎÁÈÏÄÉÔ ×ÅËÔÏÒ × ÎÁÐÒÁ×ÌÅÎÉÉ \tdescr{ÐÕÔÉ-ÐÅÒ×ÉÞÎÏÓÔÉ}. +%%Another operator\index{direction of?\texttt{direction of}}\label{Ddirof} +%%$$ {\tt direction}\, \descr{numeric expression}\, {\tt of}\, \descr{path primary} +%%$$ +%%finds a vector in the direction of the \tdescr{path primary}. +ïÎ ÏÐÒÅÄÅÌÑÅÔÓÑ ÄÌÑ ÌÀÂÏÇÏ ×ÒÅÍÅÎÉ, ÐÏÄÏÂÎÏ ËÏÎÓÔÒÕËÃÉÉ {\tt point of}. +%%This is +%%defined for any time value analogously to the {\tt point of} +%%construction. +÷ÅËÔÏÒ-ÒÅÚÕÌØÔÁÔ ÉÍÅÅÔ ÐÒÁ×ÉÌØÎÏÅ ÎÁÐÒÁ×ÌÅÎÉÅ É ÎÅÓËÏÌØËÏ ÐÒÏÉÚ×ÏÌØÎÏÊ ÒÁÚÍÅÒ. +%%The resulting direction vector has the correct +%%orientation and a somewhat arbitrary magnitude. +óÏÅÄÉÎÅÎÉÅ ËÏÎÓÔÒÕËÃÉÊ {\tt point of} É {\tt direction of} ÄÁÅÔ ÕÒÁ×ÎÅÎÉÅ ÄÌÑ +ÌÉÎÉÉ ÔÁÎÇÅÎÓÁ, ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig25}. +%%Combining {\tt point +%%of} and {\tt direction of} constructions yields the equation for a +%%tangent line as illustrated in Figure~\ref{fig25}. + +\begin{figure}[htp] +$$ \begin{verbatim} +beginfig(26); +numeric scf, #, t[]; +3.2scf = 2.4in; +path fun; +# = .1; % Keep the function single-valued +fun = ((0,-1#)..(1,.5#){right}..(1.9,.2#){right}..{curl .1}(3.2,2#)) + yscaled(1/#) scaled scf; +x1 = 2.5scf; +for i=1 upto 2: + (t[i],whatever) = + fun intersectiontimes ((x[i],-infinity)--(x[i],infinity)); + z[i] = point t[i] of fun; + z[i]-(x[i+1],0) = whatever*direction t[i] of fun; + draw (x[i],0)--z[i]--(x[i+1],0); + fill fullcircle scaled 3bp shifted z[i]; +endfor +label.bot(btex $x_1$ etex, (x1,0)); +label.bot(btex $x_2$ etex, (x2,0)); +label.bot(btex $x_3$ etex, (x3,0)); +draw (0,0)--(3.2scf,0); +pickup pencircle scaled 1pt; +draw fun; +endfig; +\end{verbatim} +\atop \includegraphics{manfig-ru-26} +$$ +\caption{ëÏÄ MetaPost É ÒÉÓÕÎÏË-ÒÅÚÕÌØÔÁÔ} +%%\caption{MetaPost code and the resulting figure} +\label{fig25} +\end{figure} + +åÓÌÉ ×Ù ÚÎÁÅÔÅ ÕËÌÏÎ É ×Ù ÈÏÔÉÔÅ ÎÁÊÔÉ ÔÏÞËÕ ÎÁ ËÒÉ×ÏÊ Ó ÔÁÎÇÅÎÓÏÍ, ÒÁ×ÎÙÍ +ÜÔÏÍÕ ÕËÌÏÎÕ, ÔÏ ÎÕÖÅÎ ÏÐÅÒÁÔÏÒ {\tt directiontime}\index{directiontime +of?\texttt{directiontime of}}\label{Ddtimof} --- ÏÂÒÁÔÎÙÊ Ë +{\tt direction of}. +%%If you know a slope and you want to find a point on a curve where the +%%tangent line has that slope, the {\tt directiontime}\index{directiontime +%%of?\texttt{directiontime of}}\label{Ddtimof} operator inverts the {\tt +%%direction of} operation. +C ÄÁÎÎÙÍÉ ×ÅËÔÏÒÏÍ-ÕËÌÏÎÏÍ É ÐÕÔÅÍ +$$ {\tt directiontime}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\, {\tt of}\, + \descr{ÐÕÔØ-ÐÅÒ×ÉÞÎÏÓÔØ} +$$ +×ÏÚ×ÒÁÝÁÅÔ ÞÉÓÌÏ×ÏÅ ÚÎÁÞÅÎÉÅ, ÞÔÏ ÄÁÅÔ ÐÅÒ×ÏÅ ×ÒÅÍÑ~$t$, ËÏÇÄÁ ÐÕÔØ ÉÍÅÅÔ +ÚÁÄÁÎÎÏÅ ÎÁÐÒÁ×ÌÅÎÉÅ. +%%Given a direction vector and a path, +%%$$ {\tt directiontime}\, \descr{pair expression}\, {\tt of}\, +%% \descr{path primary} +%%$$ +%%returns a numeric value that gives the first time~$t$ when the path has +%%the indicated direction. +(åÓÌÉ ÔÁËÏÇÏ ×ÒÅÍÅÎÉ ÎÅÔ, ÔÏ ÒÅÚÕÌØÔÁÔ ÂÕÄÅÔ $-1$.) +%%(If there is no such time, the result is +%%$-1$). +îÁÐÒÉÍÅÒ, ÅÓÌÉ {\tt a} --- ÜÔÏ ÐÕÔØ, ÎÁÒÉÓÏ×ÁÎÎÙÊ ÔÏÎËÏÊ ËÒÉ×ÏÊ ÎÁ +ÒÉÓ.~\ref{fig24}, ÔÏ {\tt directiontime (1,1) of a} ×ÏÚ×ÒÁÝÁÅÔ 0.2084. +%%For example, if {\tt a} is the path drawn as a thin curve in +%%Figure~\ref{fig24}, {\tt directiontime (1,1) of a} returns 0.2084. + +åÓÔØ ÅÝÅ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ \index{directionpoint +of?\texttt{directionpoint of}}\label{Ddpntof} +$$ {\tt directionpoint}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\, {\tt of}\, + \descr{ÐÕÔØ-ÐÅÒ×ÉÞÎÏÓÔØ}, +$$ +ËÏÔÏÒÙÊ ÎÁÈÏÄÉÔ ÐÅÒ×ÕÀ ÔÏÞËÕ ÎÁ ÐÕÔÉ, ÇÄÅ ÅÓÔØ ÄÁÎÎÏÅ ÎÁÐÒÁ×ÌÅÎÉÅ. +%%There is also an predefined macro \index{directionpoint +%%of?\texttt{directionpoint of}}\label{Ddpntof} +%%$$ {\tt directionpoint}\, \descr{pair expression}\, {\tt of}\, +%% \descr{path primary} +%%$$ +%%that finds the first point on a path where a given direction is achieved. +íÁËÒÏÓ {\tt directionpoint} ÐÒÏÉÚ×ÏÄÉÔ ÓÏÏÂÝÅÎÉÅ Ï ÏÛÉÂËÅ, ÅÓÌÉ ÉÓËÏÍÏÅ +ÎÁÐÒÁ×ÌÅÎÉÅ ÏÔÓÕÔÓÔ×ÕÅÔ ÎÁ ÐÕÔÉ. +%%The +%%{\tt directionpoint} macro produces an error message if the direction does not +%%occur on the path. + +ïÐÅÒÁÔÏÒÙ {\tt +arclength}\index{arclength?\texttt{arclength}}\label{Darclng} É {\tt +arctime of}\index{arctime of?\texttt{arctime of}}\label{Darctim} ÏÔÎÏÓÑÔÓÑ +Ë ``×ÒÅÍÅÎÉ'' ÎÁ ÐÕÔÉ ÂÏÌÅÅ ÚÎÁËÏÍÙÍ ÏÂÒÁÚÏÍ, ÉÓÐÏÌØÚÕÑ ÐÏÎÑÔÉÅ ÄÌÉÎÙ +ÄÕÇÉ.\index{ÄÌÉÎÁ ÄÕÇÉ}\footnote{ïÐÅÒÁÔÏÒÙ {\tt arclength} É {\tt arctime} +ÄÏÓÔÕÐÎÙ ÔÏÌØËÏ × MetaPost ×ÅÒÓÉÉ 0.50 É ÎÏ×ÅÅ.} +%%Operators {\tt +%%arclength}\index{arclength?\texttt{arclength}}\label{Darclng} and {\tt +%%arctime of}\index{arctime of?\texttt{arctime of}}\label{Darctim} relate +%%the ``time'' on a path to the more familiar concept of arc +%%length.\index{arc length}\footnote{The {\tt arclength} and {\tt arctime} +%%operators are only found in MetaPost version 0.50 and higher.} +÷ÙÒÁÖÅÎÉÅ +$$ \hbox{{\tt arclength} \tdescr{ÐÕÔØ-ÐÅÒ×ÉÞÎÏÓÔØ}} $$ +×ÙÄÁÅÔ ÄÌÉÎÕ ÄÕÇÉ ÐÕÔÉ. +%%The expression +%%$$ \hbox{{\tt arclength} \tdescr{path primary}} $$ +%%gives the arc length of a path. +åÓÌÉ {\tt p} --- ÜÔÏ ÐÕÔØ É {\tt a} --- ÞÉÓÌÏ ÍÅÖÄÕ 0 É {\tt arclength p}, ÔÏ +$$ \hbox{\tt arctime a of p} $$ +ÄÁÅÔ ×ÒÅÍÑ~{\tt t}, ÔÁËÏÅ ÞÔÏ +$$ \hbox{\tt arclength subpath (0,t) of p} = {\tt a}. $$ +%%If {\tt p} is a path and {\tt a} is a number +%%between 0 and {\tt arclength p}, +%%$$ \hbox{\tt arctime a of p} $$ +%%gives the time~{\tt t} such that +%%$$ \hbox{\tt arclength subpath (0,t) of p} = {\tt a}. $$ + +\subsection{áÆÆÉÎÎÙÅ ÔÒÁÎÓÆÏÒÍÁÃÉÉ} +%%\subsection{Affine Transformations} +\label{transsec} +\index{ÔÉÐ-ÔÒÁÎÓÆÏÒÍÁÃÉÑ} +%%\index{transform type} + +úÁÍÅÔØÔÅ, ÞÔÏ ÐÕÔØ {\tt fun} ÎÁ ÒÉÓ.~\ref{fig25} ÓÎÁÞÁÌÁ ËÏÎÓÔÒÕÉÒÕÅÔÓÑ ËÁË +$$ \hbox{\verb|(0,-.1)..(1,.05){right}..(1.9,.02){right}..{curl .1}(3.2,.2)|} $$ +É ÚÁÔÅÍ ÉÓÐÏÌØÚÕÀÔÓÑ ÏÐÅÒÁÔÏÒÙ {\tt yscaled}\index{yscaled?\texttt{yscaled}} +É {\tt scaled}\index{scaled?\texttt{scaled}} ÄÌÑ ÎÁÓÔÒÏÊËÉ ÆÏÒÍÙ É ÒÁÚÍÅÒÁ +ÐÕÔÉ. +%%Note how path {\tt fun} in Figure~\ref{fig25} is first constructed as +%%$$ \hbox{\verb|(0,-.1)..(1,.05){right}..(1.9,.02){right}..{curl .1}(3.2,.2)|} $$ +%%and then the {\tt yscaled}\index{yscaled?\texttt{yscaled}} and {\tt +%%scaled}\index{scaled?\texttt{scaled}} operators are used to adjust the +%%shape and size of the path. +ëÁË ÐÏÄÓËÁÚÙ×ÁÅÔ ÎÁÚ×ÁÎÉÅ, ×ÙÒÁÖÅÎÉÅ Ó ``{\tt yscaled 10}'' ÕÍÎÏÖÁÅÔ +ËÏÏÒÄÉÎÁÔÙ $y$ ÎÁ ÄÅÓÑÔØ ÔÁË, ÞÔÏ ËÁÖÄÁÑ ÔÏÞËÁ $(x,y)$ ÉÓÈÏÄÎÏÇÏ ÐÕÔÉ +ÂÕÄÅÔ ÓÏÏÔ×ÅÔÓÔ×Ï×ÁÔØ ÔÏÞËÅ $(x,10y)$ ÎÁ ÔÒÁÎÓÆÏÒÍÉÒÏ×ÁÎÎÏÍ ÐÕÔÉ. +%%As the name suggests, an expression +%%involving ``{\tt yscaled 10}'' multiplies $y$ coordinates by ten so that +%%every point $(x,y)$ on the original path corresponds to a point +%%$(x,10y)$ on the transformed path. + +÷ÍÅÓÔÅ Ó {\tt scaled} É {\tt yscaled} ÓÕÝÅÓÔ×ÕÅÔ ÓÅÍØ ÏÐÅÒÁÔÏÒÏ× +ÔÒÁÎÓÆÏÒÍÁÃÉÉ Ó ÁÒÇÕÍÅÎÔÏÍ ÞÉÓÌÏÍ ÉÌÉ ÐÁÒÏÊ :\index{shifted?\texttt{shifted}}% +\index{rotated?\texttt{rotated}}\index{slanted?\texttt{slanted}}\index{scaled?\texttt{scaled}}\index{xscaled?\texttt{xscaled}}% +\index{yscaled?\texttt{yscaled}}\index{zscaled?\texttt{zscaled}}\label{Dtranop} +%%Including {\tt scaled} and {\tt yscaled}, there are seven transformation +%%operators that take a numeric or pair +%%argument:\index{shifted?\texttt{shifted}}% +%%\index{rotated?\texttt{rotated}}\index{slanted?\texttt{slanted}}\index{scaled?\texttt{%%scaled}}\index{xscaled?\texttt{xscaled}}% +%%\index{yscaled?\texttt{yscaled}}\index{zscaled?\texttt{zscaled}}\label{Dtranop} +\begin{eqnarray*} + (x,y){\tt\ shifted\ }(a,b) &=& (x+a,\, y+b); \\ + (x,y){\tt\ rotated\ }\theta &=& (x\cos\theta-y\sin\theta,\, + x\sin\theta+y\cos\theta); \\ + (x,y){\tt\ slanted\ }a &=& (x+ay,\, y); \\ + (x,y){\tt\ scaled\ }a &=& (ax,\, ay); \\ + (x,y){\tt\ xscaled\ }a &=& (ax,\, y); \\ + (x,y){\tt\ yscaled\ }a &=& (x,\, ay); \\ + (x,y){\tt\ zscaled\ }(a,b) &=& (ax-by,\, bx+ay). +\end{eqnarray*} +âÏÌØÛÉÎÓÔ×Ï ÜÔÉÈ ÏÐÅÒÁÔÏÒÏ× ÏÂßÑÓÎÑÀÔ ÓÁÍÉ ÓÅÂÑ, ÚÁ ÉÓËÌÀÞÅÎÉÅÍ +{\tt zscaled}, Ï ËÏÔÏÒÏÍ ÍÏÖÎÏ ÄÕÍÁÔØ ËÁË Ï ÐÒÏÉÚ×ÅÄÅÎÉÉ ËÏÍÐÌÅËÓÎÙÈ ÞÉÓÅÌ. +%%Most of these operations are self-explanatory except for {\tt zscaled} +%%which can be thought of as multiplication of complex numbers. +üÆÆÅËÔ {\tt zscaled} $(a,b)$ --- ÜÔÏ ÐÏ×ÏÒÏÔ É ÍÁÓÛÔÁÂÉÒÏ×ÁÎÉÅ ÔÁË, ÞÔÏ +$(1,0)$ ÐÅÒÅÈÏÄÉÔ × $(a,b)$. +%%The +%%effect of {\tt zscaled} $(a,b)$ is to rotate and scale so as to map +%%$(1,0)$ into $(a,b)$. +üÆÆÅËÔ ÏÔ {\tt rotated}~$\theta$ ×Ï ×ÒÁÝÅÎÉÉ ÎÁ $\theta$ ÇÒÁÄÕÓÏ× ÐÒÏÔÉ× +ÞÁÓÏ×ÏÊ ÓÔÒÅÌËÉ. +%%The effect of {\tt rotated}~$\theta$ is rotate +%%$\theta$ degrees counter-clockwise. + +ìÀÂÁÑ ËÏÍÂÉÎÁÃÉÑ ÓÄ×ÉÇÏ×, ×ÒÁÝÅÎÉÊ, ÎÁËÌÏÎÏ× É Ô.~Ð. --- ÜÔÏ ÁÆÆÉÎÎÁÑ +ÔÒÁÎÓÆÏÒÍÁÃÉÑ, ÓÏ×ÏËÕÐÎÙÊ ÜÆÆÅËÔ ËÏÔÏÒÏÊ × ÔÒÁÎÓÆÏÒÍÁÃÉÉ ÌÀÂÏÊ ÐÁÒÙ +$(x,y)$ × +$$ (t_x+t_{xx}x+t_{xy}y,\, t_y+t_{yx}x+t_{yy}y), $$ +ÄÌÑ ÎÅËÏÔÏÒÏÊ ÛÅÓÔÅÒËÉ $(t_x,t_y,t_{xx},t_{xy},t_{yx},t_{yy})$. +%%Any combination of shifting, rotating, slanting, etc.\ is an affine +%%transformation, the net effect of which is to transform any pair $(x,y)$ +%%into +%%$$ (t_x+t_{xx}x+t_{xy}y,\, t_y+t_{yx}x+t_{yy}y), $$ +%%for some sextuple $(t_x,t_y,t_{xx},t_{xy},t_{yx},t_{yy})$. +ðÏÓÌÅÄÎÑÑ ÉÎÆÏÒÍÁÃÉÑ ÍÏÖÅÔ ÂÙÔØ ÓÏÈÒÁÎÅÎÁ × ÐÅÒÅÍÅÎÎÏÊ ÔÉÐÁ ÔÒÁÎÓÆÏÒÍÁÃÉÑ, +ÔÁË ÞÔÏ {\tt +transformed T}\index{transformed?\texttt{transformed}}\label{Dtrfrmd} +ÍÏÖÅÔ ÂÙÔØ ÜË×É×ÁÌÅÎÔÎÏ +$$ \hbox{\tt xscaled -1 rotated 90 shifted (1,1)}, $$ +ÅÓÌÉ {\tt T} --- ÜÔÏ ÐÅÒÅÍÅÎÎÁÑ-ÔÒÁÎÓÆÏÒÍÁÃÉÑ. +%%This +%%information can be stored in a variable of type transform so that {\tt +%%transformed T}\index{transformed?\texttt{transformed}}\label{Dtrfrmd} +%%might be equivalent to +%%$$ \hbox{\tt xscaled -1 rotated 90 shifted (1,1)} $$ +%%if {\tt T} is an appropriate transform variable. +ôÒÁÎÓÆÏÒÍÁÃÉÑ~{\tt T} ÍÏÇÌÁ ÂÙÔØ ÉÎÉÃÉÁÌÉÚÉÒÏ×ÁÎÁ ×ÙÒÁÖÅÎÉÅÍ ÔÉÐÁ +ÔÒÁÎÓÆÏÒÍÁÃÉÑ, ÎÁÐÒÉÍÅÒ, +%%The transform~{\tt T} could then be initialized with an +%%expression of type transform as follows: +$$ \begin{verbatim} +transform T; +T = identity xscaled -1 rotated 90 shifted (1,1); +\end{verbatim} +$$ +üÔÏÔ ÐÒÉÍÅÒ ÐÏËÁÚÙ×ÁÅÔ, ÞÔÏ ×ÙÒÁÖÅÎÉÑ-ÔÒÁÎÓÆÏÒÍÁÃÉÉ ÍÏÇÕÔ ÓÔÒÏÉÔØÓÑ +ÐÒÉÍÅÎÅÎÉÅÍ ÔÒÁÎÓÆÏÒÍÁÃÉÏÎÎÙÈ ÏÐÅÒÁÔÏÒÏ× Ë ÄÒÕÇÉÍ ÔÒÁÎÓÆÏÒÍÁÃÉÑÍ. +%%As this example indicates, transform expressions can be built up by +%%applying transformation operators to other transforms. +óÔÁÎÄÁÒÔÎÁÑ ÔÒÁÎÓÆÏÒÍÁÃÉÑ {\tt +identity}\index{identity?\texttt{identity}}\label{Dident} --- ÜÔÏ ÐÏÌÅÚÎÁÑ +ÏÔÐÒÁ×ÎÁÑ ÔÏÞËÁ ÄÌÑ ÜÔÏÇÏ ÐÒÏÃÅÓÓÁ. +%%The predefined transformation {\tt +%%identity}\index{identity?\texttt{identity}}\label{Dident} is a useful +%%starting point for this process. +÷ÓÅ ÍÏÖÎÏ ÐÒÏÉÌÌÀÓÔÒÉÒÏ×ÁÔØ ÐÅÒÅ×ÏÄÏÍ ÕÒÁ×ÎÅÎÉÑ ×ÙÛÅ ÎÁ ÅÓÔÅÓÔ×ÅÎÎÙÊ ÑÚÙË: +``{\tt T} ÓÌÅÄÕÅÔ ÂÙÔØ ÔÒÁÎÓÆÏÒÍÁÃÉÅÊ, ÔÁËÏÊ ÖÅ ËÁË {\tt identity}, ÚÁÔÅÍ +ÍÁÓÛÔÁÂÉÒÏ×ÁÎÎÏÊ ÐÏ ËÏÏÒÄÉÎÁÔÁÍ $x$ × $-1$ ÒÁÚ, ×ÒÁÝÅÎÎÏÊ ÎÁ +$90^\circ$ É ÓÄ×ÉÎÕÔÏÊ ÎÁ $(1,1)$.'' +%%This can be illustrated by +%%paraphrasing the above equation for {\tt T} into English: ``{\tt T} +%%should be the transform obtained by doing whatever {\tt identity} +%%does. +%%Then scaling $x$~coordinates by $-1$, rotating $45^\circ$, and +%%shifting by $(1,1)$.'' +üÔÏ ÒÁÂÏÔÁÅÔ, ÐÏÔÏÍÕ ÞÔÏ {\tt identity} --- ÔÏÖÄÅÓÔ×ÅÎÎÁÑ ÔÒÁÎÓÆÏÒÍÁÃÉÑ, +ËÏÔÏÒÁÑ ÎÉÞÅÇÏ ÎÅ ÄÅÌÁÅÔ, Ô.~Å. {\tt transformed identity} --- ÜÔÏ ÐÕÓÔÏÊ +ÏÐÅÒÁÔÏÒ. +%%This works because {\tt identity} is the +%%identity transformation which does nothing; i.e., {\tt transformed +%%identity} is a no-op. + +óÉÎÔÁËÓÉÓ ÄÌÑ ×ÙÒÁÖÅÎÉÊ-ÔÒÁÎÓÆÏÒÍÁÃÉÊ É ÏÐÅÒÁÔÏÒÏ× ÔÒÁÎÓÆÏÒÍÁÃÉÉ ÄÁÅÔÓÑ ÎÁ +ÒÉÓ.~\ref{sytrans}. +%%The syntax for transform expressions and transformation operators is given in +%%Figure~\ref{sytrans}. +ïÎ ×ËÌÀÞÁÅÔ Ä×Å ÄÏÐÏÌÎÉÔÅÌØÎÙÅ ×ÏÚÍÏÖÎÏÓÔÉ ÄÌÑ +\tdescr{ÔÒÁÎÓÆÏÒÍÁÃÉÉ}:\index{reflectedabout?\texttt{reflectedabout}} +$$ \hbox{\tt reflectedabout(}p, q\hbox{\tt )} $$ +ÏÔÒÁÖÁÅÔ ÏÔÎÏÓÉÔÅÌØÎÏ ÐÒÑÍÏÊ, ÏÐÒÅÄÅÌÑÅÍÏÊ ÔÏÞËÁÍÉ $p$ É $q$ +É\index{rotatedaround?\texttt{rotatedaround}} +$$ \hbox{\tt rotatedaround(}p,\theta\hbox{\tt )} $$ +×ÒÁÝÁÅÔ ÎÁ $\theta$ ÇÒÁÄÕÓÏ× ÐÒÏÔÉ× ÞÁÓÏ×ÏÊ ÓÔÒÅÌËÉ ×ÏËÒÕÇ ÔÏÞËÉ $p$. +%%It includes two more options for +%%\tdescr{transformer}:\index{reflectedabout?\texttt{reflectedabout}} +%%$$ \hbox{\tt reflectedabout(}p, q\hbox{\tt )} $$ +%%reflects about the line defined by points $p$ and $q$; +%%and\index{rotatedaround?\texttt{rotatedaround}} +%%$$ \hbox{\tt rotatedaround(}p,\theta\hbox{\tt )} $$ +%%rotates $\theta$ degrees counter-clockwise around point $p$. +îÁÐÒÉÍÅÒ, ÕÒÁ×ÎÅÎÉÅÍ ÄÌÑ ÉÎÉÃÉÁÌÉÚÁÃÉÉ ÔÒÁÎÓÆÏÒÍÁÃÉÉ~{\tt T} ÍÏÖÅÔ ÂÙÔØ +$$ \hbox{\tt T = identity reflectedabout((2,0), (0,2))}. $$ +%%For example, +%%the equation for initializing transform~{\tt T} could have been +%%$$ \hbox{\tt T = identity reflectedabout((2,0), (0,2))}. $$ + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{×ÔÏÒÉÞÎÁÑ ÐÁÒÁ} \rightarrow + \descr{×ÔÏÒÉÞÎÁÑ ÐÁÒÁ} \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ}$\\ +%%$\tt \descr{pair secondary} \rightarrow +%% \descr{pair secondary} \descr{transformer}$\\ +$\tt \descr{ÐÕÔØ-×ÔÏÒÉÞÎÏÓÔØ} \rightarrow + \descr{ÐÕÔØ-×ÔÏÒÉÞÎÏÓÔØ} \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ}$\\ +%%$\tt \descr{path secondary} \rightarrow +%% \descr{path secondary} \descr{transformer}$\\ +$\tt \descr{ÒÉÓÕÎÏË-×ÔÏÒÉÞÎÏÓÔØ} \rightarrow + \descr{ÒÉÓÕÎÏË-×ÔÏÒÉÞÎÏÓÔØ} \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ}$\\ +%%$\tt \descr{picture secondary} \rightarrow +%% \descr{picture secondary} \descr{transformer}$\\ +$\tt \descr{ÐÅÒÏ-×ÔÏÒÉÞÎÏÓÔØ} \rightarrow + \descr{ÐÅÒÏ-×ÔÏÒÉÞÎÏÓÔØ} \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ}$\\ +%%$\tt \descr{pen secondary} \rightarrow +%% \descr{pen secondary} \descr{transformer}$\\ +$\tt \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ-×ÔÏÒÉÞÎÏÓÔØ} \rightarrow + \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ-×ÔÏÒÉÞÎÏÓÔØ} \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ}$\\[6pt] +%%$\tt \descr{transform secondary} \rightarrow +%% \descr{transform secondary} \descr{transformer}$\\[6pt] +$\tt \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ} \rightarrow rotated \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{transformer} \rightarrow rotated \descr{numeric primary}$\\ +$\tt \qquad \;|\; scaled \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; scaled \descr{numeric primary}$\\ +$\tt \qquad \;|\; shifted \descr{ÐÅÒ×ÉÞÎÁÑ ÐÁÒÁ}$\\ +%%$\tt \qquad \;|\; shifted \descr{pair primary}$\\ +$\tt \qquad \;|\; slanted \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; slanted \descr{numeric primary}$\\ +$\tt \qquad \;|\; transformed \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ-ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; transformed \descr{transform primary}$\\ +$\tt \qquad \;|\; xscaled \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; xscaled \descr{numeric primary}$\\ +$\tt \qquad \;|\; yscaled \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; yscaled \descr{numeric primary}$\\ +$\tt \qquad \;|\; zscaled \descr{ÐÅÒ×ÉÞÎÁÑ ÐÁÒÁ}$\\ +%%$\tt \qquad \;|\; zscaled \descr{pair primary}$\\ +$\tt \qquad \;|\; reflectedabout\hbox{\tt (}\descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ} + \hbox{\tt ,}\descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; reflectedabout\hbox{\tt (}\descr{pair expression} +%% \hbox{\tt ,}\descr{pair expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; rotatedaround\hbox{\tt (}\descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ} + \hbox{\tt ,}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt )}$ +%%$\tt \qquad \;|\; rotatedaround\hbox{\tt (}\descr{pair expression} +%% \hbox{\tt ,}\descr{numeric expression}\hbox{\tt )}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ÄÌÑ ÔÒÁÎÓÆÏÒÍÁÃÉÊ É ÒÏÄÓÔ×ÅÎÎÙÈ ÏÐÅÒÁÔÏÒÏ×} +%%\caption{The syntax for transforms and related operators} +\label{sytrans} +\end{figure} + +åÓÔØ ÅÝÅ ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ Ó ÏÄÎÉÍ ÁÒÇÕÍÅÎÔÏÍ {\tt +inverse}\index{inverse?\texttt{inverse}}\label{Dinv}, ÎÁÈÏÄÑÝÉÊ +ÏÂÒÁÔÎÕÀ ÔÒÁÎÓÆÏÒÍÁÃÉÀ, ÏÔÍÅÎÑÀÝÕÀ ÜÆÆÅËÔ +ÔÒÁÎÓÆÏÒÍÁÃÉÉ-ÁÒÇÕÍÅÎÔÁ. +%%There is also a unary operator {\tt +%%inverse}\index{inverse?\texttt{inverse}}\label{Dinv} that takes a +%%transform and finds another transform that undoes the effect of the +%%first transform. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÅÓÌÉ +$$ p = q{\tt\ transformed\ }T, $$ +ÔÏ +$$ q = p{\tt\ transformed\ inverse\ }T. $$ +%%Thus if +%%$$ p = q{\tt\ transformed\ }T $$ +%%then +%%$$ q = p{\tt\ transformed\ inverse\ }T. $$ + +îÅÌØÚÑ ÂÒÁÔØ {\tt inverse} ÄÌÑ ÎÅÉÚ×ÅÓÔÎÏÊ +ÔÒÁÎÓÆÏÒÍÁÃÉÉ\index{ÔÒÁÎÓÆÏÒÍÁÃÉÑ!ÎÅÉÚ×ÅÓÔÎÁÑ}, ÎÏ ÍÙ ÕÖÅ ×ÉÄÅÌÉ, ÞÔÏ +ÍÏÖÎÏ +$$ \hbox{\tt T = } \descr{×ÙÒÁÖÅÎÉÅ-ÔÒÁÎÓÆÏÒÍÁÃÉÑ}, $$ +ËÏÇÄÁ {\tt T} ÅÝÅ ÎÅ ÉÍÅÅÔ ÚÎÁÞÅÎÉÑ. +%%It is not legal to take the {\tt inverse} of an +%%unknown transform\index{transformation!unknown} but we +%%have already seen that you can say +%%$$ \hbox{\tt T = } \descr{transform expression} $$ +%%when {\tt T} has not been given a value yet. +ôÁËÖÅ ×ÏÚÍÏÖÎÏ ÐÒÉÍÅÎÑÔØ ÎÅÉÚ×ÅÓÔÎÕÀ ÔÒÁÎÓÆÏÒÍÁÃÉÀ Ë ÉÚ×ÅÓÔÎÏÊ ÐÁÒÅ ÉÌÉ +ÔÒÁÎÓÆÏÒÍÁÃÉÉ É ÉÓÐÏÌØÚÏ×ÁÔØ ÒÅÚÕÌØÔÁÔ × ÌÉÎÅÊÎÏÍ ÕÒÁ×ÎÅÎÉÉ. +%%It is also possible to +%%apply an unknown transform to a known pair or transform and use the +%%result in a linear equation. +ôÒÉ ÔÁËÉÈ ÕÒÁ×ÎÅÎÉÑ ÄÏÓÔÁÔÏÞÎÙ ÄÌÑ ÏÐÒÅÄÅÌÅÎÉÑ ÔÒÁÎÓÆÏÒÍÁÃÉÉ. +%%Three such equations are sufficient to determine a transform. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÕÒÁ×ÎÅÎÉÑ +%%Thus the equations +$$ \begin{verbatim} +(0,1) transformed T' = (3,4); +(1,1) transformed T' = (7,1); +(1,0) transformed T' = (4,-3); +\end{verbatim} +$$ +ÐÏÚ×ÏÌÑÀÔ MetaPost ÏÐÒÅÄÅÌÉÔØ, ÞÔÏ ÔÒÁÎÓÆÏÒÍÁÃÉÑ {\tt T'} --- ÜÔÏ +ËÏÍÂÉÎÁÃÉÑ ×ÒÁÝÅÎÉÑ É ÍÁÓÛÔÁÂÉÒÏ×ÁÎÉÑ Ó +%%allow MetaPost to determine that the transform {\tt T'} is a combination of +%%rotation and scaling with +$$\openup\jot + \tabskip=0pt plus 1fil + \halign to\displaywidth{\tabskip=0pt + \hfil$\displaystyle{#}$& $\displaystyle{{}#}$\hfil \qquad& + \hfil$\displaystyle{#}$& $\displaystyle{{}#}$\hfil + \tabskip=0pt plus 1fil\cr +\noalign{\vskip-\jot} + t_{xx}&=4,& t_{yx}&=-3,\cr + t_{yx}&=3,& t_{yy}&=4,\cr + t_x&=0,& t_y&=0.\cr} +$$ + +õÒÁ×ÎÅÎÉÑ Ó ÎÅÉÚ×ÅÓÔÎÙÍÉ ÔÒÁÎÓÆÏÒÍÁÃÉÑÍÉ ÒÁÓÓÍÁÔÒÉ×ÁÀÔÓÑ ËÁË ÌÉÎÅÊÎÙÅ +ÕÒÁ×ÎÅÎÉÑ Ó ÛÅÓÔØÀ ÐÁÒÁÍÅÔÒÁÍÉ, ÏÐÒÅÄÅÌÑÀÝÉÍÉ ÔÒÁÎÓÆÏÒÍÁÃÉÀ. +%%Equations involving an unknown transform are treated as linear equations +%%in the six parameters that define the transform. +üÔÉ ÛÅÓÔØ ÐÁÒÁÍÅÔÒÏ× ÍÏÇÕÔ ÔÁËÖÅ ÉÍÅÎÏ×ÁÔØÓÑ ÎÁÐÒÑÍÕÀ +ËÁË\index{xpart?\texttt{xpart}}\index{ypart?\texttt{ypart}}\index{xxpart?\texttt{xxpart}}% +\index{xypart?\texttt{xypart}}\index{yxpart?\texttt{yxpart}}\index{yypart?\texttt{yypart}}\label{Dtrprt} +$$ {\tt xpart\ T},\ {\tt ypart\ T},\ {\tt xxpart\ T},\ {\tt xypart\ T},\ + {\tt yxpart\ T},\ {\tt yypart\ T}, +$$ +ÇÄÅ {\tt T} --- ÜÔÏ ÔÒÁÎÓÆÏÒÍÁÃÉÑ. +%%These six parameters can also be referred to directly +%%as\index{xpart?\texttt{xpart}}\index{ypart?\texttt{ypart}}\index{xxpart?\texttt{xxpart%%}}% +%%\index{xypart?\texttt{xypart}}\index{yxpart?\texttt{yxpart}}\index{yypart?\texttt{yypa%%rt}}\label{Dtrprt} +%%$$ {\tt xpart\ T},\ {\tt ypart\ T},\ {\tt xxpart\ T},\ {\tt xypart\ T},\ +%% {\tt yxpart\ T},\ {\tt yypart\ T}, +%%$$ +%%where {\tt T} is a transform. +îÁÐÒÉÍÅÒ, ÒÉÓ.~\ref{fig27} ÉÓÐÏÌØÚÕÅÔ ÕÒÁ×ÎÅÎÉÑ +$$ \hbox{\tt xxpart T=yypart T; yxpart T=-xypart T} $$ +ÄÌÑ ÕËÁÚÁÎÉÑ, ÞÔÏ {\tt T} ÓÏÈÒÁÎÑÅÔ ÆÏÒÍÕ, Ô.~Å. Ñ×ÌÑÅÔÓÑ ËÏÍÂÉÎÁÃÉÅÊ +×ÒÁÝÅÎÉÑ, ÓÄ×ÉÇÁ É ÓÏÈÒÁÎÑÀÝÅÇÏ ÆÏÒÍÕ ÍÁÓÛÔÁÂÉÒÏ×ÁÎÉÑ. +%%For instance, Figure~\ref{fig27} uses the +%%equations +%%$$ \hbox{\tt xxpart T=yypart T; yxpart T=-xypart T} $$ +%%to specify that {\tt T} is shape preserving; i.e., it is a combination of +%%rotating, shifting, and uniform scaling. + +\begin{figure}[htp] +$$\begin{verbatim} +beginfig(28); +path p[]; +p1 = fullcircle scaled .6in; +z1=(.75in,0)=-z3; +z2=directionpoint left of p1=-z4; +p2 = z1..z2..{curl1}z3..z4..{curl 1}cycle; +fill p2 withcolor .4[white,black]; +unfill p1; +draw p1; +transform T; +z1 transformed T = z2; +z3 transformed T = z4; +xxpart T=yypart T; yxpart T=-xypart T; +picture pic; +pic = currentpicture; +for i=1 upto 2: + pic:=pic transformed T; + draw pic; +endfor +dotlabels.top(1,2,3); dotlabels.bot(4); +endfig; +\end{verbatim} +\quad \mathcenter{\includegraphics{manfig-ru-28}} +$$ +\caption{ëÏÄ MetaPost É ``ÆÒÁËÔÁÌØÎÁÑ'' ËÁÒÔÉÎËÁ-ÒÅÚÕÌØÔÁÔ} +%%\caption{MetaPost code and the resulting ``fractal'' figure} +\label{fig27} +\end{figure} + +\subsection{ðÕÎËÔÉÒÎÙÅ ÌÉÎÉÉ} +%%\subsection{Dashed Lines} + +ñÚÙË MetaPost ÐÒÅÄÏÓÔÁ×ÌÑÅÔ ÍÎÏÇÏ ÓÐÏÓÏÂÏ× ÉÚÍÅÎÑÔØ ÌÉÎÉÉ ÐÏÍÉÍÏ ÐÒÏÓÔÏÇÏ +ÉÚÍÅÎÅÎÉÑ ÉÈ ÔÏÌÝÉÎÙ. +%%The MetaPost language provides many ways of changing the appearance of a +%%line besides just changing its width. +ïÄÉÎ ÔÁËÏÊ ÓÐÏÓÏÂ × ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÐÕÎËÔÉÒÎÙÈ ÌÉÎÉÊ, ËÁË ÓÄÅÌÁÎÏ ÎÁ +ÒÉÓÕÎËÁÈ \ref{fig4} É~\ref{fig22}. +%%One way is to use dashed lines as +%%was done in Figures \ref{fig4} and~\ref{fig22}. +óÉÎÔÁËÓÉÓ ÄÌÑ ÜÔÏÇÏ\index{dashed?\texttt{dashed}}\label{Ddashed} --- +$$ {\tt draw}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\, {\tt dashed}\, \descr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ}, $$ +ÇÄÅ \tdescr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ}\index{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ?\tdescr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ}} +--- ÜÔÏ × ÄÅÊÓÔ×ÉÔÅÌØÎÏÓÔÉ ÓÐÅÃÉÁÌØÎÙÊ ÔÉÐ \tdescr{×ÙÒÁÖÅÎÉÑ-ËÁÒÔÉÎËÉ}. +%%The syntax for this +%%is\index{dashed?\texttt{dashed}} +%%$$ {\tt draw}\, \descr{path expression}\, {\tt dashed}\, \descr{dash pattern} $$ +%%where a \tdescr{dash pattern}\index{dash pattern?\tdescr{dash pattern}} +%%is really a special type of \tdescr{picture expression}. +åÓÔØ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ \tdescr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ}, ÎÁÚÙ×ÁÅÍÙÊ {\tt +evenly}\index{evenly?\texttt{evenly}}\label{Devenly}, ÄÅÌÁÀÝÉÊ +ÔÉÒÅ ÄÌÉÎÏÊ 3 PostScript ÐÕÎËÔÁ, ÒÁÚÄÅÌÅÎÎÙÅ ÐÒÏÍÅÖÕÔËÁÍÉ ÔÁËÏÇÏ ÖÅ +ÒÁÚÍÅÒÁ. +%%There is a predefined \tdescr{dash pattern} called {\tt +%%evenly}\index{evenly?\texttt{evenly}}\label{Devenly} that makes dashes 3 +%%PostScript points long separated by gaps of the same size. +äÒÕÇÏÊ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÏÂÒÁÚÅÃ, {\tt +withdots}\index{withdots?\texttt{withdots}}\label{Dwdots}, ÐÒÏÉÚ×ÏÄÉÔ +ÔÏÞÅÞÎÕÀ ÌÉÎÉÀ Ó ÔÏÞËÏÊ ÎÁ ËÁÖÄÙÅ 5 PostScript ÐÕÎËÔÏ×.\footnote{{\tt +withdots} ÅÓÔØ ÔÏÌØËÏ × MetaPost ×ÅÒÓÉÉ 0.50 É ÎÏ×ÅÅ.} +%%Another predefined dash pattern {\tt +%%withdots}\index{withdots?\texttt{withdots}}\label{Dwdots} produces +%%dotted lines with dots 5 PostScript points apart.\footnote{{\tt +%%withdots} is only found in MetaPost version 0.50 and higher.} +äÌÑ ÂÏÌÅÅ ÒÁÚÒÑÖÅÎÎÙÈ ÔÏÞÅË É ÒÁÚÒÑÖÅÎÎÙÈ É ÕÄÌÉÎÅÎÎÙÈ ÔÉÒÅ +\tdescr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ} ÍÏÖÅÔ ÂÙÔØ ÍÁÓÛÔÁÂÉÒÏ×ÁÎ\index{scaled?\texttt{scaled}} +ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig28}. +%%For dots +%%further apart or longer dashes further apart, the \tdescr{dash pattern} +%%can be scaled\index{scaled?\texttt{scaled}} as shown in +%%Figure~\ref{fig28}. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-29} $$ +\caption[ðÕÎËÔÉÒÎÙÅ ÌÉÎÉÉ É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÅ ÏÂÒÁÚÃÙ ÐÕÎËÔÉÒÁ] + {ðÕÎËÔÉÒÎÙÅ ÌÉÎÉÉ, ÐÏÍÅÞÅÎÎÙÅ \tdescr{ÏÂÒÁÚÃÏÍ ÐÕÎËÔÉÒÁ}, ÉÓÐÏÌØÚÕÅÍÙÍ + ÄÌÑ ÉÈ ÓÏÚÄÁÎÉÑ.} +%%\caption[Dashed lines and the corresponding dash patters] +%% {Dashed lines each labeled with the \tdescr{dash pattern} used to create +%% it.} +\label{fig28} +\end{figure} + +äÒÕÇÏÊ ÓÐÏÓÏ ÉÚÍÅÎÉÔØ ÏÂÒÁÚÅà ÌÉÎÉÉ × ÉÚÍÅÎÅÎÉÉ ÅÇÏ ÆÁÚÙ ÇÏÒÉÚÏÎÔÁÌØÎÙÍ +ÓÄ×ÉÇÏÍ. +%%Another way to change a dash pattern is to alter its phase by shifting +%%it horizontally. +óÄ×ÉÇ ×ÐÒÁ×Ï Ä×ÉÇÁÅÔ ÏÂÒÁÚÅà ×ÐÅÒÅÄ ×ÄÏÌØ ÐÕÔÉ, Á ÓÄ×ÉÇ ×ÐÒÁ×Ï --- ÎÁÚÁÄ. +%%Shifting to the right makes the dashes move forward +%%along the path and shifting to the left moves them backward. +òÉÓ.~\ref{fig29} ÉÌÌÀÓÔÒÉÒÕÅÔ ÜÔÏÔ ÜÆÆÅËÔ. +%%Figure~\ref{fig29} illustrates this effect. +ïÂÒÁÚÅà ÐÕÎËÔÉÒÁ ÍÏÖÎÏ ÐÒÅÄÓÔÁ×ÌÑÔØ ËÁË ÂÅÓËÏÎÅÞÎÏ ÐÏ×ÔÏÒÑÀÝÉÊÓÑ ÏÂÒÁÚÅÃ, +ÒÁÓÐÒÅÄÅÌÅÎÎÙÊ ×ÄÏÌØ ÇÏÒÉÚÏÎÔÁÌØÎÏÊ ÌÉÎÉÉ, ÇÄÅ ÕÞÁÓÔÏË ÌÉÎÉÉ ÓÐÒÁ×Á ÏÔ +ÏÓÉ $y$ ÒÁÚÍÅÝÁÅÔÓÑ ÎÁ ÐÕÔÉ, ÇÄÅ ÎÕÖÎÙ +ÒÁÚÒÙ×Ù\index{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ?\tdescr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ}}. +%%The dash pattern can be +%%thought of as an infinitely repeating pattern strung out along a +%%horizontal line where the portion of the line to the right of the +%%$y$~axis is laid out along the path to be dashed\index{dash +%%pattern?\tdescr{dash pattern}}. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-30} $$ +\caption[ðÕÎËÔÉÒÎÙÅ ÌÉÎÉÉ É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÅ ÏÂÒÁÚÃÙ ÐÕÎËÔÉÒÁ] + {ðÕÎËÔÉÒÎÙÅ ÌÉÎÉÉ É ËÏÍÁÎÄÙ MetaPost ÄÌÑ ÉÈ ÒÉÓÏ×ÁÎÉÑ, ÇÄÅ {\tt e4} + ÓÓÙÌÁÅÔÓÑ ÎÁ ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ {\tt evenly scaled 4}.} +%%\caption[Dashed lines and the corresponding dash patters] +%% {Dashed lines and the MetaPost statements for drawing them where {\tt e4} +%% refers to the dash pattern {\tt evenly scaled 4}.} +\label{fig29} +\end{figure} + +ëÏÇÄÁ ×Ù ÓÄ×ÉÇÁÅÔÅ ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ, ÔÁË ÞÔÏ ÏÓØ $y$ ÐÅÒÅÓÅËÁÅÔ ÓÅÒÅÄÉÎÕ, +ÐÅÒ×ÏÅ ÔÉÒÅ ÕÒÅÚÁÅÔÓÑ. +%%When you shift a dash pattern so that the $y$~axis crosses the middle of +%%a dash, the first dash gets truncated. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÌÉÎÉÑ Ó ÏÂÒÁÚÃÁÍÉ ÐÕÎËÔÉÒÁ {\tt e4} ÎÁÞÉÎÁÅÔÓÑ Ó ÔÉÒÅ ÄÌÉÎÏÊ +12bp, ÚÁ ËÏÔÏÒÙÍ ÉÄÅÔ ÒÁÚÒÙ× 12bp, ÚÁ ËÏÔÏÒÙÍ --- ÄÒÕÇÏÅ 12bp ÔÉÒÅ É Ô.~Ä.; +{\tt e4 shifted (-6bp,0)} ÐÒÏÉÚ×ÏÄÉÔ 6bp ÔÉÒÅ, 12 bp ÐÒÏÍÅÖÕÔÏË, ÚÁÔÅÍ 12bp +ÔÉÒÅ É Ô.~Ä. +%%Thus the line with dash pattern +%%{\tt e4} starts with a dash of length 12bp followed by a 12bp gap and +%%another 12bp dash, etc., while {\tt e4 shifted (-6bp,0)} produces a 6bp +%%dash, a 12 bp gap, then a 12bp dash, etc. +üÔÏÔ ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ ÍÏÖÅÔ ÂÙÔØ ÕËÁÚÁÎ ÂÏÌÅÅ ÐÒÑÍÏ ÞÅÒÅÚ ÆÕÎËÃÉÀ +{\tt dashpattern}\index{dash +pattern?\texttt{dashpattern}}\label{Ddshpat}: +$$ \hbox{\tt dashpattern(on 6bp off 12bp on 6bp)} $$ +%%This dash pattern could be +%%specified more directly via the {\tt dashpattern}\index{dash +%%pattern?\texttt{dash pattern}}\label{Ddshpat} function: +%%$$ \hbox{\tt dashpattern(on 6bp off 12bp on 6bp)} $$ +ðÒÉÍÅÒ ÏÚÎÁÞÁÅÔ ``ÎÁÒÉÓÕÊ ÐÅÒ×ÙÅ 6bp ÌÉÎÉÉ, ÚÁÔÅÍ ÐÒÏÐÕÓÔÉ ÓÌÅÄÕÀÝÉÅ 12bp, +ÚÁÔÅÍ ÒÉÓÕÊ 6bp É ÐÏ×ÔÏÒÑÊ''. +%%This means ``draw the first 6bp of the line, then skip the next 12bp, then draw +%%another 6bp and repeat.'' +åÓÌÉ ÜÔÁ ÌÉÎÉÑ Ó ÒÁÚÒÙ×ÁÍÉ ÉÍÅÅÔ ÄÌÉÎÕ ÂÏÌÅÅ 30bp, ÔÏ ÐÏÓÌÅÄÎÉÅ 6bp ÐÅÒ×ÏÊ ËÏÐÉÉ +ÏÂÒÁÚÃÁ ÌÉÎÉÉ ÂÕÄÕÔ ÓÏÅÄÉÎÑÔØÓÑ Ó ÐÅÒ×ÙÍÉ 6bp ÓÌÅÄÕÀÝÅÊ ËÏÐÉÉ ÄÌÑ ÆÏÒÍÉÒÏ×ÁÎÉÑ +ÔÉÒÅ ÄÌÉÎÏÊ 12bp. +%%If the line to be dashed is more than 30bp long, the +%%last 6bp of the first copy of the dash pattern will merge with the first 6bp of +%%the next copy to form a dash 12bp long. +ïÂÝÉÊ ÓÉÎÔÁËÓÉÓ ÄÌÑ ÆÕÎËÃÉÉ {\tt dashpattern} ÐÏËÁÚÁÎ ÎÁ ÒÉÓ.~\ref{sydash}. +%%The general syntax for the +%%{\tt dashpattern} function is shown in Figure~\ref{sydash}. + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ} \rightarrow dashpattern + \hbox{\tt (}\descr{ÓÐÉÓÏË ÅÓÔØ/ÎÅÔ}\hbox{\tt )}$\\ +%%$\tt \descr{dash pattern} \rightarrow dashpattern +%% \hbox{\tt (}\descr{on/off list}\hbox{\tt )}$\\ +$\tt \descr{ÓÐÉÓÏË ÅÓÔØ/ÎÅÔ} \rightarrow + \descr{ÓÐÉÓÏË ÅÓÔØ/ÎÅÔ}\descr{ÐÕÎËÔ ÅÓÔØ/ÎÅÔ} \;|\; \descr{ÐÕÎËÔ ÅÓÔØ/ÎÅÔ}$\\ +%%$\tt \descr{on/off list} \rightarrow +%% \descr{on/off list}\descr{on/off clause} \;|\; \descr{on/off clause}$\\ +$\tt \descr{ÐÕÎËÔ ÅÓÔØ/ÎÅÔ} \rightarrow on \descr{ÞÉÓÌÏ×ÁÑ ÔÒÅÔÉÞÎÏÓÔØ} + \;|\; off \descr{ÞÉÓÌÏ×ÁÑ ÔÒÅÔÉÞÎÏÓÔØ}$ +%%$\tt \descr{on/off clause} \rightarrow on \descr{numeric tertiary} +%% \;|\; off \descr{numeric tertiary}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ÆÕÎËÃÉÉ {\tt dashpattern}} +%%\caption{The syntax for the {\tt dashpattern} function} +\label{sydash} +\end{figure} + +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ × ÄÅÊÓÔ×ÉÔÅÌØÎÏÓÔÉ Ñ×ÌÑÅÔÓÑ ÏÓÏÂÙÍ ÔÉÐÏÍ +ÒÉÓÕÎËÁ, ÆÕÎËÃÉÑ {\tt dashpattern} ×ÏÚ×ÒÁÝÁÅÔ ÒÉÓÕÎÏË. +%%Since a dash pattern is really just a special kind of picture, the {\tt +%%dashpattern} function returns a picture. +îÅÔ ÎÅÏÂÈÏÄÉÍÏÓÔÉ ÚÎÁÔØ ÓÔÒÕËÔÕÒÕ ÔÁËÏÇÏ ÒÉÓÕÎËÁ, ÐÏÜÔÏÍÕ ÓÌÕÞÁÊÎÙÊ +ÞÉÔÁÔÅÌØ ÂÕÄÅÔ ×ÅÒÏÑÔÎÏ ÈÏÔÅÔØ ÐÅÒÅÊÔÉ Ë ÒÁÚÄÅÌÕ~\ref{oopt}. +%%It is not really necessary to +%%know the structure of such a picture, so the casual reader will probably +%%want to skip on to Section~\ref{oopt}. +äÌÑ ÔÅÈ, ËÔÏ ÈÏÞÅÔ ÚÎÁÔØ, ÍÁÌÅÎØËÉÊ ÜËÓÐÅÒÉÍÅÎÔ ÐÏËÁÚÙ×ÁÅÔ, ÞÔÏ ÅÓÌÉ +{\tt d} --- ÜÔÏ +$$ \hbox{\tt dashpattern(on 6bp off 12bp on 6bp)}, $$ +ÔÏ {\tt llcorner d} --- ÜÔÏ $(0,24)$ É {\tt urcorner d} --- $(24,24)$. +%%For those who want to know, a +%%little experimentation shows that if {\tt d} is +%%$$ \hbox{\tt dashpattern(on 6bp off 12bp on 6bp)}, $$ +%%then {\tt llcorner d} is $(0,24)$ and {\tt urcorner d} is $(24,24)$. +ðÒÑÍÏÅ ÉÚÏÂÒÁÖÅÎÉÅ {\tt d} ÂÅÚ ÉÓÐÏÌØÚÏ×ÁÎÉÑ ÅÇÏ ËÁË ÏÂÒÁÚÃÁ +ÐÒÏÉÚ×ÅÄÅÔ Ä×Á ÔÏÎËÉÈ ÇÏÒÉÚÏÎÔÁÌØÎÙÈ ÏÔÒÅÚËÁ ÐÒÑÍÏÊ, ÐÏÄÏÂÎÙÅ ÔÁËÉÍ: +%%Drawing {\tt d} directly without using it as a dash pattern produces two +%%thin horizontal line segments like this: +$$ \includegraphics{manfig-ru-31} $$ +ìÉÎÉÉ × ÜÔÏÍ ÐÒÉÍÅÒÅ ÏÐÉÓÙ×ÁÌÉÓØ, ËÁË ÉÍÅÀÝÉÅ ÔÏÌÝÉÎÕ ÎÏÌØ, ÎÏ ÜÔÏ ÎÅ ÉÍÅÅÔ +ÚÎÁÞÅÎÉÑ, ÐÏÔÏÍÕ ÞÔÏ ÔÏÌÝÉÎÁ ÌÉÎÉÉ ÉÇÎÏÒÉÒÕÅÔÓÑ, ËÏÇÄÁ ÒÉÓÕÎÏË ÉÓÐÏÌØÚÕÅÔÓÑ +ËÁË ÏÂÒÁÚÅà ÌÉÎÉÉ. +%%The lines in this example are specified as having width zero, but this +%%does not matter because the line width is ignored when a picture is used +%%as a dash pattern. + +ïÂÝÅÅ ÐÒÁ×ÉÌÏ ÉÎÔÅÒÐÒÅÔÁÃÉÉ ÒÉÓÕÎËÁ {\tt d}, ËÁË ÏÂÒÁÚÃÁ ÌÉÎÉÉ, × ÔÏÍ, +ÞÔÏ ÏÔÒÅÚËÉ × {\tt d} ÐÒÏÅËÔÉÒÕÀÔÓÑ ÎÁ ÏÓØ $x$ É ÉÔÏÇÏ×ÙÊ ÏÂÒÁÚÅà +ÐÏ×ÔÏÒÑÅÔÓÑ ÂÅÓËÏÎÅÞÎÏ × ÏÂÏÉÈ ÎÁÐÒÁ×ÌÅÎÉÑÈ ÐÏÍÅÝÅÎÉÅÍ ×ÐÌÏÔÎÕÀ ËÏÐÉÊ +ÏÂÒÁÚÃÁ. +%%The general rule for interpreting a picture {\tt d} as a dash pattern is +%%that the line segments in {\tt d} are projected onto the $x$-axis and +%%the resulting pattern is replicated to infinity in both directions by +%%placing copies of the pattern end-to-end. +îÁÓÔÏÑÝÉÅ ÄÌÉÎÙ ÐÏÌÕÞÁÀÔÓÑ, ÎÁÞÉÎÁÑ Ó $x=0$, Ä×ÉÖÅÎÉÅÍ × ÐÏÌÏÖÉÔÅÌØÎÏÍ +ÎÁÐÒÁ×ÌÅÎÉÉ $x$. +%%The actual dash lengths are +%%obtained by starting at $x=0$ and scanning in the positive $x$ +%%direction. + +þÔÏÂÙ ÓÄÅÌÁÔØ ÉÄÅÀ ``ÐÏ×ÔÏÒÑÔØ ÂÅÓËÏÎÅÞÎÏ'' ÂÏÌÅÅ ÔÏÞÎÏÊ, ÕÓÔÁÎÏ×ÉÍ +$P({\tt d})$ ÐÒÏÅËÃÉÅÊ {\tt d} ÎÁ ÏÓØ $x$ É ÐÕÓÔØ +${\rm shift}(P({\tt d}),x)$ --- ÜÔÏ ÒÅÚÕÌØÔÁÔ ÓÄ×ÉÇÁ {\tt d} ÎÁ~$x$. +%%To make the idea of ``replicating to infinity'' more precise, let $P({\tt d})$ +%%be the projection of {\tt d} onto the $x$~axis, and let +%%${\rm shift}(P({\tt d}),x)$ be the result of shifting {\tt d} by~$x$. +ïÂÒÁÚÅÃ, ÐÏÌÕÞÁÀÝÉÊÓÑ × ÒÅÚÕÌØÔÁÔÅ ÂÅÓËÏÎÅÞÎÏÇÏ ÐÏ×ÔÏÒÅÎÉÑ, --- ÜÔÏ +$$ \bigcup_{\hbox{\scriptsize ÃÅÌÙÅ}\ n} {\rm shift}(P(d),\, n\cdot\ell(d)), $$ +ÇÄÅ $\ell(d)$ ÉÚÍÅÒÑÅÔ ÄÌÉÎÕ $P(d)$. +%%The pattern resulting from infinite replication is +%%$$ \bigcup_{{\rm integers}\ n} {\rm shift}(P(d),\, n\cdot\ell(d)), $$ +%%where $\ell(d)$ measures the length of $P(d)$. +îÁÉÂÏÌÅÅ ÏÇÒÁÎÉÞÉ×ÁÀÝÅÅ ÏÐÒÅÄÅÌÅÎÉÅ ÜÔÏÊ ÄÌÉÎÙ ÒÁ×ÎÏ +$d_{\rm max}-d_{\rm min}$, ÇÄÅ $[d_{\rm min},d_{\rm max}]$ +--- ÜÔÏ ÄÉÁÐÁÚÏÎ ËÏÏÒÄÉÎÁÔ $x$ × $P(d)$. +%%The most restrictive possible +%%definition of this length is $d_{\rm max}-d_{\rm min}$, +%%where $[d_{\rm min},d_{\rm max}]$ +%%is the range of $x$~coordinates in $P(d)$. +æÁËÔÉÞÅÓËÉ MetaPost ÉÓÐÏÌØÚÕÅÔ +$$ \max(\left|y_0({\tt d})\right|,\, d_{\rm max}-d_{\rm min}), $$ +ÇÄÅ $y_0({\tt d})$ --- ÜÔÏ ËÏÏÒÄÉÎÁÔÁ $y$ ÓÏÄÅÒÖÉÍÏÇÏ {\tt d}. +%%In fact, MetaPost uses +%%$$ \max(\left|y_0({\tt d})\right|,\, d_{\rm max}-d_{\rm min}), $$ +%%where $y_0({\tt d})$ is the $y$ coordinate of the contents of {\tt d}. +óÏÄÅÒÖÉÍÏÅ {\tt d} ÄÏÌÖÎÏ ÎÁÈÏÄÉÔØÓÑ ÎÁ ÇÏÒÉÚÏÎÔÁÌØÎÏÊ ÌÉÎÉÉ, ÎÏ ÅÓÌÉ +ÜÔÏ ÎÅ ÔÁË, ÔÏ ÉÎÔÅÒÐÒÅÔÁÔÏÒ MetaPost ÐÒÏÓÔÏ ×ÏÚØÍÅÔ ËÏÏÒÄÉÎÁÔÕ $y$ ×ÎÕÔÒÉ +{\tt d}\index{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ?\tdescr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ}}. +%%The contents of {\tt d} should lie on a horizontal line, but if they do +%%not, the MetaPost interpreter just picks a $y$~coordinate that occurs in +%%{\tt d}\index{dash pattern?\tdescr{dash pattern}}. + +ëÁÒÔÉÎËÁ Ó ÏÂÒÁÚÃÏÍ ÐÕÎËÔÉÒÁ ÎÅ ÄÏÌÖÎÁ ÓÏÄÅÒÖÁÔØ ÔÅËÓÔÁ ÉÌÉ ÚÁÐÏÌÎÅÎÎÙÈ +ÏÂÌÁÓÔÅÊ, ÎÏ ÏÎÁ ÍÏÖÅÔ ÓÏÄÅÒÖÁÔØ ÌÉÎÉÉ, ËÏÔÏÒÙÅ ÐÕÎËÔÉÒÎÙÅ. +%%A picture used as a dashed pattern must contain no text or filled +%%regions, but it can contain lines that are themselves dashed. +üÔÏ ÄÁÅÔ ÍÁÌÅÎØËÉÅ É ÂÏÌØÛÉÅ ÒÁÚÒÙ×Ù ËÁË ÐÏËÁÚÁÎÏ ÎÁ +ÒÉÓ.~\ref{fig32}.\index{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ?\tdescr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ}!ÒÅËÕÒÓÉ×ÎÙÊ} +%%This can give small dashes inside of larger dashes as shown in +%%Figure~\ref{fig32}.\index{dash pattern?\tdescr{dash pattern}!recursive} + +\begin{figure}[htp] +$$\begin{verbatim} +beginfig(32); +draw dashpattern(on 15bp off 15bp) dashed evenly; +picture p; +p=currentpicture; +currentpicture:=nullpicture; +draw fullcircle scaled 1cm xscaled 3 dashed p; +endfig; +\end{verbatim} +\quad \mathcenter{\includegraphics{manfig-ru-32}} +$$ +\caption{ëÏÄ MetaPost ÄÌÑ ÏÂÒÁÚÃÁ ÐÕÎËÔÉÒÁ É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ×Ù×ÏÄ} +%%\caption{MetaPost code for dashed patterns and the corresponding output} +\label{fig32} +\end{figure} + +\label{dashed-pens} +ïÂÒÁÚÃÙ ÐÕÎËÔÉÒÁ ÔÁËÖÅ ÐÒÅÄÎÁÚÎÁÞÅÎÙ ÄÌÑ ÉÓÐÏÌØÚÏ×ÁÎÉÑ Ó {\tt +pencircle} ÉÌÉ Ó ÏÔÓÕÔÓÔ×ÉÅÍ ÐÅÒÁ; {\tt pensquare} É ÄÒÕÇÉÈ ÓÌÏÖÎÙÈ +ÐÅÒØÅ× ÓÌÅÄÕÅÔ ÉÚÂÅÇÁÔØ. +%%Also, dashed patterns are intended to be used either with {\tt +%%pencircle} or no pen at all; {\tt pensquare} and other complex pens +%%should be avoided. +ðÏÓÌÅÄÎÅÅ ÏÂÕÓÌÏ×ÌÅÎÏ ÔÅÍ, ÞÔÏ ×Ù×ÏÄ ÉÓÐÏÌØÚÕÅÔ ÐÒÉÍÉÔÉ× PostScript +{\tt setdash}, ËÏÔÏÒÙÊ ÎÅ ÏÞÅÎØ ÈÏÒÏÛÏ ×ÚÁÉÍÏÄÅÊÓÔ×ÕÅÔ Ó ÚÁÐÏÌÎÅÎÎÙÍÉ +ÐÕÔÑÍÉ, ÓÏÚÄÁÎÎÙÍÉ ÍÎÏÇÏÕÇÏÌØÎÙÍÉ ÐÅÒØÑÍÉ. +%%This is because the output uses the PostScript +%%primitive {\tt setdash}, which does not interact well with the filled +%%paths created by polygonal pens. +óÍ. ÒÁÚÄÅÌ~\ref{sec.pens}, ÓÔÒ.~\pageref{sec.pens}. +%%See Section~\ref{sec.pens}, p.\ \pageref{sec.pens}. + +%\newpage + +\subsection{÷ËÌÀÞÅÎÉÅ PostScript} +%%\subsection{Local specials} + +åÓÌÉ ×Ù ÈÏÔÉÔÅ ÄÏÂÁ×ÉÔØ ËÏÄ PostScript Ë Ó×ÏÉÍ ÏÂßÅËÔÁÍ, ÔÏ +×Ù ÍÏÖÅÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ +$$ +{\tt withprescript} \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}% +\index{withprescript?\texttt{withprescript}}\label{Dwithpre} +$$ +É +$$ +{\tt withpostcript} \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}% +\index{withpostscript?\texttt{withpostscript}}\label{Dwithpost} +$$ +%%If you want to attach a special bit of PostScript code, you can use +%%$$ +%%{\tt withprescript} \descr{string expression} +%%$$\index{withprescript?\texttt{withprescript}}\label{Dwithpre}% +%%and +%%$$ +%%{\tt withpostcript} \descr{string expression} +%%$$\index{withpostscript?\texttt{withpostscript}}\label{Dwithpost}% +óÔÒÏËÉ-ÒÅÚÕÌØÔÁÔÙ ÂÕÄÕÔ ÚÁÐÉÓÁÎÙ × ÆÁÊÌ ×Ù×ÏÄÁ ÓÏÏÔ×ÅÔÓÔ×ÅÎÎÏ ÐÅÒÅÄ ÉÌÉ +ÐÏÓÌÅ ÔÅËÕÝÅÇÏ ÏÂßÅËÔÁ, ÎÁÞÉÎÁÑÓØ Ó ÎÏ×ÏÊ ÓÔÒÏËÉ ËÁÖÄÁÑ. +%%The strings will be written to the output file before and after the +%%current object, each beginning on their own line. +ïÐÃÉÉ {\tt withprescript} ÉÌÉ {\tt withpostscript} ÍÏÖÎÏ ÕËÁÚÙ×ÁÔØ +ÍÎÏÇÏËÒÁÔÎÏ. +%%You can specify +%%multiple {\tt withprescript} or {\tt withpostscript} options if you +%%like. + +ëÏÇÄÁ ×Ù ÕËÁÚÙ×ÁÅÔÅ ÂÏÌÅÅ ÏÄÎÏÊ ÏÐÃÉÉ {\tt withprescript} ÉÌÉ {\tt +withpostscript}, ÂÕÄØÔÅ ×ÎÉÍÁÔÅÌØÎÙ Ó ÆÁËÔÏÍ ÔÏÇÏ, ÞÔÏ ÜÔÉ ÓËÒÉÐÔÙ ÉÓÐÏÌØÚÕÀÔ +×ÌÏÖÅÎÎÏÓÔØ: ÐÕÎËÔÙ {\tt withprescript} ÚÁÐÉÓÙ×ÁÀÔÓÑ × PostScript-ÆÁÊÌ +ËÁË × ÓÔÅË, Á ÐÕÎËÔÙ {\tt withpostscript} ÚÁÐÉÓÙ×ÁÀÔÓÑ ËÁË × ÏÞÅÒÅÄØ. +%%When you specify more than one {\tt withprescript} or more than one {\tt +%% withpostscript} option, be wary of the fact that the scripts use a +%%form of nesting: the {\tt withprescript} items are written to the +%%PostScript file in last in, first out order; whereas the {\tt +%% withpostscript} items are written in first in, first out order. + +\subsection{äÒÕÇÉÅ ÏÐÃÉÉ} +%%\subsection{Other Options} +\label{oopt} + +÷Ù ÍÏÇÌÉ ÚÁÍÅÔÉÔØ, ÞÔÏ ÐÕÎËÔÉÒÎÙÅ ÌÉÎÉÉ, ÐÒÏÉÚ×ÏÄÉÍÙÅ +{\tt dashed evenly}\index{evenly?\texttt{evenly}}, ÓÏÄÅÒÖÁÔ +ÂÏÌØÛÅ ÞÅÒÎÏÇÏ, ÞÅÍ ÂÅÌÏÇÏ. +%%You might have noticed that the dashed lines produced by {\tt dashed +%%evenly}\index{evenly?\texttt{evenly}} appear to have more black than +%%white. +üÔÏ ÉÚ-ÚÁ ÜÆÆÅËÔÁ ÐÁÒÁÍÅÔÒÁ {\tt +linecap}\index{linecap?\texttt{linecap}}\label{Dlinecap}, ËÏÔÏÒÙÊ +ÕÐÒÁ×ÌÑÅÔ ÐÏÑ×ÌÅÎÉÅÍ ËÏÎÃÏ× ÌÉÎÉÊ É ËÏÎÃÏ× ÏÔÒÅÚËÏ×-ÔÉÒÅ. +%%This is an effect of the {\tt +%%linecap}\index{linecap?\texttt{linecap}}\label{Dlinecap} parameter that +%%controls the appearance of the ends of lines as well as the ends of +%%dashes. +åÓÔØ ÔÁËÖÅ É ÄÒÕÇÉÅ ÓÐÏÓÏÂÙ ×ÌÉÑÔØ ÎÁ ÐÏÑ×ÌÅÎÉÅ ÔÏÇÏ, ÞÔÏ ÒÉÓÕÅÔÓÑ +MetaPost. +%%There are also a number of other ways to affect the appearance +%%of things drawn with MetaPost. + +ðÁÒÁÍÅÔÒ {\tt linecap} ÉÍÅÅÔ ÔÒÉ ÒÁÚÌÉÞÎÙÈ ÕÓÔÁÎÏ×ËÉ --- ÔÏÞÎÏ ÔÁËÉÅ ÖÅ, +ËÁË É × PostScript. +%%The {\tt linecap} parameter has three different settings just as in +%%PostScript. +Plain MetaPost ÄÁÅÔ ÜÔÏÊ ×ÎÕÔÒÅÎÎÅÊ ÐÅÒÅÍÅÎÎÏÊ\index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} ÔÉÐÏ×ÏÅ ÚÎÁÞÅÎÉÅ {\tt +rounded}\index{rounded?\texttt{rounded}}, ÞÔÏ ÏÚÎÁÞÁÅÔ ÒÉÓÏ×ÁÔØ +ÏÔÒÅÚËÉ Ó ÚÁËÒÕÇÌÅÎÎÙÍÉ ËÏÎÃÁÍÉ, ÐÏÄÏÂÎÏ ÏÔÒÅÚËÕ ÏÔ +{\tt z0} ÄÏ {\tt z3} ÎÁ ÒÉÓ.~\ref{fig33}. +%%Plain MetaPost gives this internal variable\index{internal +%%variables}\index{variables!internal} the default value {\tt +%%rounded}\index{rounded?\texttt{rounded}} which causes line segments to +%%be drawn with rounded ends like the segment from {\tt z0} to {\tt z3} in +%%Figure~\ref{fig33}. +õÓÔÁÎÏ×ËÁ ${\tt linecap}\mathrel{\hbox{\tt:=}}{\tt +butt}$\index{butt?\texttt{butt}}\label{Dbutt} ÏÂÒÅÚÁÅÔ ËÏÎÃÙ ÔÁË, ÞÔÏ +ÔÉÒÅ, ÐÒÏÉÚ×ÏÄÉÍÙÅ {\tt dashed +evenly}\index{evenly?\texttt{evenly}}, ÉÍÅÀÔ ÄÌÉÎÕ 3bp, Á ÎÅ 3bp ÐÌÀÓ +ÔÏÌÝÉÎÁ ÌÉÎÉÉ. +%%Setting ${\tt linecap}\mathrel{\hbox{\tt:=}}{\tt +%%butt}$\index{butt?\texttt{butt}}\label{Dbutt} cuts the ends off flush so +%%that dashes produced by {\tt dashed +%%evenly}\index{evenly?\texttt{evenly}} have length 3bp, not 3bp plus the +%%line width. +÷Ù ÔÁËÖÅ ÍÏÖÅÔÅ ÐÏÌÕÞÉÔØ ËÏÎÃÙ-Ë×ÁÄÒÁÔÙ, ×ÙÈÏÄÑÝÉÅ ÚÁ ÐÒÅÄÅÌÙ ÕËÁÚÁÎÎÙÈ +ÔÏÞÅË-ËÏÎÃÏ×, ÕÓÔÁÎÏ×ËÏÊ ${\tt linecap}\mathrel{\hbox{\tt:=}}{\tt +squared}$\index{squared?\texttt{squared}}\label{Dsqred}, ËÁË ÜÔÏ ÓÄÅÌÁÎÏ +ÎÁ ÌÉÎÉÉ ÏÔ {\tt z2} ÄÏ {\tt z5} × ÒÉÓ.~\ref{fig33}. +%%You can also get squared-off ends that extend past the +%%specified endpoints by setting ${\tt linecap}\mathrel{\hbox{\tt:=}}{\tt +%%squared}$\index{squared?\texttt{squared}}\label{Dsqred} as was done in +%%the line from {\tt z2} to {\tt z5} in Figure~\ref{fig33}. + +\begin{figure}[htp] +$$\begin{verbatim} +beginfig(33); +for i=0 upto 2: + z[i]=(0,40i); z[i+3]-z[i]=(100,30); +endfor +pickup pencircle scaled 18; +draw z0..z3 withcolor .8white; +linecap:=butt; +draw z1..z4 withcolor .8white; +linecap:=squared; +draw z2..z5 withcolor .8white; +dotlabels.top(0,1,2,3,4,5); +endfig; linecap:=rounded; +\end{verbatim} +\qquad +\mathcenter{\includegraphics{manfig-ru-33}} +$$ +\caption{ëÏÄ MetaPost É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ×Ù×ÏÄ} +%%\caption{MetaPost code and the corresponding output} +\label{fig33} +\end{figure} + +äÒÕÇÏÊ ÐÁÒÁÍÅÔÒ, ÚÁÉÍÓÔ×Ï×ÁÎÎÙÊ ÉÚ PostScript, ×ÌÉÑÅÔ ÎÁ ÓÐÏÓÏÂ, ËÏÔÏÒÙÍ +ËÏÍÁÎÄÁ {\tt draw} ÒÉÓÕÅÔ ÕÇÌÙ\index{ÕÇÌÙ} ÎÁ ÉÚÏÂÒÁÖÁÅÍÏÍ ÐÕÔÉ. +%%Another parameter borrowed from PostScript affects the way a {\tt draw} +%%statement treats sharp corners\index{corners} in the path to be drawn. +ðÁÒÁÍÅÔÒ {\tt linejoin}\index{linejoin?\texttt{linejoin}}\label{Dlinejoin} +ÍÏÖÅÔ ÂÙÔØ {\tt +rounded}\index{rounded?\texttt{rounded}}\label{Drnded}, {\tt +beveled}\index{beveled?\texttt{beveled}}\label{Dbvled} ÉÌÉ {\tt +mitered}\index{mitered?\texttt{mitered}}\label{Dmitred}, ËÁË ÐÏËÁÚÁÎÏ +ÎÁ ÒÉÓ.~\ref{fig34}. +%%The {\tt linejoin}\index{linejoin?\texttt{linejoin}}\label{Dlinejoin} +%%parameter can be {\tt +%%rounded}\index{rounded?\texttt{rounded}}\label{Drnded}, {\tt +%%beveled}\index{beveled?\texttt{beveled}}\label{Dbvled}, or {\tt +%%mitered}\index{mitered?\texttt{mitered}}\label{Dmitred} as shown in +%%Figure~\ref{fig34}. +óÔÁÎÄÁÒÔÎÏÅ ÚÎÁÞÅÎÉÅ ÄÌÑ plain MetaPost --- ÜÔÏ {\tt +rounded}, ÏÎÏ ÄÁÅÔ ÜÆÆÅËÔ ÒÉÓÏ×ÁÎÉÑ ËÒÕÇÌÙÍ ÐÅÒÏÍ. +%%The default value for plain MetaPost is {\tt +%%rounded} which gives the effect of drawing with a circular brush. + +\begin{figure}[htp] +$$\begin{verbatim} +beginfig(34); +for i=0 upto 2: + z[i]=(0,50i); z[i+3]-z[i]=(60,40); + z[i+6]-z[i]=(120,0); +endfor +pickup pencircle scaled 24; +draw z0--z3--z6 withcolor .8white; +linejoin:=mitered; +draw z1..z4--z7 withcolor .8white; +linejoin:=beveled; +draw z2..z5--z8 withcolor .8white; +dotlabels.bot(0,1,2,3,4,5,6,7,8); +endfig; linejoin:=rounded; +\end{verbatim} +\qquad +\mathcenter{\includegraphics{manfig-ru-34}} +$$ +\caption{ëÏÄ MetaPost É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ×Ù×ÏÄ} +%%\caption{MetaPost code and the corresponding output} +\label{fig34} +\end{figure} + +ëÏÇÄÁ {\tt linejoin} ÒÁ×ÅÎ {\tt mitered}, ÕÇÌÙ ÉÚÏÂÒÁÖÁÀÔÓÑ Ó ÄÌÉÎÎÙÍ +ÏÓÔÒÉÅÍ, ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig35}. +%%When {\tt linejoin} is {\tt mitered}, sharp corners generate long +%%pointed features as shown in Figure~\ref{fig35}. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÜÔÏ ÍÏÖÅÔ ÂÙÔØ ÎÅÖÅÌÁÔÅÌØÎÙÍ, ÅÓÔØ ×ÎÕÔÒÅÎÎÑÑ +ÐÅÒÅÍÅÎÎÁÑ\index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} Ó ÉÍÅÎÅÍ {\tt +miterlimit}\index{miterlimit?\texttt{miterlimit}}\label{Dmiterlim}, +ËÏÔÏÒÁÑ ÕÐÒÁ×ÌÑÅÔ ÐÅÒÅÈÏÄÏÍ ÏÔ ÏÓÔÒÏËÏÎÅÞÎÏÇÏ ÓÏÅÄÉÎÅÎÉÑ Ë ÓÒÅÚÁÎÎÏÍÕ +ÓÏÅÄÉÎÅÎÉÀ. +%%Since this might be +%%undesirable, there is an internal variable\index{internal +%%variables}\index{variables!internal} called {\tt +%%miterlimit}\index{miterlimit?\texttt{miterlimit}}\label{Dmiterlim} that +%%controls how extreme the situation can get before the mitered join is +%%replaced by a beveled join. +äÌÑ Plain MetaPost {\tt miterlimit} ÉÍÅÅÔ ÓÔÁÎÄÁÒÔÎÏÅ ÚÎÁÞÅÎÉÅ 10.0 É +ÓÏÅÄÉÎÅÎÉÅ ÌÉÎÉÊ ÏÂÒÁÝÁÅÔÓÑ Ë ÓÒÅÚÁÎÎÏÍÕ ÔÏÇÄÁ, ËÏÇÄÁ ÏÔÎÏÛÅÎÉÅ +ÄÌÉÎÙ ÏÓÔÒÉÑ Ë ÔÏÌÝÉÎÅ ÌÉÎÉÉ ÄÏÓÔÉÇÁÅÔ ÜÔÏÇÏ ÚÎÁÞÅÎÉÑ. +%%For Plain MetaPost, {\tt miterlimit} has a +%%default value of 10.0 and line joins revert to beveled when the ratio of +%%miter length to line width reaches this value. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-35} $$ +\caption{äÌÉÎÁ ÏÓÔÒÉÑ É ÔÏÌÝÉÎÁ ÌÉÎÉÉ, ÞØÅ ÏÔÎÏÛÅÎÉÅ ÏÇÒÁÎÉÞÉ×ÁÅÔÓÑ + {\tt miterlimit}.} +%%\caption{The miter length and line width whose ratio is limited by +%% {\tt miterlimit}.} +\label{fig35} +\end{figure} + +ðÁÒÁÍÅÔÒÙ {\tt linecap}, {\tt linejoin} É {\tt miterlimit} ÏÞÅÎØ +×ÁÖÎÙ, ÐÏÔÏÍÕ ÞÔÏ ÏÎÉ ×ÌÉÑÀÔ É ÎÁ ÄÒÕÇÉÅ ÒÉÓÕÅÍÙÅ ÏÂßÅËÔÙ. +%%The {\tt linecap}, {\tt linejoin}, and {\tt miterlimit} parameters are +%%especially important because they also affect things that get drawn +%%behind the scenes. +îÁÐÒÉÍÅÒ, Plain MetaPost ÉÍÅÅÔ ËÏÍÁÎÄÕ ÄÌÑ ÒÉÓÏ×ÁÎÉÑ +ÓÔÒÅÌÏË\index{ÓÔÒÅÌËÉ} É ËÏÎÃÙ ÓÔÒÅÌÏË ÐÏÌÕÞÁÀÔÓÑ ÓÌÅÇËÁ ÓËÒÕÇÌÅÎÎÙÍÉ +ÐÒÉ {\tt linejoin} ÒÁ×ÎÏÍ {\tt rounded}. +%%For instance, Plain MetaPost has statements for +%%drawing arrows\index{arrows}, and the arrowheads are slightly rounded +%%when {\tt linejoin} is {\tt rounded}. +üÆÆÅËÔ ÚÁ×ÉÓÉÔ ÏÔ ÔÏÌÝÉÎÙ ÌÉÎÉÉ É ÐÏÞÔÉ ÎÅÚÁÍÅÔÅÎ ÐÒÉ ÓÔÁÎÄÁÒÔÎÏÊ ÔÏÌÝÉÎÅ +ÌÉÎÉÉ × 5bp, ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig36}. +%%The effect depends on the line +%%width and is quite subtle at the default line width of 0.5bp as shown in +%%Figure~\ref{fig36}. + +\begin{figure}[htp] +$$\includegraphics{manfig-ru-36}$$ +\caption{ôÒÉ ÓÐÏÓÏÂÁ ÒÉÓÏ×ÁÔØ ÓÔÒÅÌËÉ.} +%%\caption{Three ways of drawing arrows.} +\label{fig36} +\end{figure} + +îÁÒÉÓÏ×ÁÎÎÙÅ ÓÔÒÅÌËÉ, ÐÏÄÏÂÎÙÅ ÔÅÍ, ÞÔÏ ÎÁ ÒÉÓ.~\ref{fig36}, --- ÜÔÏ ÐÒÏÓÔÏ +ÒÅÚÕÌØÔÁÔ, ËÏÇÄÁ ×ÍÅÓÔÏ {\tt draw} \tdescr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} +ÐÉÛÕÔ\index{drawarrow?\texttt{drawarrow}}\label{Ddrwarr} +$$ {\tt drawarrow}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}. $$ +%%Drawing arrows like the ones in Figure~\ref{fig36} is simply a matter of +%%saying\index{drawarrow?\texttt{drawarrow}}\label{Ddrwarr} +%%$$ {\tt drawarrow}\, \descr{path expression} $$ +%%instead of {\tt draw} \tdescr{path expression}. +ðÏÓÌÅÄÎÅÅ ÒÉÓÕÅÔ ÐÕÔØ Ó ÎÁËÏÎÅÞÎÉËÏÍ ÓÔÒÅÌÙ × ÐÏÓÌÅÄÎÅÊ ÔÏÞËÅ ÐÕÔÉ. +%%This draws the given +%%path with an arrowhead at the last point on the path. +åÓÌÉ ×Ù ÈÏÔÉÔÅ ÎÁËÏÎÅÞÎÉË ÓÔÒÅÌÙ × ÎÁÞÁÌÅ ÐÕÔÉ, ÔÏ ÐÒÏÓÔÏ ÉÓÐÏÌØÚÕÊÔÅ +ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ {\tt +reverse}\index{reverse?\texttt{reverse}}\label{Drevrse}, ËÏÔÏÒÙÊ ÉÚ +ÐÕÔÉ-ÁÒÇÕÍÅÎÔÁ ÄÅÌÁÅÔ ÏÂÒÁÔÎÙÊ ÐÕÔØ ÏÔÎÏÓÉÔÅÌØÎÏ ×ÒÅÍÅÎÉ, Ô.~Å. ÄÌÑ +ÐÕÔÉ {\tt p} Ó {\tt length p}${}=n$, +$$ {\tt point\ } t {\tt\ of\ reverse\ p} + \quad \hbox{\rm É} \quad + {\tt point\ } n-t {\tt\ of\ p} +$$ --- ÓÉÎÏÎÉÍÙ. +%%If you want the +%%arrowhead at the beginning of the path, just use the unary operator {\tt +%%reverse}\index{reverse?\texttt{reverse}}\label{Drevrse} to take the +%%original path and make a new one with its time sense reversed; i.e., for +%%a path~{\tt p} with {\tt length p}${}=n$, +%%$$ {\tt point\ } t {\tt\ of\ reverse\ p} +%% \quad {\rm and} \quad +%% {\tt point\ } n-t {\tt\ of\ p} +%%$$ are synonymous. + +ëÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig36}, ËÏÍÁÎÄÁ, ÎÁÞÉÎÁÀÝÁÑÓÑ Ó +\index{drawdblarrow?\texttt{drawdblarrow}}% +\index{ÓÔÒÅÌËÉ!Ä×ÕÈËÏÎÅÞÎÙÅ}\label{Ddrwdar} +$$ {\tt drawdblarrow}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}, $$ +ÒÉÓÕÅÔ ÎÁËÏÎÅÞÎÉËÉ ÓÔÒÅÌÏË × ÏÂÏÉÈ ËÏÎÃÁÈ ÐÕÔÉ. +%%As shown in Figure~\ref{fig36}, a statement +%%beginning\index{drawdblarrow?\texttt{drawdblarrow}}% +%%\index{arrows!double-headed}\label{Ddrwdar} +%%$$ {\tt drawdblarrow}\, \descr{path expression} $$ +%%draws a double-headed arrow. +òÁÚÍÅÒ ÎÁËÏÎÅÞÎÉËÁ ÇÁÒÁÎÔÉÒÕÅÔÓÑ ÂÏÌØÛÉÍ, ÞÅÍ ÔÏÌÝÉÎÁ ÌÉÎÉÉ, ÎÏ +×ÏÚÍÏÖÎÏ ÐÏÎÁÄÏÂÉÔÓÑ ÄÏÐÏÌÎÉÔÅÌØÎÁÑ ÎÁÓÔÒÏÊËÁ ÄÌÑ ÏÞÅÎØ ÔÏÌÓÔÙÈ ÌÉÎÉÊ. +%%The size of the arrowhead is guaranteed to +%%be larger than the line width, but it might need adjusting if the line +%%width is very great. +üÔÏ ÄÅÌÁÅÔÓÑ ÐÒÉÓ×ÏÅÎÉÅÍ ÎÏ×ÏÇÏ ÚÎÁÞÅÎÉÑ ×ÎÕÔÒÅÎÎÅÊ +ÐÅÒÅÍÅÎÎÏÊ\index{×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} +{\tt ahlength}\index{ahlength?\texttt{ahlength}}\label{Dahlength}, +ËÏÔÏÒÁÑ ÏÐÒÅÄÅÌÑÅÔ ÄÌÉÎÕ ÎÁËÏÎÅÞÎÉËÁ, ËÁË ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{fig37}. +%%This is done by assigning a new value to the +%%internal variable\index{internal variables}\index{variables!internal} +%%{\tt ahlength}\index{ahlength?\texttt{ahlength}}\label{Dahlength} that +%%determines arrowhead length as shown in Figure~\ref{fig37}. +õ×ÅÌÉÞÅÎÉÅ {\tt ahlength} ÂÏÌÅÅ ÓÔÁÎÄÁÒÔÎÏÇÏ ÚÎÁÞÅÎÉÑ 4 PostScript-ÐÕÎËÔÁ +ÄÏ 1.5 ÓÁÎÔÉÍÅÔÒÏ× ÐÒÏÉÚ×ÏÄÉÔ ÂÏÌØÛÏÊ ÎÁËÏÎÅÞÎÉË ÎÁ ÒÉÓ.~\ref{fig37}. +%%Increasing +%%{\tt ahlength} from the default value of 4 PostScript points to 1.5 +%%centimeters produces the large arrowhead in Figure~\ref{fig37}. +åÓÔØ ÅÝÅ ÐÁÒÁÍÅÔÒ {\tt +ahangle}\index{ahangle?\texttt{ahangle}}\label{Dahangle}, +ËÏÎÔÒÏÌÉÒÕÀÝÉÊ ÕÇÏÌ ÎÁ ×ÅÒÈÕÛËÅ ÎÁËÏÎÅÞÎÉËÁ ÓÔÒÅÌËÉ. +%%There +%%is also an {\tt ahangle}\index{ahangle?\texttt{ahangle}}\label{Dahangle} +%%parameter that controls the angle at the tip of the arrowhead. +ôÉÐÏ×ÏÅ ÚÎÁÞÅÎÉÅ ÜÔÏÇÏ ÕÇÌÁ --- 45 ÇÒÁÄÕÓÏ×, ÞÔÏ ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓÕÎËÅ. +%%The default value of this angle is 45 degrees as shown in the figure. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-37} $$ +\caption[âÏÌØÛÏÊ ÎÁËÏÎÅÞÎÉË ÓÔÒÅÌËÉ Ó ÏÔÍÅÞÅÎÎÙÍÉ ËÌÀÞÅ×ÙÍÉ ÐÁÒÁÍÅÔÒÁÍÉ.] + {âÏÌØÛÏÊ ÎÁËÏÎÅÞÎÉË ÓÔÒÅÌËÉ Ó ÏÔÍÅÞÅÎÎÙÍÉ ËÌÀÞÅ×ÙÍÉ ÐÁÒÁÍÅÔÒÁÍÉ É + Ó ×ÙÄÅÌÅÎÎÙÍÉ ÂÅÌÙÍÉ ÌÉÎÉÑÍÉ ÐÕÔÑÍÉ ÄÌÑ ÅÇÏ ÒÉÓÏ×ÁÎÉÑ.} +%%\caption[A large arrowhead with key parameters labeled.] +%% {A large arrowhead with key parameters labeled and paths used to +%% draw it marked with white lines.} +\label{fig37} +\end{figure} + +îÁËÏÎÅÞÎÉË ÓÏÚÄÁÅÔÓÑ ÚÁÐÏÌÎÅÎÉÅÍ ÔÒÅÕÇÏÌØÎÏÊ ÏÂÌÁÓÔÉ, ×ÙÄÅÌÅÎÎÏÊ ÂÅÌÙÍ +ÎÁ ÒÉÓ.~\ref{fig37}, É ÚÁÔÅÍ ÐÒÏÒÉÓÏ×ËÏÊ ×ÏËÒÕÇ ÎÅÅ ÔÅËÕÝÉÍ ÐÅÒÏÍ. +%%The arrowhead is created by filling the triangular region that is +%%outlined in white in Figure~\ref{fig37} and then drawing around it with +%%the currently picked up pen. +üÔÁ ËÏÍÂÉÎÁÃÉÑ ÉÚ ÚÁÐÏÌÎÅÎÉÑ É ÒÉÓÏ×ÁÎÉÑ ÍÏÖÅÔ ÂÙÔØ ÏÂßÅÄÉÎÅÎÁ × +ÏÄÎÕ ËÏÍÁÎÄÕ {\tt +filldraw}\index{filldraw?\texttt{filldraw}}\label{Dfildrw}: +$$ {\tt filldraw}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\, + \descr{ÏÐÃÉÏÎÁÌØÎÙÅ {\tt dashed}, {\tt withcolor} É {\tt withpen} ÐÕÎËÔÙ}; +$$ +%%This combination of filling and drawing +%%can be combined into a single {\tt filldraw} +%%statement\index{filldraw?\texttt{filldraw}}\label{Dfildrw}: +%%$$ {\tt filldraw}\, \descr{path expression}\, +%% \descr{optional {\tt dashed} and {\tt withcolor} and {\tt withpen} clauses}; +%%$$ +\tdescr{÷ÙÒÁÖÅÎÉÅ-ÐÕÔØ} ÄÏÌÖÎÏ ÂÙÔØ ÚÁÍËÎÕÔÙÍ ÃÉËÌÏÍ, ÐÏÄÏÂÎÙÍ +ÔÒÅÕÇÏÌØÎÏÍÕ ÐÕÔÉ ÎÁ ÒÉÓ.~\ref{fig37}. +%%The \tdescr{path expression} should be a closed cycle like the +%%triangular path in Figure~\ref{fig37}. +üÔÏÔ ÐÕÔØ ÎÅ ÓÌÅÄÕÅÔ ÓÍÅÛÉ×ÁÔØ Ó ÁÒÇÕÍÅÎÔÏÍ-ÐÕÔÅÍ Ë {\tt drawarrow}, +ËÏÔÏÒÙÊ ÉÚÏÂÒÁÖÅÎ ÂÅÌÏÊ ÌÉÎÉÅÊ ÎÁ ÒÉÓÕÎËÅ. +%%This path should not be confused +%%with the path argument to {\tt drawarrow} which is indicated by a white +%%line in the figure. + +âÅÌÙÅ ÌÉÎÉÉ, ÐÏÄÏÂÎÙÅ ÔÅÍ, ÞÔÏ ÎÁ ÒÉÓÕÎËÅ, ÍÏÇÕÔ ÓÏÚÄÁ×ÁÔØÓÑ ËÏÍÁÎÄÏÊ +{\tt undraw}\index{undraw?\texttt{undraw}}\label{Dundraw}. +%%White lines like the ones in the figure can be created by an {\tt +%%undraw}\index{undraw?\texttt{undraw}}\label{Dundraw} statement. +üÔÏ ÓÔÉÒÁÀÝÁÑ\index{ÓÔÉÒÁÎÉÅ} ×ÅÒÓÉÑ {\tt draw}, ËÏÔÏÒÁÑ ÉÓÐÏÌØÚÕÅÔ {\tt +withcolor background}\index{background?\texttt{background}} ÔÁË ÖÅ, ËÁË É +ËÏÍÁÎÄÁ {\tt unfill}. +%%This is +%%an erasing\index{erasing} version of {\tt draw} that draws {\tt +%%withcolor background}\index{background?\texttt{background}} just as the +%%{\tt unfill} statement does. +åÓÔØ ÅÝÅ ËÏÍÁÎÄÁ {\tt +unfilldraw}\index{unfilldraw?\texttt{unfilldraw}}\label{Dunfdrw} +ËÁË ÒÁÚ ÄÌÑ ÓÌÕÞÁÑ, ËÏÔÏÒÙÊ ÓÌÅÄÕÅÔ ÉÚ ÅÅ ÎÁÚ×ÁÎÉÑ. +%%There is also an {\tt +%%unfilldraw}\index{unfilldraw?\texttt{unfilldraw}}\label{Dunfdrw} +%%statement just in case someone finds a use for it. + +ëÏÍÁÎÄÙ {\tt filldraw}, {\tt undraw}, {\tt unfilldraw} É ×ÓÅ ËÏÍÁÎÄÙ +ÄÌÑ ÒÉÓÏ×ÁÎÉÑ ÓÔÒÅÌÏË ÐÏÄÏÂÎÙ ËÏÍÁÎÄÁÍ {\tt fill} É {\tt draw} +× ÔÏÍ, ÞÔÏ ÏÎÉ ÍÏÇÕÔ ÉÍÅÔØ ÏÐÃÉÉ {\tt dashed}\index{dashed?\texttt{dashed}}, +{\tt withpen}\index{withpen?\texttt{withpen}} É {\tt +withcolor}\index{withcolor?\texttt{withcolor}}. +%%The {\tt filldraw}, {\tt undraw} and {\tt unfilldraw} statements and all +%%the arrow drawing statements are like the {\tt fill} and {\tt draw} +%%statements in that they take {\tt dashed}\index{dashed?\texttt{dashed}}, +%%{\tt withpen}\index{withpen?\texttt{withpen}}, and {\tt +%%withcolor}\index{withcolor?\texttt{withcolor}} options. +ëÏÇÄÁ Õ ×ÁÓ ÉÍÅÅÔÓÑ ÍÎÏÇÏ ËÏÍÁÎÄ ÒÉÓÏ×ÁÎÉÑ, ÔÏ ÕÄÏÂÎÏ ÉÍÅÔØ ×ÏÚÍÏÖÎÏÓÔØ +ÐÒÉÍÅÎÉÔØ ÏÐÃÉÀ, ÔÁËÕÀ ËÁË {\tt withcolor 0.8white}, ËÏ ×ÓÅÍ ÎÉÍ ÂÅÚ +ÐÏ×ÔÏÒÅÎÉÑ ÅÅ ×ÓÑËÉÊ ÒÁÚ, ËÁË ÎÁ ÒÉÓÕÎËÁÈ \ref{fig33} É~\ref{fig34}. +%%When you have a +%%lot of drawing statements it is nice to be able to apply an option such +%%as {\tt withcolor 0.8white} to all of them without having to type this +%%repeatedly as was done in Figures \ref{fig33} and~\ref{fig34}. +ëÏÍÁÎÄÁ ÄÌÑ ÜÔÏÊ ÃÅÌÉ ÎÁÚÙ×ÁÅÔÓÑ\index{drawoptions?\texttt{drawoptions}}\label{Ddropts} +$$ \hbox{\tt drawoptions(} \descr{ÔÅËÓÔ} \hbox{\tt )}, $$ +ÇÄÅ ÁÒÇÕÍÅÎÔ \tdescr{ÔÅËÓÔ} ÄÁÅÔ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÏÐÃÉÊ {\tt dashed}, +{\tt withcolor} É {\tt withpen}, ËÏÔÏÒÙÅ ÐÒÉÍÅÎÑÀÔ Á×ÔÏÍÁÔÉÞÅÓËÉ ËÏ +×ÓÅÍ ÒÉÓÕÀÝÉÍ ËÏÍÁÎÄÁÍ. +%%The statement for this purpose +%%is\index{drawoptions?\texttt{drawoptions}}\label{Ddropts} +%%$$ \hbox{\tt drawoptions(} \descr{text} \hbox{\tt )} $$ +%%where the \tdescr{text} argument gives a sequence of {\tt dashed}, {\tt +%%withcolor}, and {\tt withpen} options to be applied automatically to all +%%drawing statements. +åÓÌÉ ×Ù ÕËÁÖÉÔÅ +$$ \hbox{\tt drawoptions(withcolor .5[black,white])} $$ +É ÚÁÔÅÍ ÚÁÈÏÔÉÔÅ ÎÁÒÉÓÏ×ÁÔØ ÞÅÒÎÕÀ ÌÉÎÉÀ, ÔÏ ×ÁÍ ÐÒÉÄÅÔÓÑ +ÐÅÒÅÕÓÔÁÎÏ×ÉÔØ {\tt drawoptions} ÕËÁÚÁÎÉÅÍ +$$ {\tt draw}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\, {\tt withcolor\ black}. $$ +%%If you specify +%%$$ \hbox{\tt drawoptions(withcolor .5[black,white])} $$ +%%and then want to draw a black line, you can override the {\tt drawoptions} +%%by specifying +%%$$ {\tt draw}\, \descr{path expression}\, {\tt withcolor\ black} $$ +äÌÑ ÏÔËÌÀÞÅÎÉÑ ×ÓÅÈ ÐÏÓÌÅÄÓÔ×ÉÊ {\tt drawoptions} ÐÒÏÓÔÏ ÉÓÐÏÌØÚÕÊÔÅ +ÐÕÓÔÏÊ ÓÐÉÓÏË-ÁÒÇÕÍÅÎÔ: +$$ \hbox{\tt drawoptions()}. $$ +%%To turn off {\tt drawoptions} all together, just give an empty list: +%%$$ \hbox{\tt drawoptions()} $$ +(üÔÏ ÄÅÌÁÅÔÓÑ Á×ÔÏÍÁÔÉÞÅÓËÉ ÍÁËÒÏÓÏÍ {\tt +beginfig}\index{beginfig?\texttt{beginfig}}.) +%%(This is done automatically by the {\tt +%%beginfig}\index{beginfig?\texttt{beginfig}} macro). + +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÎÅ×ÅÒÎÙÅ ÏÐÃÉÉ ÉÇÎÏÒÉÒÕÀÔÓÑ, ÎÅ ÂÕÄÅÔ ×ÒÅÄÁ ÏÔ +ËÏÍÁÎÄÙ, ÐÏÄÏÂÎÏÊ +$$ \hbox{\tt drawoptions(dashed evenly)}, $$ +ÚÁ ËÏÔÏÒÏÊ ÉÄÅÔ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ËÏÍÁÎÄ {\tt draw} É {\tt fill}. +%%Since irrelevant options are ignored, there is no harm in giving a statement +%%like +%%$$ \hbox{\tt drawoptions(dashed evenly)} $$ +%%followed by a sequence of {\tt draw} and {\tt fill} commands. +îÅ ÉÍÅÅÔ ÓÍÙÓÌÁ ÉÓÐÏÌØÚÏ×ÁÔØ ÏÂÒÁÚÅà ÌÉÎÉÉ ÐÒÉ ÚÁÌÉ×ËÅ, ÐÏÜÔÏÍÕ +{\tt dashed evenly} ÉÇÎÏÒÉÒÕÅÔÓÑ ÄÌÑ ËÏÍÁÎÄ {\tt fill}. +%%It does +%%not make sense to use a dash pattern when filling so the {\tt dashed +%%evenly} gets ignored for {\tt fill} statements. +ïÞÅ×ÉÄÎÏ, ÞÔÏ +$$ \hbox{\tt drawoptions(withpen } \descr{×ÙÒÁÖÅÎÉÅ-ÐÅÒÏ} \hbox{\tt )} $$ +×ÌÉÑÅÔ ÎÁ ËÏÍÁÎÄÙ {\tt fill} É {\tt draw}. +%%It turns out that +%%$$ \hbox{\tt drawoptions(withpen } \descr{pen expression} \hbox{\tt )} $$ +%%does affect {\tt fill} statements as well as {\tt draw} statements. +æÁËÔÉÞÅÓËÉ ÓÕÝÅÓÔ×ÕÅÔ ÓÐÅÃÉÁÌØÎÁÑ ÐÅÒÅÍÅÎÎÁÑ-ÐÅÒÏ Ó ÉÍÅÎÅÍ +{\tt currentpen}\index{currentpen?\texttt{currentpen}} ÔÁËÁÑ, ÞÔÏ +{\tt fill} \ldots\ {\tt withpen currentpen} ÜË×É×ÁÌÅÎÔÎÏ +ËÏÍÁÎÄÅ {\tt filldraw}. +%%In fact there is a special pen variable called +%%{\tt currentpen}\index{currentpen?\texttt{currentpen}} such that +%%{\tt fill} \ldots\ {\tt withpen currentpen} is equivalent to a {\tt filldraw} +%%statement. + +ôÁË ÞÔÏ ÖÅ ÔÏÞÎÏ ÚÎÁÞÉÔ ÓËÁÚÁÔØ, ÞÔÏ ÏÐÃÉÉ ÒÉÓÏ×ÁÎÉÑ ×ÌÉÑÀÔ ÎÁ +ËÏÍÁÎÄÙ ÔÏÇÄÁ, ËÏÇÄÁ ÜÔÏ ÉÍÅÅÔ ÓÍÙÓÌ? +%%Precisely what does it mean to say that drawing options affect those +%%statements where they make sense? +ïÐÃÉÑ {\tt dashed} \tdescr{ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ} ×ÌÉÑÅÔ ÔÏÌØËÏ ÎÁ ËÏÍÁÎÄÙ +$$ {\tt draw}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}, $$ +Á ÐÏÑ×ÌÅÎÉÅ ÔÅËÓÔÁ × ÁÒÇÕÍÅÎÔÅ ÔÉÐÁ \tdescr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ} ÄÌÑ +ËÏÍÁÎÄÙ +$$ {\tt draw}\, \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ} $$ +ÍÅÎÑÅÔÓÑ ÔÏÌØËÏ ÏÐÃÉÅÊ {\tt withcolor} \tdescr{×ÙÒÁÖÅÎÉÅ-Ã×ÅÔ}. +%%The {\tt dashed} \tdescr{dash +%%pattern} option only affects +%%$$ {\tt draw}\, \descr{path expression} $$ +%%statements, and text appearing in the \tdescr{picture expression} argument to +%%$$ {\tt draw}\, \descr{picture expression} $$ +%%statement is only affected by the {\tt withcolor} \tdescr{color +%%expression} option. +÷Ï ×ÓÅÈ ÄÒÕÇÉÈ ËÏÍÂÉÎÁÃÉÑÈ ËÏÍÁÎÄ É ÏÐÃÉÊ ÒÉÓÏ×ÁÎÉÑ ÅÓÔØ ÎÅËÏÔÏÒÙÊ +ÜÆÆÅËÔ. +%%For all other combinations of drawing statements +%%and options, there is some effect. +ïÐÃÉÑ, ÐÒÉÍÅÎÅÎÎÁÑ Ë ËÏÍÁÎÄÅ {\tt draw} \tdescr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ}, +ÂÕÄÅÔ, ×ÏÏÂÝÅ ÇÏ×ÏÒÑ, ×ÌÉÑÔØ ÎÁ ÎÅËÏÔÏÒÙÅ ÞÁÓÔÉ ÒÉÓÕÎËÁ, ÎÏ ÎÅ ×ÓÅ. +%%An option applied to a {\tt draw} +%%\tdescr{picture expression} statement will in general affect some parts +%%of the picture but not others. +îÁÐÒÉÍÅÒ, ÏÐÃÉÉ {\tt dashed} ÉÌÉ {\tt withpen} ÂÕÄÕÔ ×ÌÉÑÔØ ÎÁ ×ÓÅ ÌÉÎÉÉ, +ÎÏ ÎÅ ÎÁ ÍÅÔËÉ. +%%For instance, a {\tt dashed} or {\tt +%%withpen} option will affect all the lines in the picture but none of the +%%labels. + +\subsection{ðÅÒØÑ} +%%\subsection{Pens} +\label{sec.pens} + +ðÒÅÄÙÄÕÝÉÅ ÒÁÚÄÅÌÙ ÄÁÌÉ ÍÎÏÖÅÓÔ×Ï ÐÒÉÍÅÒÏ× ÔÉÐÁ {\tt pickup} +\tdescr{×ÙÒÁÖÅÎÉÅ-ÐÅÒÏ} É {\tt withpen} \tdescr{×ÙÒÁÖÅÎÉÅ-ÐÅÒÏ}, ÎÏ +ÎÅ ÂÙÌÏ ÐÒÉÍÅÒÏ×, ÏÔÌÉÞÎÙÈ ÏÔ +$$ {\tt pencircle\ scaled}\, \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}, $$ +ÞÔÏ ÓÏÚÄÁ×ÁÌÉ ÌÉÎÉÉ ÕËÁÚÁÎÎÏÊ ÔÏÌÝÉÎÙ. +%%Previous sections have given numerous examples of {\tt pickup} +%%\tdescr{pen expression} and {\tt withpen} \tdescr{pen expression}, but +%%there have not been any examples of pen expressions other than +%%$$ {\tt pencircle\ scaled}\, \descr{numeric primary} $$ +%%which produces lines of a specified width. +äÌÑ ËÁÌÌÉÇÒÁÆÉÞÅÓËÉÈ ÜÆÆÅËÔÏ×, ÔÁËÉÈ ËÁË ÎÁ ÒÉÓ.~\ref{fig38}, ×Ù +ÍÏÖÅÔÅ ÐÒÉÍÅÎÑÔØ ÌÀÂÙÅ ÔÒÁÎÓÆÏÒÍÁÃÉÏÎÎÙÅ ÏÐÅÒÁÔÏÒÙ, ÏÂÓÕÖÄÁÅÍÙÅ × +ÒÁÚÄÅÌÅ~\ref{transsec}. +%%For calligraphic effects +%%such in Figure~\ref{fig38}, you can apply any of the transformation +%%operators discussed in Section~\ref{transsec}. +ïÔÐÒÁ×ÎÏÊ ÔÏÞËÏÊ ÄÌÑ ÔÁËÉÈ ÔÒÁÎÓÆÏÒÍÁÃÉÊ ÓÌÕÖÉÔ {\tt +pencircle}\index{pencircle?\texttt{pencircle}}\label{Dpncirc} --- +ËÒÕÇ ÄÉÁÍÅÔÒÏÍ ÏÄÉÎ PostScript ÐÕÎËÔ. +%%The starting point for +%%such transformations is {\tt +%%pencircle}\index{pencircle?\texttt{pencircle}}\label{Dpncirc}, a circle +%%one PostScript point in diameter. +ðÏÜÔÏÍÕ ÁÆÆÉÎÎÙÅ ÔÒÁÎÓÆÏÒÍÁÃÉÉ ÐÒÏÉÚ×ÏÄÑÔ ËÒÕÇÏ×ÕÀ ÉÌÉ +ÜÌÌÉÐÔÉÞÅÓËÕÀ\index{ÐÅÒØÑ!ÜÌÌÉÐÔÉÞÅÓËÉÅ} ÆÏÒÍÕ ÐÅÒÁ. +%%Thus affine transformations produce a +%%circular or elliptical\index{pens!elliptical} pen shape. +ôÏÌÝÉÎÁ ÌÉÎÉÉ, ÒÉÓÕÅÍÏÊ ÐÅÒÏÍ, ÚÁ×ÉÓÉÔ ÏÔ ÔÏÇÏ, ÎÁÓËÏÌØËÏ ÐÅÒÐÅÎÄÉËÕÌÑÒÎÁ +ÌÉÎÉÑ ÂÏÌØÛÅÊ ÏÓÉ ÜÌÌÉÐÓÁ. +%%The width of +%%lines drawn with the pen depends on how nearly perpendicular the line is +%%to the long axis of the ellipse. + +\begin{figure}[htp] +$$\begin{verbatim} +beginfig(38); +pickup pencircle scaled .2in yscaled .08 rotated 30; +x0=x3=x4; +z1-z0 = .45in*dir 30; +z2-z3 = whatever*(z1-z0); +z6-z5 = whatever*(z1-z0); +z1-z6 = 1.2*(z3-z0); +rt x3 = lft x2; +x5 = .55[x4,x6]; +y4 = y6; +lft x3 = bot y5 = 0; +top y2 = .9in; +draw z0--z1--z2--z3--z4--z5--z6 withcolor .7white; +dotlabels.top(0,1,2,3,4,5,6); +endfig; +\end{verbatim} +\quad \mathcenter{\includegraphics{manfig-ru-38}} +$$ +\caption{ëÏÄ MetaPost É ``ËÁÌÌÉÇÒÁÆÉÞÅÓËÉÊ'' ÒÉÓÕÎÏË-ÒÅÚÕÌØÔÁÔ.} +%%\caption{MetaPost code and the resulting ``calligraphic'' figure.} +\label{fig38}\index{lft?\texttt{lft}}\index{bot?\texttt{bot}}\index{top?\texttt{top}} +\end{figure} + +òÉÓ.~\ref{fig38} ÄÅÍÏÎÓÔÒÉÒÕÅÔ ÏÐÅÒÁÔÏÒÙ {\tt +lft}\index{lft?\texttt{lft}}\label{Dlft}, {\tt +rt}\index{rt?\texttt{rt}}\label{Drt}, {\tt +top}\index{top?\texttt{top}}\label{Dtop} É {\tt +bot}\index{bot?\texttt{bot}}\label{Dbot}, ÏÔ×ÅÞÁÀÝÉÅ ÎÁ ×ÏÐÒÏÓ: +``åÓÌÉ ÔÅËÕÝÅÅ ÐÅÒÏ ÐÏÍÅÓÔÉÔØ × ÚÁÄÁÎÎÕÀ ÁÒÇÕÍÅÎÔÏÍ ÐÏÚÉÃÉÀ, ÔÏ ÇÄÅ +ÂÕÄÕÔ ÎÁÈÏÄÉÔØÓÑ ÌÅ×ÙÊ, ÐÒÁ×ÙÊ, ×ÅÒÈÎÉÊ ÉÌÉ ÎÉÖÎÉÊ ËÒÁÊ?'' +%%Figure~\ref{fig38} demonstrates operators {\tt +%%lft}\index{lft?\texttt{lft}}\label{Dlft}, {\tt +%%rt}\index{rt?\texttt{rt}}\label{Drt}, {\tt +%%top}\index{top?\texttt{top}}\label{Dtop}, and {\tt +%%bot}\index{bot?\texttt{bot}}\label{Dbot} that answer the question, ``If +%%the current pen is placed at the position given by the argument, where +%%will its left, right, top, or bottom edge be?'' +îÁ ÜÔÏÍ ÒÉÓÕÎËÅ ÔÅËÕÝÅÅ ÐÅÒÏ Ñ×ÌÑÅÔÓÑ ÜÌÌÉÐÓÏÍ, ÚÁÄÁÎÎÙÍ ËÏÍÁÎÄÏÊ +{\tt pickup}, É ÅÇÏ ÏÈ×ÁÔÙ×ÁÀÝÁÑ ÒÁÍËÁ ÒÁ×ÎÁ 0.1734 ÄÀÊÍÁ ÛÉÒÉÎÙ É +0.101 ÄÀÊÍÁ ×ÙÓÏÔÙ, ÐÏÜÔÏÍÕ {\tt rt +x3} ÒÁ×ÎÏ ${\tt x3}+{\tt 0.0867in}$ É {\tt bot y5} ÒÁ×ÎÏ ${\tt y5}-{\tt +0.0505in}$. +%%In this case the +%%current pen is the ellipse given in the {\tt pickup} statement and its +%%bounding box is 0.1734 inches wide and 0.1010 inches high, so {\tt rt +%%x3} is ${\tt x3}+{\tt 0.0867in}$ and {\tt bot y5} is ${\tt y5}-{\tt +%%0.0505in}$. +ïÐÅÒÁÔÏÒÙ {\tt lft}, {\tt rt}, {\tt top} É {\tt bot} ÍÏÇÕÔ ÔÁËÖÅ ÉÍÅÔØ +ÁÒÇÕÍÅÎÔ ÔÉÐÁ ÐÁÒÁ --- × ÜÔÏÍ ÓÌÕÞÁÅ ÏÎÉ ×ÙÞÉÓÌÑÀÔ ËÏÏÒÄÉÎÁÔÙ $x$ +É~$y$ ÎÁÉÂÏÌÅÅ ÌÅ×ÏÊ, ÐÒÁ×ÏÊ, ×ÅÒÈÎÅÊ ÉÌÉ ÎÉÖÎÅÊ ÔÏÞËÉ ÆÏÒÍÙ ÐÅÒÁ. +%%The {\tt lft}, {\tt rt}, {\tt top}, and {\tt bot} operators +%%also accept arguments of type pair in which case they compute the $x$ +%%and~$y$ coordinates of the leftmost, rightmost, topmost, or bottommost +%%point on the pen shape. +îÁÐÒÉÍÅÒ, +$$ {\tt rt}(x,y) = (x,y)+({\tt 0.0867in}, {\tt 0.0496in}) $$ +ÄÌÑ ÐÅÒÁ ÎÁ ÒÉÓ.~\ref{fig38}. +%%For example, +%%$$ {\tt rt}(x,y) = (x,y)+({\tt 0.0867in}, {\tt 0.0496in}) $$ +%%for the pen in Figure~\ref{fig38}. +úÁÍÅÔØÔÅ, ÞÔÏ {\tt +beginfig}\index{beginfig?\texttt{beginfig}} ÓÂÒÁÓÙ×ÁÅÔ ÔÅËÕÝÅÅ ÐÅÒÏ Ë +ÓÔÁÎÄÁÒÔÎÏÍÕ ÚÎÁÞÅÎÉÀ +$$ \hbox{\tt pencircle scaled 0.5bp} $$ +× ÎÁÞÁÌÅ ËÁÖÄÏÊ ÆÉÇÕÒÙ. +%%Note that {\tt +%%beginfig}\index{beginfig?\texttt{beginfig}} resets the current pen to a +%%default value of +%%$$ \hbox{\tt pencircle scaled 0.5bp} $$ +%%at the beginning of each figure. +üÔÏ ÚÎÁÞÅÎÉÅ ÍÏÖÅÔ ÂÙÔØ ÔÁËÖÅ ×ÙÂÒÁÎÏ × ÌÀÂÏÅ ×ÒÅÍÑ ËÏÍÁÎÄÏÊ {\tt pickup +defaultpen}\index{defaultpen?\texttt{defaultpen}}\label{Ddefaultpen}. +%%This value can be reselected at any +%%time by giving the command {\tt pickup +%%defaultpen}\index{defaultpen?\texttt{defaultpen}}\label{Ddefaultpen}. + +úÄÅÓØ ÍÏÇ ÂÙ ÂÙÔØ ËÏÎÅà ÉÓÔÏÒÉÉ Ï ÐÅÒØÑÈ, ÎÏ +ÄÌÑ ÓÏ×ÍÅÓÔÉÍÏÓÔÉ Ó \MF\index{metafont?\MF}, MetaPost ÔÁËÖÅ ÄÏÐÕÓËÁÅÔ +ÍÎÏÇÏÕÇÏÌØÎÙÅ ÆÏÒÍÙ\index{ÐÅÒØÑ!ÍÎÏÇÏÕÇÏÌØÎÙÅ} ÐÅÒØÅ×. +%%This would be the end of the story on pens, except that for +%%compatibility with \MF\index{metafont?\MF}, MetaPost also allows pen +%%shapes to be polygonal\index{pens!polygonal}. +åÓÔØ ÓÔÁÎÄÁÒÔÎÏÅ ÐÅÒÏ Ó ÉÍÅÎÅÍ +{\tt pensquare}\index{pensquare?\texttt{pensquare}}\label{Dpnsqr}, +ËÏÔÏÒÏÅ ÍÏÖÎÏ ÔÒÁÎÓÆÏÒÍÉÒÏ×ÁÔØ × ÐÅÒÏ × ÆÏÒÍÅ ÐÁÒÁÌÌÅÌÏÇÒÁÍÍÁ. +%%There is a predefined pen +%%called {\tt pensquare}\index{pensquare?\texttt{pensquare}}\label{Dpnsqr} +%%that can be transformed to yield pens shaped like parallelograms. +æÁËÔÉÞÅÓËÉ ÅÓÔØ ÄÁÖÅ ÏÐÅÒÁÔÏÒ, ÎÁÚÙ×ÁÅÍÙÊ {\tt +makepen}\index{makepen?\texttt{makepen}}\label{Dmkpen}, ÂÅÒÕÝÉÊ +ÐÕÔØ × ÆÏÒÍÅ ×ÙÐÕËÌÏÇÏ ÍÎÏÇÏÕÇÏÌØÎÉËÁ É ÄÅÌÁÀÝÉÊ ÐÅÒÏ ÔÁËÏÊ ÖÅ ÆÏÒÍÙ +É ÒÁÚÍÅÒÁ. +%%In fact, there is even an operator called {\tt +%%makepen}\index{makepen?\texttt{makepen}}\label{Dmkpen} that takes a +%%convex-polygon-shaped path and makes a pen that shape and size. +åÓÌÉ ÐÕÔØ ÎÅ ÓÔÒÏÇÏ ×ÙÐÕËÌÙÊ ÉÌÉ ÍÎÏÇÏÕÇÏÌØÎÙÊ, ÔÏ ÏÐÅÒÁÔÏÒ +{\tt makepen} ÂÕÄÅÔ ÓÐÒÑÍÌÑÔØ ËÒÁÑ É/ÉÌÉ ÓÂÒÁÓÙ×ÁÔØ ÎÅËÏÔÏÒÙÅ ×ÅÒÛÉÎÙ. +%%If the +%%path is not exactly convex or polygonal, the {\tt makepen} operator will +%%straighten the edges and/or drop some of the vertices. +÷ ÞÁÓÔÎÏÓÔÉ, {\tt pensquare} ÜË×É×ÁÌÅÎÔÎÏ +$$ \hbox{\tt makepen((-.5,-.5)-{}-(.5,-.5)-{}-(.5,.5)-{}-(-.5,.5)-{}-cycle)} $$ +%%In particular, {\tt pensquare} is equivalent to +%%$$ \hbox{\tt makepen((-.5,-.5)--(.5,-.5)--(.5,.5)--(-.5,.5)--cycle)} $$ +ëÏÍÁÎÄÙ {\tt pensquare} É {\tt makepen} ÎÅ ÄÏÌÖÎÙ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ Ó +ÏÂÒÁÚÃÁÍÉ ÐÕÎËÔÉÒÁ. +%%{\tt pensquare} and {\tt makepen} should not be used with dash +%%patterns. +óÍ. ËÏÎÅà ÒÁÚÄÅÌÁ~\ref{sec.pens}, ÓÔÒ. \pageref{dashed-pens}. +%%See the end of Section~\ref{sec.pens}, p.\ \pageref{dashed-pens}. + +ïÂÒÁÔÎÙÍ Ë {\tt makepen} Ñ×ÌÑÅÔÓÑ ÏÐÅÒÁÔÏÒ {\tt +makepath}\index{makepath?\texttt{makepath}}\label{Dmkpath}, ËÏÔÏÒÙÊ +ÂÅÒÅÔ \tdescr{ÐÅÒÏ-ÐÅÒ×ÉÞÎÏÓÔØ} É ×ÏÚ×ÒÁÝÁÅÔ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ÐÕÔØ. +%%The inverse of {\tt makepen} is the {\tt +%%makepath}\index{makepath?\texttt{makepath}}\label{Dmkpath} operator that +%%takes a \tdescr{pen primary} and returns the corresponding path. +ðÏÜÔÏÍÕ {\tt makepath pencircle} ÐÒÏÉÚ×ÏÄÉÔ ËÒÕÇÏ×ÏÊ ÐÕÔØ, ÉÄÅÎÔÉÞÎÙÊ {\tt +fullcircle}\index{fullcircle?\texttt{fullcircle}}. +%%Thus +%%{\tt makepath pencircle} produces a circular path identical to {\tt +%%fullcircle}\index{fullcircle?\texttt{fullcircle}}. +üÔÏ ÔÁËÖÅ ÒÁÂÏÔÁÅÔ ÄÌÑ ÍÎÏÇÏÕÇÏÌØÎÏÇÏ ÐÅÒÁ, ÔÁË ÞÔÏ +$$ {\tt makepath\ makepen}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} $$ +ÂÕÄÅÔ ÂÒÁÔØ ÌÀÂÏÊ ÃÉËÌÉÞÅÓËÉÊ ÐÕÔØ É ÏÂÒÁÝÁÔØ ÅÇÏ × ×ÙÐÕËÌÙÊ +ÍÎÏÇÏÕÇÏÌØÎÉË\index{×ÙÐÕËÌÙÅ ÍÎÏÇÏÕÇÏÌØÎÉËÉ}. +%%This also works for +%%a polygonal pen so that +%%$$ {\tt makepath\ makepen}\, \descr{path expression} $$ +%%will take any cyclic path and turn it into a convex polygon\index{convex %%polygons}. + +\subsection{÷ÙÒÅÚËÁ É ÎÉÚËÏÕÒÏ×ÎÅ×ÙÅ ËÏÍÁÎÄÙ ÒÉÓÏ×ÁÎÉÑ} +%%\subsection{Clipping and Low-Level Drawing Commands} + +ëÏÍÁÎÄÙ ÒÉÓÏ×ÁÎÉÑ, ÔÁËÉÅ ËÁË {\tt draw}, {\tt fill}, {\tt filldraw} É +{\tt unfill}, --- ÜÔÏ ÞÁÓÔÉ ÍÁËÒÏÐÁËÅÔÁ Plain\index{ÍÁËÒÏÓÙ Plain}, +ÏÐÒÅÄÅÌÅÎÎÙÅ ÞÅÒÅÚ ÂÏÌÅÅ ÐÒÉÍÉÔÉ×ÎÙÅ ËÏÍÁÎÄÙ. +%%Drawing statements such as {\tt draw}, {\tt fill}, {\tt filldraw}, and +%%{\tt unfill} are part of the Plain macro\index{Plain macros} package and +%%are defined in terms of more primitive statements. +ïÓÎÏ×ÎÁÑ ÒÁÚÎÉÃÁ ÍÅÖÄÕ ËÏÍÁÎÄÁÍÉ ÒÉÓÏ×ÁÎÉÑ, ÒÁÓÓÍÏÔÒÅÎÎÙÍÉ × +ÐÒÅÄÙÄÕÝÉÈ ÒÁÚÄÅÌÁÈ, É ÂÏÌÅÅ ÐÒÉÍÉÔÉ×ÎÙÍÉ × ÔÏÍ, ÞÔÏ ×ÓÅ ÐÒÉÍÉÔÉ×ÎÙÅ +ËÏÍÁÎÄÙ ÒÉÓÏ×ÁÎÉÑ ÔÒÅÂÕÀÔ ÕËÁÚÁÎÉÑ ÐÅÒÅÍÅÎÎÏÊ-ËÁÒÔÉÎËÉ ÄÌÑ ÈÒÁÎÅÎÉÑ +ÒÅÚÕÌØÔÁÔÏ×. +%%The main difference +%%between the drawing statements discussed in previous sections and the +%%more primitive versions is that the primitive drawing statements all +%%require you to specify a picture variable to hold the results. +äÌÑ ËÏÍÁÎÄ {\tt fill}, {\tt draw} É ÒÏÄÓÔ×ÅÎÎÙÈ ÉÍ, ÒÅÚÕÌØÔÁÔÙ ×ÓÅÇÄÁ +ÎÁÐÒÁ×ÌÑÀÔÓÑ × ÐÅÒÅÍÅÎÎÕÀ-ËÁÒÔÉÎËÕ Ó ÉÍÅÎÅÍ {\tt +currentpicture}\index{currentpicture?\texttt{currentpicture}}\label{Dcurpic}. +%%For {\tt +%%fill}, {\tt draw}, and related statements, the results always go to a +%%picture variable called {\tt +%%currentpicture}\index{currentpicture?\texttt{currentpicture}}\label{Dcurpic}. +óÉÎÔÁËÓÉÓ ÄÌÑ ÐÒÉÍÉÔÉ×ÎÙÈ ËÏÍÁÎÄ ÒÉÓÏ×ÁÎÉÑ, ÐÏÚ×ÏÌÑÀÝÉÊ ÕËÁÚÙ×ÁÔØ +ÐÅÒÅÍÅÎÎÕÀ-ËÁÒÔÉÎËÕ, ÐÏËÁÚÁÎ ÎÁ ÒÉÓ.~\ref{sydraw}. +%%The syntax for the primitive drawing statements that allow you to +%%specify a picture variable is shown in Figure~\ref{sydraw}. + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ËÏÍÁÎÄÁ addto} \rightarrow$\\ +%%$\tt \descr{addto command} \rightarrow$\\ +$\tt \qquad addto \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ} also + \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \qquad addto \descr{picture variable} also +%% \descr{picture expression} \descr{option list}$\\ +$\tt \qquad \;|\; addto \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ} + contour \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \qquad \;|\; addto \descr{picture variable} +%% contour \descr{path expression} \descr{option list}$\\ +$\tt \qquad \;|\; addto \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ} + doublepath \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \qquad \;|\; addto \descr{picture variable} +%% doublepath \descr{path expression} \descr{option list}$\\ +$\tt \descr{ÓÐÉÓÏË ÏÐÃÉÊ} \rightarrow \descr{ÐÕÓÔÏ} \;|\; + \descr{ÏÐÃÉÑ ÒÉÓÏ×ÁÎÉÑ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \descr{option list} \rightarrow \descr{empty} \;|\; +%% \descr{drawing option} \descr{option list}$\\ +$\tt \descr{ÏÐÃÉÑ ÒÉÓÏ×ÁÎÉÑ} \rightarrow withcolor \descr{×ÙÒÁÖÅÎÉÅ-Ã×ÅÔ}$\\ +%%$\tt \descr{drawing option} \rightarrow withcolor \descr{color expression}$\\ +$\tt \qquad \;|\; withrgbcolor \descr{×ÙÒÁÖÅÎÉÅ-rgb-Ã×ÅÔ} \;|\; + withcmykcolor \descr{×ÙÒÁÖÅÎÉÅ-cmyk-Ã×ÅÔ}$\\ +%%$\tt \qquad \;|\; withrgbcolor \descr{rgbcolor expression} \;|\; +%% withcmykcolor \descr{cmykcolor expression}$\\ +$\tt \qquad \;|\; withgreyscale \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} \;|\; + withoutcolor$\\ +%%$\tt \qquad \;|\; withgreyscale \descr{numeric expression} \;|\; +%% withoutcolor$\\ +$\tt \qquad \;|\; withprescript \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} \;|\; + withpostscript \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; withprescript \descr{string expression} \;|\; +%% withpostscript \descr{string expression}$\\ +$\tt \qquad \;|\; withpen \descr{×ÙÒÁÖÅÎÉÅ-ÐÅÒÏ} \;|\; + dashed \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ}$ +%%$\tt \qquad \;|\; withpen \descr{pen expression} \;|\; +%% dashed \descr{picture expression}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ÄÌÑ ÐÒÉÍÉÔÉ×ÎÙÈ ËÏÍÁÎÄ ÒÉÓÏ×ÁÎÉÑ} +%%\caption{The syntax for primitive drawing statements} +\label{sydraw} +\index{ÓÐÉÓÏË ÏÐÃÉÊ?\tdescr{ÓÐÉÓÏË ÏÐÃÉÊ}}\index{addto also?\texttt{addto also}}\index{addto contour?\texttt{addto contour}}% +\index{addto doublepath?\texttt{addto doublepath}}\index{withcolor?\texttt{withcolor}}\index{withpen?\texttt{withpen}}% +\index{dashed?\texttt{dashed}}\index{ÏÐÃÉÉ ÒÉÓÏ×ÁÎÉÑ?\tdescr{ÏÐÃÉÉ ÒÉÓÏ×ÁÎÉÑ}} +\end{figure} + +óÉÎÔÁËÓÉÓ ÄÌÑ ÐÒÉÍÉÔÉ×ÎÙÈ ËÏÍÁÎÄ ÒÉÓÏ×ÁÎÉÑ ÓÏ×ÍÅÓÔÉÍ Ó +\MF\index{metafont?\MF}. +%%The syntax for primitive drawing commands is compatible with +%%\MF\index{metafont?\MF}. +ôÁÂÌÉÃÁ~\ref{draweqv} ÐÏËÁÚÙ×ÁÅÔ, ËÁË ÐÒÉÍÉÔÉ×ÎÙÅ +ËÏÍÁÎÄÙ ÒÉÓÏ×ÁÎÉÑ ÏÔÎÏÓÑÔÓÑ Ë ÚÎÁËÏÍÙÍ {\tt draw} É {\tt fill}. +%%Table~\ref{draweqv} shows how the primitive +%%drawing statements relate to the familiar {\tt draw} and {\tt fill} +%%statements. +ëÁÖÄÁÑ ËÏÍÁÎÄÁ × ÐÅÒ×ÏÊ ËÏÌÏÎËÅ ÔÁÂÌÉÃÙ ÍÏÖÅÔ ÚÁËÁÎÞÉ×ÁÔØÓÑ +Ó×ÏÉÍ \tdescr{ÓÐÉÓËÏÍ ÏÐÃÉÊ}, ËÏÔÏÒÙÊ ÜË×É×ÁÌÅÎÔÅÎ ÄÏÂÁ×ÌÅÎÉÀ +\tdescr{ÓÐÉÓËÁ ÏÐÃÉÊ} Ë ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÊ ÚÁÐÉÓÉ ×Ï ×ÔÏÒÏÊ ËÏÌÏÎËÅ. +%%Each of the statements in the first column of the table +%%could be ended with an \tdescr{option list} of its own, which is +%%equivalent to appending the \tdescr{option list} to the corresponding +%%entry in the second column of the table. +îÁÐÒÉÍÅÒ, +$$ {\tt draw}\ p\ {\tt withpen\ pencircle} $$ +ÜË×É×ÁÌÅÎÔÎÏ +$$ {\tt addto\ currentpicture\ doublepath}\ p\ + {\tt withpen\ currentpen\ withpen\ pencircle}, +$$ +ÇÄÅ {\tt +currentpen}\index{currentpen?\texttt{currentpen}}\label{Dcurpen} --- +ÜÔÏ ÓÐÅÃÉÁÌØÎÁÑ ÐÅÒÅÍÅÎÎÁÑ, × ËÏÔÏÒÏÊ ×ÓÅÇÄÁ ÈÒÁÎÉÔÓÑ ÔÅËÕÝÅÅ ÐÅÒÏ. +%%For example, +%%$$ {\tt draw%%}\ p\ {\tt withpen\ pencircle} $$ +%%is equivalent to +%%$$ {\tt addto\ currentpicture\ doublepath}\ p\ +%% {\tt withpen\ currentpen\ withpen\ pencircle} +%%$$ +%%where {\tt +%%currentpen}\index{currentpen?\texttt{currentpen}}\label{Dcurpen} is a +%%special pen variable that always holds the last pen picked up. +÷ÔÏÒÁÑ ÏÐÃÉÑ {\tt withpen} ÂÅÚ ÛÕÍÁ ÏÔÍÅÎÑÅÔ {\tt withpen +currentpen} × ÒÁÓËÒÙÔÉÉ {\tt draw}. +%%The second {\tt withpen} option silently overrides the {\tt withpen +%%currentpen} from the expansion of {\tt draw}. + +\begin{table}[htp] +$$\begin{tabular}{|l|l|} \hline +\multicolumn1{|c|}{ËÏÍÁÎÄÁ}& \multicolumn1{c|}{ÜË×É×ÁÌÅÎÔÎÙÊ ÐÒÉÍÉÔÉ×}\\ \hline +%%\multicolumn1{|c|}{statement}& \multicolumn1{c|}{equivalent primitives}\\ \hline +{\tt draw} {\it pic}& {\tt addto currentpicture also} {\it pic}\\ +{\tt draw} $p$& {\tt addto currentpicture doublepath} $p$ + {\tt withpen} $q$\\ +{\tt fill} $c$& {\tt addto currentpicture contour} $c$\\ +{\tt filldraw} $c$& {\tt addto currentpicture contour} $c$ {\tt withpen} $q$\\ +{\tt undraw} {\it pic}& {\tt addto currentpicture also} {\it pic} + {\tt withcolor} $b$\\ +{\tt undraw} $p$& {\tt addto currentpicture doublepath} $p$ + {\tt withpen} $q$ + {\tt withcolor} $b$\\ +{\tt unfill} $c$& {\tt addto currentpicture contour} $c$ + {\tt withcolor} $b$\\ +{\tt unfilldraw} $c$& {\tt addto currentpicture contour} $c$ {\tt withpen} $q$ + {\tt withcolor} $b$\\ \hline +\end{tabular} +$$ +\caption[ëÏÍÁÎÄÙ ÒÉÓÏ×ÁÎÉÑ É ÜË×É×ÁÌÅÎÔÎÙÅ ÐÒÉÍÉÔÉ×ÎÙÅ ËÏÍÁÎÄÙ] {ïÂÙÞÎÙÅ + ËÏÍÁÎÄÙ ÒÉÓÏ×ÁÎÉÑ É ÜË×É×ÁÌÅÎÔÎÙÅ ×ÅÒÓÉÉ ÐÒÉÍÉÔÉ×Ï×, ÇÄÅ $q$ + ÚÎÁÞÉÔ {\tt currentpen}, $b$ --- {\tt background}, + $p$ --- ÌÀÂÏÊ ÐÕÔØ, $c$ --- ÃÉËÌÉÞÅÓËÉÊ ÐÕÔØ É {\it + pic} --- \tdescr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ}. úÁÍÅÔØÔÅ, ÞÔÏ + ÎÅÐÕÓÔÏÅ ÐÏÌÅ {\tt drawoptions} ÍÏÇÌÏ ÂÙ ÕÓÌÏÖÎÉÔØ ÚÁÐÉÓÉ ×Ï + ×ÔÏÒÏÊ ËÏÌÏÎËÅ.} +%%\caption[Drawing statements and equivalent primitive commands] {Common +%% drawing statements and equivalent primitive versions, where $q$ +%% stands for {\tt currentpen}, $b$ stands for {\tt background}, +%% $p$ stands for any path, $c$ stands for a cyclic path, and {\it +%% pic} stands for a \tdescr{picture expression}. Note that +%% nonempty {\tt drawoptions} would complicate the entries in the +%% second column.} +\label{draweqv} +\index{drawoptions?\texttt{drawoptions}} +\end{table} + +åÓÔØ ÅÝÅ Ä×Å ÐÒÉÍÉÔÉ×ÎÙÅ ÒÉÓÕÀÝÉÅ ËÏÍÁÎÄÙ, ÎÅÄÏÐÕÓËÁÀÝÉÅ ÎÉËÁËÉÈ ÏÐÃÉÊ +ÒÉÓÏ×ÁÎÉÑ. +%%There are two more primitive drawing commands that do not accept any +%%drawing options. +ðÅÒ×ÁÑ --- ÜÔÏ {\tt setbounds}, ÏÂÓÕÖÄÁÅÍÁÑ × +ÒÁÚÄÅÌÅ~\ref{meas}; ×ÔÏÒÁÑ --- ÜÔÏ {\tt clip}\index{clip?\texttt{clip}}\label{Dclip}: +$$ {\tt clip}\, \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ}\, {\tt to}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} $$ +%%One is the {\tt setbounds} command that was discussed +%%in Section~\ref{meas}; the other is the {\tt clip} +%%command\index{clip?\texttt{clip}}\label{Dclip}: +%%$$ {\tt clip}\, \descr{picture variable}\, {\tt to}\, \descr{path expression} $$ +ðÏ ÄÁÎÎÏÍÕ ÃÉËÌÉÞÅÓËÏÍÕ ÐÕÔÉ, ËÏÍÁÎÄÁ {\tt clip} ÏÂÒÅÚÁÅÔ ÓÏÄÅÒÖÉÍÏÅ +\tdescr{ÐÅÒÅÍÅÎÎÏÊ-ËÁÒÔÉÎËÉ} ÔÁË, ÞÔÏ ÕÄÁÌÑÅÔÓÑ ×ÓÅ, ÞÔÏ ÏËÁÚÙ×ÁÅÔÓÑ ÓÎÁÒÕÖÉ +ÃÉËÌÉÞÅÓËÏÇÏ ÐÕÔÉ. +%%Given a cyclic path, this statement trims the contents of the +%%\tdescr{picture variable} to eliminate everything outside of the cyclic path. +îÅÔ ``×ÙÓÏËÏÕÒÏ×ÎÅ×ÏÊ'' ×ÅÒÓÉÉ ÜÔÏÊ ËÏÍÁÎÄÙ, ÔÁË ÞÔÏ ×Ù ÄÏÌÖÎÙ ÉÓÐÏÌØÚÏ×ÁÔØ +$$ {\tt clip\ currentpicture\ to}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}, $$ +ÅÓÌÉ ×Ù ÈÏÔÉÔÅ ÏÂÒÅÚÁÔØ {\tt +currentpicture}\index{currentpicture?\texttt{currentpicture}}. +%%There is no ``high level'' version of this statement, so you have to use +%%$$ {\tt clip\ currentpicture\ to}\, \descr{path expression} $$ +%%if you want to clip {\tt +%%currentpicture}\index{currentpicture?\texttt{currentpicture}}. +òÉÓ.~\ref{fig40} ÉÌÌÀÓÔÒÉÒÕÅÔ ÏÂÒÅÚËÕ. +%%Figure~\ref{fig40} illustrates clipping. + +\begin{figure}[htp] +$$\begin{verbatim} +beginfig(40); +path p[]; +p1 = (0,0){curl 0}..(5pt,-3pt)..{curl 0}(10pt,0); +p2 = p1..(p1 yscaled-1 shifted(10pt,0)); +p0 = p2; +for i=1 upto 3: p0:=p0.. p2 shifted (i*20pt,0); + endfor +for j=0 upto 8: draw p0 shifted (0,j*10pt); + endfor +p3 = fullcircle shifted (.5,.5) scaled 72pt; +clip currentpicture to p3; +draw p3; +endfig; +\end{verbatim} +\qquad +\mathcenter{\includegraphics{manfig-ru-40}} +$$ +\caption{ëÏÄ MetaPost É ×ÙÒÅÚÁÎÎÁÑ ËÁÒÔÉÎËÁ-ÒÅÚÕÌØÔÁÔ.} +%%\caption{MetaPost code and the resulting ``clipped'' figure.} +\label{fig40} +\end{figure} + +÷ÓÅ ÐÒÉÍÉÔÉ×ÎÙÅ ÏÐÅÒÁÃÉÉ ÒÉÓÏ×ÁÎÉÑ ÂÙÌÉ ÂÙ ÂÅÓÐÏÌÅÚÎÙ ÂÅÚ ÐÏÓÌÅÄÎÅÊ +ÏÐÅÒÁÃÉÉ Ó ÉÍÅÎÅÍ {\tt shipout}. +%%All the primitive drawing operations would be useless without one last +%%operation called {\tt shipout}. +ëÏÍÁÎÄÁ \index{shipout?\texttt{shipout}}\label{Dship} +$$ {\tt shipout}\, \descr{×ÙÒÁÖÅÎÉÅ-ÒÉÓÕÎÏË} $$ +ÐÉÛÅÔ ËÁÒÔÉÎËÕ, ËÁË ÆÁÊÌ PostScript\index{PostScript}, ÞØÅ ÉÍÑ +ÏÐÒÅÄÅÌÑÅÔÓÑ ÚÎÁÞÅÎÉÅÍ {\tt filenametemplate}\index{filenametemplate?\texttt{filenametemplate}} +(ÓÍ. ÒÁÚÄÅÌ~\ref{Dfilenametemplate}). +%%The statement\index{shipout?\texttt{shipout}}\label{Dship} +%%$$ {\tt shipout}\, \descr{picture expression} $$ +%%writes out a picture as a PostScript\index{PostScript} file whose +%%file name is determined by +%%{\tt filenametemplate}\index{filenametemplate?\texttt{filenametemplate}} +%%(see section~\ref{Dfilenametemplate}). +ïÂÙÞÎÏ ÉÍÑ ÆÁÊÌÁ ÚÁËÁÎÞÉ×ÁÅÔÓÑ ÎÁ {\tt.}{\it nnn}, ÇÄÅ {\tt nnn} --- ÜÔÏ +ÄÅÓÑÔÉÞÎÏÅ ÐÒÅÄÓÔÁ×ÌÅÎÉÅ ÚÎÁÞÅÎÉÑ ×ÎÕÔÒÅÎÎÅÊ ÐÅÒÅÍÅÎÎÏÊ\index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} {\tt +charcode}\index{charcode?\texttt{charcode}}\label{Dcharcode}. +%%By default, the file name ends +%%{\tt.}{\it nnn}, where {\tt nnn} is the decimal representation +%%of the value of the internal variable\index{internal +%%variables}\index{variables!internal} {\tt +%%charcode}\index{charcode?\texttt{charcode}}\label{Dcharcode}. +éÍÑ ``{\tt charcode}'' ÉÓÐÏÌØÚÕÅÔÓÑ ÄÌÑ ÓÏ×ÍÅÓÔÉÍÏÓÔÉ +Ó \MF\index{metafont?\MF}. +%%(The name +%%``{\tt charcode}'' is for compatibility with \MF\index{metafont?\MF}.) +ëÁË ÐÒÁ×ÉÌÏ, {\tt beginfig}\index{beginfig?\texttt{beginfig}} ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ +{\tt charcode}, Á {\tt endfig}\index{endfig?\texttt{endfig}} ×ÙÚÙ×ÁÅÔ {\tt +shipout}. +%%Normally, {\tt beginfig}\index{beginfig?\texttt{beginfig}} sets {\tt +%%charcode}, and {\tt endfig}\index{endfig?\texttt{endfig}} invokes {\tt +%%shipout}. + +\subsection{îÁÐÒÁ×ÌÅÎÉÅ ×Ù×ÏÄÁ × ÐÅÒÅ\-ÍÅÎÎÕÀ-ËÁÒÔÉÎËÕ} +%%\subsection{Directing Output to a Picture Variable} + +éÎÏÇÄÁ ÍÏÖÅÔ ÂÙÔØ ÖÅÌÁÔÅÌØÎÏ ÓÏÈÒÁÎÉÔØ ×Ù×ÏÄ ÒÉÓÕÀÝÉÈ ÏÐÅÒÁÃÉÊ É +ÉÓÐÏÌØÚÏ×ÁÔØ ÅÇÏ ÐÏÔÏÍ. +%%Sometimes, it might be desirable to save the output of a drawing +%%operation and re-use them later. +üÔÏ ÍÏÖÅÔ ÂÙÔØ ÌÅÇËÏ ÓÄÅÌÁÎÏ ÐÒÉÍÉÔÉ×ÁÍÉ MetaPost ÔÉÐÁ \ttt{addto}. +%%This can easily be done with +%%MetaPost primitives like \ttt{addto}. +ó ÄÒÕÇÏÊ ÓÔÏÒÏÎÙ, ÉÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ×ÙÓÏËÏÕÒÏ×ÎÅ×ÙÅ ËÏÍÁÎÄÙ ÒÉÓÏ×ÁÎÉÑ, +ÏÐÒÅÄÅÌÅÎÎÙÅ × ÍÁËÒÏÐÁËÅÔÅ Plain, ×ÓÅÇÄÁ ÐÉÛÕÔ × \ttt{currentpicture}\index{currentpicture?\texttt{currentpicture}}, +ÓÏÈÒÁÎÅÎÉÅ ÉÈ ×Ù×ÏÄÁ ÔÒÅÂÕÅÔ ×ÒÅÍÅÎÎÏÇÏ ÓÏÈÒÁÎÅÎÉÑ \ttt{currentpicture}, +ÚÁÔÅÍ ÓÂÒÏÓÁ ÅÅ × \ttt{nullpicture}\index{nullpicture?\texttt{nullpicture}}, +ÚÁÔÅÍ ÉÓÐÏÌÎÅÎÉÑ ÒÉÓÕÀÝÉÈ ÏÐÅÒÁÃÉÊ, ÚÁÔÅÍ ÚÁÐÉÓÉ ÚÎÁÞÅÎÉÑ \ttt{currentpicture} +× ÎÏ×ÕÀ ÐÅÒÅÍÅÎÎÕÀ ÔÉÐÁ \ttt{picture} É, ÎÁËÏÎÅÃ, ×ÏÓÓÔÁÎÏ×ÌÅÎÉÑ +\ttt{currentpicture} × ÉÓÈÏÄÎÏÅ ÓÏÓÔÏÑÎÉÅ. +%%On the other hand, since the +%%higher-level drawing commands defined in the Plain macro package +%%always write to the +%%\ttt{currentpicture}\index{currentpicture?\texttt{currentpicture}}, +%%saving their output required to temporarily save \ttt{currentpicture}, +%%reset it to \ttt{nullpicture}\index{nullpicture?\texttt{nullpicture}}, +%%execute the drawing operations, save the \ttt{currentpicture} to a +%%new \ttt{picture} variable and finally restore \ttt{currentpicture} to +%%the saved state. +÷ MetaPost ×ÅÒÓÉÉ~0.60 ÎÏ×ÙÊ ÍÁËÒÏÓ +$$ \hbox{\tt image( $\descr{ËÏÍÁÎÄÙ ÒÉÓÏ×ÁÎÉÑ}$ )} $$% +\index{image?\texttt{image}}\label{Dimage}% +××ÏÄÉÔÓÑ ÄÌÑ ÕÐÒÏÝÅÎÉÑ ÜÔÏÇÏ ÚÁÄÁÎÉÑ. +%%In MetaPost version~0.60 a new macro +%%$$ \hbox{\tt image( $\descr{drawing commands}$ )} $$% +%%\index{image?\texttt{image}}\label{Dimage}% +%%was introduced that eases this task. +ïÎ ×ÏÓÐÒÉÎÉÍÁÅÔ ËÁË ××ÏÄ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÐÒÏÉÚ×ÏÌØÎÙÈ ÏÐÅÒÁÃÉÊ +ÒÉÓÏ×ÁÎÉÑ É ×ÏÚ×ÒÁÝÁÅÔ ÐÅÒÅÍÅÎÎÕÀ ÔÉÐÁ \ttt{picture}, ÓÏÄÅÒÖÁÝÕÀ +ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ×Ù×ÏÄ, ÂÅÚ ×ÌÉÑÎÉÑ ÎÁ {\tt currentpicture}. +%%It takes as input a sequence of arbitrary +%%drawing operations and returns a \ttt{picture} variable containing the +%%corresponding output, without affecting {\tt currentpicture}. + +îÁÐÒÉÍÅÒ, × ËÏÄÅ ÒÉÓ.~\ref{fig55} ÏÂßÅËÔ \ttt{wheel} ÏÐÒÅÄÅÌÑÅÔÓÑ +ÓÏÈÒÁÎÅÎÉÅÍ ×Ù×ÏÄÁ Ä×ÕÈ ÏÐÅÒÁÃÉÊ \ttt{draw} (ÓÍ. ËÏÄ). +%%As an example, in the code of figure~\ref{fig55} an object \ttt{wheel} has +%%been defined that saves the output of two \ttt{draw} operations as follows: +\begin{figure}[b] +$$ \includegraphics{manfig-ru-55} $$ +\caption{ëÏÐÉÒÏ×ÁÎÉÅ ÏÂßÅËÔÏ× ÏÐÅÒÁÔÏÒÏÍ \ttt{image}.} +%%\caption{Copying objects with the \ttt{image} operator.} +\label{fig55} +\end{figure} +$$\begin{verbatim} +picture wheel; +wheel := image( + draw fullcircle scaled 2u xscaled .8 rotated 30; + draw fullcircle scaled .15u xscaled .8 rotated 30; +); +\end{verbatim} +$$ +ïÂßÅËÔ \ttt{wheel} ÐÏ×ÔÏÒÎÏ ÉÓÐÏÌØÚÕÅÔÓÑ × ÏÐÒÅÄÅÌÅÎÉÉ ÄÒÕÇÏÇÏ ÏÂßÅËÔÁ \ttt{car}. +%%This \ttt{wheel} object is re-used in the definition of another object \ttt{car}. +òÉÓ.~\ref{fig55} ÐÏËÁÚÙ×ÁÅÔ ÔÒÉ ÏÂßÅËÔÁ \ttt{car}, ÎÁÒÉÓÏ×ÁÎÎÙÅ Ó Ä×ÕÍÑ ÒÁÚÎÙÍÉ +ÚÎÁÞÅÎÉÑÍÉ ÎÁËÌÏÎÁ. +%%Figure~\ref{fig55} shows three \ttt{car} objects drawn with two different slant +%%values. + +\subsection{òÁÂÏÔÁ Ó ËÏÍÐÏÎÅÎÔÁÍÉ ÒÉÓÕÎËÁ} +%%\subsection{Inspecting the Components of a Picture} +\label{piccomp} + +\mbox{}% Start paragraph here. +\index{setbounds?\texttt{setbounds}|(}% +\index{for within?\texttt{for within}|(}% +% +òÉÓÕÎËÉ MetaPost ÓÏÓÔÁ×ÌÑÀÔÓÑ ÉÚ ÎÁÒÉÓÏ×ÁÎÎÙÈ ÌÉÎÉÊ, ÚÁÐÏÌÎÅÎÎÙÈ +ËÏÎÔÕÒÏ×, ÔÅËÓÔÏ×ÙÈ ÆÒÁÇÍÅÎÔÏ×, ÐÕÔÅÊ ÄÌÑ ×ÙÒÅÚËÉ\index{clip?\texttt{clip}} É +ÐÕÔÅÊ {\tt setbounds}\index{setbounds?\texttt{setbounds}}. +%%MetaPost pictures are composed of stroked lines, filled outlines, pieces +%%of typeset text, clipping paths\index{clip?\texttt{clip}}, and +%%{\tt setbounds}\index{setbounds?\texttt{setbounds}} paths. +ðÕÔØ {\tt setbounds} ÄÁÅÔ ÉÓËÕÓÓÔ×ÅÎÎÕÀ ÏÈ×ÁÔÙ×ÁÀÝÕÀ ÒÁÍËÕ, ÎÕÖÎÕÀ ÄÌÑ +×Ù×ÏÄÁ \TeX. +%%(A {\tt setbounds} +%%path gives an artificial bounding box as is needed for \TeX\ output.) +òÉÓÕÎÏË ÍÏÖÅÔ ÉÍÅÔØ ÍÎÏÇÏ ËÏÍÐÏÎÅÎÔ ËÁÖÄÏÇÏ ÔÉÐÁ. +%%A picture can have many components of each type. +üÔÉ ËÏÍÐÏÎÅÎÔÙ ÄÏÓÔÕÐÎÙ ÞÅÒÅÚ ÉÔÅÒÁÃÉÀ × ÆÏÒÍÅ +$$ {\tt for}\ \descr{ÓÉÍ×ÏÌØÎÙÊ ÚÎÁË}\ {\tt within}\ + \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ}\hbox{\tt:}\ \descr{ÔÅÌÏ ÃÉËÌÁ}\ {\tt endfor} +$$\index{for within?\texttt{for within}}\label{Dforwithin}% +%%They can be accessed via an iteration of the form +%%$$ {\tt for}\ \descr{symbolic token}\ {\tt within}\ +%% \descr{picture expression}\hbox{\tt:}\ \descr{loop text}\ {\tt endfor} +%%$$\index{for within?\texttt{for within}}\label{Dforwithin}% +\tdescr{ôÅÌÏ ÃÉËÌÁ} ÍÏÖÅÔ ÂÙÔØ ÞÅÍ-ÕÇÏÄÎÏ, ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÍ ÏÔÎÏÓÉÔÅÌØÎÏ +{\tt for} É {\tt endfor}. +%%The \tdescr{loop text} can be anything that is balanced with respect to +%%{\tt for} and {\tt endfor}. +\tdescr{óÉÍ×ÏÌØÎÙÊ ÚÎÁË} --- ÜÔÏ ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ ÄÌÑ ÃÉËÌÁ, +ÓËÁÎÉÒÕÀÝÁÑ ËÏÍÐÏÎÅÎÔÙ ÒÉÓÕÎËÁ × ÐÏÒÑÄËÅ ÉÈ ÒÉÓÏ×ÁÎÉÑ. +%%The \tdescr{symbolic token} is a loop variable that +%%scans the components of the picture in the order in which they were drawn. +ëÏÍÐÏÎÅÎÔÁ ÄÌÑ ÐÕÔÉ ×ÙÒÅÚËÉ ÉÌÉ {\tt setbounds} ×ËÌÀÞÁÅÔ ×ÓÅ, Ë ÞÅÍÕ +ÐÒÉÍÅÎÑÅÔÓÑ ÐÕÔØ. +%%The +%%component for a clipping or {\tt setbounds} path includes everything the path +%%applies to. +ðÏÜÔÏÍÕ, ÅÓÌÉ ÏÄÉÎÏÞÎÙÊ ÐÕÔØ ×ÙÒÅÚËÉ ÉÌÉ {\tt setbounds} ÐÒÉÍÅÎÑÅÔÓÑ ËÏ +×ÓÅÍÕ × \tdescr{×ÙÒÁÖÅÎÉÉ-ËÁÒÔÉÎËÅ}, ÔÏ ×ÓÑ ËÁÒÔÉÎËÁ ÍÏÖÅÔ ÒÁÓÓÍÁÔÒÉ×ÁÔØÓÑ +ËÁË ÏÄÎÁ ÂÏÌØÛÁÑ ËÏÍÐÏÎÅÎÔÁ. +%%Thus if a single clipping or {\tt setbounds} path applies to +%%everything in the \tdescr{picture expression}, the whole picture could be +%%thought of as one big component. +äÌÑ ÔÏÇÏ, ÞÔÏÂÙ ÓÏÄÅÒÖÉÍÏÅ ÔÁËÏÊ ËÁÒÔÉÎËÉ ÂÙÌÏ ÄÏÓÔÕÐÎÙÍ, ÉÔÅÒÁÃÉÑ +{\tt for}\ldots{\tt within} ÉÇÎÏÒÉÒÕÅÔ ÏÈ×ÁÔÙ×ÁÀÝÉÊ ÐÕÔØ ×ÙÒÅÚËÉ ÉÌÉ +{\tt setbounds} × ÜÔÏÍ ÓÌÕÞÁÅ. +%%In order to make the contents of such a picture +%%accessible, the {\tt for}\ldots{\tt within} iteration ignores the enclosing +%%clipping or {\tt setbounds} path in this case. +þÉÓÌÏ ËÏÍÐÏÎÅÎÔ, ÎÁÈÏÄÉÍÙÈ ÉÔÅÒÁÃÉÅÊ {\tt for}\ldots {\tt within}, ×ÏÚ×ÒÁÝÁÅÔÓÑ +$$ {\tt length}\ \descr{ÒÉÓÕÎÏË-ÐÅÒ×ÉÞÎÏÓÔØ}\index{length?\texttt{length}}\label{DlengthPicture}$$ +%%The number of components +%%that a {\tt for}\ldots {\tt within} iteration would find is returned by +%%$$ {\tt length}\ \descr{picture primary}\index{length?\texttt{length}}\label{DlengthPicture}$$ + +\index{for within?\texttt{for within}|)} +\mbox{}% Start paragraph here. +\index{stroked?\texttt{stroked}|(}% +\index{filled?\texttt{filled}|(}% +\index{textual?\texttt{textual}|(}% +\index{clipped?\texttt{clipped}|(}% +\index{bounded?\texttt{bounded}|(}% +% +ëÁË ÔÏÌØËÏ ÉÔÅÒÁÃÉÑ {\tt for}\ldots{\tt within} ÎÁÈÏÄÉÔ ËÏÍÐÏÎÅÎÔ ËÁÒÔÉÎËÉ, +ÓÒÁÚÕ ×ÏÚÎÉËÁÅÔ ÒÑÄ ÏÐÅÒÁÔÏÒÏ× ÄÌÑ ÅÇÏ ÉÄÅÎÔÉÆÉËÁÃÉÉ É ÐÏÌÕÞÅÎÉÑ +ÏÔÎÏÓÑÝÅÊÓÑ Ë ÎÅÍÕ ÉÎÆÏÒÍÁÃÉÉ. +%%Once the {\tt for}\ldots{\tt within} iteration has found a picture component, +%%there are numerous operators for identifying it and extracting relevant +%%information. +ïÐÅÒÁÔÏÒ +$$ {\tt stroked}\ \descr{ÐÅÒ×ÉÞÎÏÅ ×ÙÒÁÖÅÎÉÅ} $$\index{stroked?\texttt{stroked}}\label{Dstroked}% +ÐÒÏ×ÅÒÑÅÔ, Ñ×ÌÑÅÔÓÑ ÌÉ ×ÙÒÁÖÅÎÉÅ ÉÚ×ÅÓÔÎÏÊ ËÁÒÔÉÎËÏÊ, ÞÅÊ ÐÅÒ×ÙÊ +ËÏÍÐÏÎÅÎÔ --- ÜÔÏ ÉÚÏÂÒÁÖÅÎÎÁÑ ÌÉÎÉÑ. +%%The operator +%%$$ {\tt stroked}\ \descr{primary expression} %%$$\index{stroked?\texttt{stroked}}\label{Dstroked}% +%%tests whether the expression is a known picture whose first component is a +%%stroked line. +áÎÁÌÏÇÉÞÎÙÍ ÏÂÒÁÚÏÍ, ÏÐÅÒÁÔÏÒÙ {\tt filled}\index{filled?\texttt{filled}}\label{Dfilled} +É {\tt textual}\index{textual?\texttt{textual}}\label{Dtextual} +×ÏÚ×ÒÁÝÁÀÔ {\tt true}, ÅÓÌÉ ÐÅÒ×ÙÊ ËÏÍÐÏÎÅÎÔ --- ÜÔÏ +ÓÏÏÔ×ÅÔÓÔ×ÅÎÎÏ ÚÁÐÏÌÎÅÎÎÙÊ ËÏÎÔÕÒ ÉÌÉ ÆÒÁÇÍÅÎÔ ÔÅËÓÔÁ. +%%Similarly, the {\tt filled}\index{filled?\texttt{filled}}\label{Dfilled} +%%and {\tt textual}\index{textual?\texttt{textual}}\label{Dtextual} operators +%%return {\tt true} if the first component is a filled outline or a piece of +%%typeset text. +ïÐÅÒÁÔÏÒÙ {\tt clipped}\index{clipped?\texttt{clipped}}\label{Dclipped} +É {\tt bounded}\index{bounded?\texttt{bounded}}\label{Dbounded} +ÐÒÏ×ÅÒÑÀÔ, Ñ×ÌÑÅÔÓÑ ÌÉ ÁÒÇÕÍÅÎÔ ËÁÒÔÉÎËÏÊ, ÎÁÞÉÎÁÀÝÅÊÓÑ Ó ÐÕÔÉ ×ÙÒÅÚËÉ +ÉÌÉ {\tt setbounds}. +%%The {\tt clipped}\index{clipped?\texttt{clipped}}\label{Dclipped} +%%and {\tt bounded}\index{bounded?\texttt{bounded}}\label{Dbounded} operators +%%test whether the argument is a known picture that starts with a clipping +%%path or a {\tt setbounds} path. +ïÎÉ ÂÕÄÕÔ ÉÓÔÉÎÎÙ, ÅÓÌÉ ÐÅÒ×ÁÑ ËÏÍÐÏÎÅÎÔÁ ×ÙÒÅÚÁÎÁ ÉÌÉ ÏÇÒÁÎÉÞÅÎÁ (ËÏÍÁÎÄÏÊ +{\tt setbounds}) ÉÌÉ ÅÓÌÉ ×ÓÑ ËÁÒÔÉÎËÁ ÚÁËÌÀÞÅÎÁ × ÐÕÔØ ×ÙÒÅÚËÉ +ÉÌÉ {\tt setbounds}. +%%This is true if the first component is +%%clipped or bounded or if the entire picture is enclosed in a clipping or +%%{\tt setbounds} path. + +\mbox{}% Start paragraph here. +\index{pathpart?\texttt{pathpart}|(}% +\index{penpart?\texttt{penpart}|(}% +\index{dashpart?\texttt{dashpart}|(}% +% +åÓÔØ ÅÝÅ ÒÑÄ ÏÐÅÒÁÔÏÒÏ× ÉÚ×ÌÅÞÅÎÉÑ ÞÁÓÔÅÊ, ÐÒÉÍÅÎÑÅÍÙÈ Ë ÐÅÒ×ÏÊ +ËÏÍÐÏÎÅÎÔÅ ÒÉÓÕÎËÁ. +%%There are also numerous part extraction operators that test the first component +%%of a picture. +åÓÌÉ {\tt p} --- ÜÔÏ ËÁÒÔÉÎËÁ É {\tt stroked p} --- ÉÓÔÉÎÎÏ, ÔÏ +{\tt pathpart p}\index{pathpart?\texttt{pathpart}}\label{Dpathpart} --- ÜÔÏ +ÐÕÔØ, ÏÐÉÓÙ×ÁÀÝÉÊ ÎÁÒÉÓÏ×ÁÎÎÕÀ ÌÉÎÉÀ, +{\tt penpart p}\index{penpart?\texttt{penpart}}\label{Dpenpart} --- ÜÔÏ +ÉÓÐÏÌØÚÏ×ÁÎÎÏÅ ÐÅÒÏ, {\tt dashpart p}\index{dashpart?\texttt{dashpart}}\label{Ddashpart} --- +ÜÔÏ ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ. +%%If {\tt p} is a picture and {\tt stroked p} is true, +%%{\tt pathpart p}\index{pathpart?\texttt{pathpart}}\label{Dpathpart} is the +%%path describing the line that got stroked, +%%{\tt penpart p}\index{penpart?\texttt{penpart}}\label{Dpenpart} is the pen +%%that was used, {\tt dashpart p}\index{dashpart?\texttt{dashpart}}\label{Ddashpart} +%%is the dash pattern. +åÓÌÉ ÌÉÎÉÑ ÂÅÚ ÒÁÚÒÙ×Ï×, ÔÏ {\tt dashpart p} ×ÏÚ×ÒÁÝÁÅÔ ÐÕÓÔÕÀ ËÁÒÔÉÎËÕ. +%%If the line is not dashed, {\tt dashpart p} returns an empty picture. + +ôÁËÉÅ ÖÅ ÏÐÅÒÁÔÏÒÙ ÄÌÑ ÉÚ×ÌÅÞÅÎÉÑ ÞÁÓÔÅÊ ÒÁÂÏÔÁÀÔ, ËÏÇÄÁ {\tt filled p} --- +ÉÓÔÉÎÎÏ, ÚÁ ÉÓËÌÀÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ {\tt dashpart p} ÎÅ ÉÍÅÅÔ ÓÍÙÌÁ × ÜÔÏÍ +ÓÌÕÞÁÅ. +%%The same part extraction operators work when {\tt filled p} is true, except +%%that {\tt dashpart p} is not meaningful in that case. + +äÌÑ ÔÅËÓÔÏ×ÙÈ ÆÒÁÇÍÅÎÔÏ×, ËÏÇÄÁ {\tt textual p} --- ÉÓÔÉÎÎÏ, +{\tt textpart p}\index{textpart?\texttt{textpart}}\label{Dtextpart} +ÄÁÅÔ ÎÁÐÅÞÁÔÁÎÎÙÊ ÔÅËÓÔ, +{\tt fontpart p}\index{fontpart?\texttt{fontpart}}\label{Dfontpart} +--- ÉÓÐÏÌØÚÕÅÍÙÊ ÛÒÉÆÔ É {\tt xpart~p}\index{xpart?\texttt{xpart}}\index{ypart?\texttt{ypart}}\index{xxpart?\texttt{xxpart}}% +\index{xypart?\texttt{xypart}}\index{yxpart?\texttt{yxpart}}\index{yypart?\texttt{yypart}}, +{\tt ypart~p}, {\tt xxpart~p}, {\tt xypart~p}, {\tt yxpart~p}, {\tt yypart~p} +ÐÏËÁÚÙ×ÁÀÔ, ËÁË ÔÅËÓÔ ÓÄ×ÉÇÁÌÓÑ, ×ÒÁÝÁÌÓÑ É ÍÁÓÛÔÁÂÉÒÏ×ÁÌÓÑ. +%%For text components, +%%{\tt textual p} is true, +%%{\tt textpart p}\index{textpart?\texttt{textpart}}\label{Dtextpart} +%%gives the text that got typeset, +%%{\tt fontpart p}\index{fontpart?\texttt{fontpart}}\label{Dfontpart} +%%gives the font that was used, and {\tt %%xpart~p}\index{xpart?\texttt{xpart}}\index{ypart?\texttt{ypart}}\index{xxpart?\tex%%ttt{xxpart}}% +%%\index{xypart?\texttt{xypart}}\index{yxpart?\texttt{yxpart}}\index{yypart?\texttt{%%yypart}}, +%%{\tt ypart~p}, {\tt xxpart~p}, {\tt xypart~p}, {\tt yxpart~p}, {\tt yypart~p} +%%tell how the text has been shifted, rotated, and scaled. + +îÁËÏÎÅÃ, ÄÌÑ ËÏÍÐÏÎÅÎÔ \ttt{stroked}, \ttt{filled} É \ttt{textual} +ÍÏÖÎÏ ÐÏÌÕÞÉÔØ Ã×ÅÔ, ÓËÁÚÁ× +$$ {\tt colorpart}\ +\descr{ËÏÍÐÏÎÅÎÔÁ}\index{colorpart?\texttt{colorpart}}\label{Dcolorpart} +$$ +%%Finally, for \ttt{stroked}, \ttt{filled} and \ttt{textual} components +%%the color can be examined by saying +%%$$ {\tt colorpart}\ +%%\descr{item}\index{colorpart?\texttt{colorpart}}\label{Dcolorpart} +%%$$ +üÔÏ ×ÏÚ×ÒÁÝÁÅÔ Ã×ÅÔ ËÏÍÐÏÎÅÎÔÙ × ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÊ ÍÏÄÅÌÉ Ã×ÅÔÁ. +%%This returns the color of a component in its respective color model. +íÏÄÅÌØ Ã×ÅÔÁ ËÏÍÐÏÎÅÎÔÙ ÍÏÖÅÔ ÂÙÔØ ÉÄÅÎÔÉÆÉÃÉÒÏ×ÁÎÁ ÏÐÅÒÁÔÏÒÏÍ +\ttt{colormodel}\index{colormodel?\texttt{colormodel}}\label{Dcolormodel} +(ÓÍ. ÔÁÂÌÉÃÕ~\ref{dfltcmod} ÎÁ ÓÔÒ.~\pageref{dfltcmod}). +%%The color model of a component can be identified by the +%%\ttt{colormodel}\index{colormodel?\texttt{colormodel}}\label{Dcolormodel} +%%operator (cf. Table~\ref{dfltcmod} on p.~\pageref{dfltcmod}). + +äÌÑ ÂÏÌÅÅ ÄÅÔÁÌØÎÙÈ ÏÐÅÒÁÃÉÊ ÓÏ Ã×ÅÔÏÍ ÅÓÔØ ÏÐÅÒÁÔÏÒÙ ÄÌÑ ÉÚ×ÌÅÞÅÎÉÑ ÏÔÄÅÌØÎÙÈ +ÓÏÓÔÁ×ÌÑÀÝÉÈ Ã×ÅÔÁ ÉÚ ËÏÍÐÏÎÅÎÔÙ ÒÉÓÕÎËÁ. +%%For more fine grained color operations there are operators to extract +%%single color components of an item. +÷ ÚÁ×ÉÓÉÍÏÓÔÉ ÏÔ ÍÏÄÅÌÉ Ã×ÅÔÁ Ã×ÅÔ ËÏÍÐÏÎÅÎÔÙ ÒÉÓÕÎËÁ \ttt{p} --- ÜÔÏ +$$ \hbox{\tt (cyanpart p, magentapart p, yellowpart p, blackpart p)} $$% +\index{cyanpart?\texttt{cyanpart}}\index{magentapart?\texttt{magentapart}}\index{yellowpart?\texttt{yellowpart}}\index{blackpart?\texttt{blackpart}} +ÉÌÉ +$$ \hbox{\tt (redpart p, greenpart p, bluepart p)} $$% +\index{redpart?\texttt{redpart}}\index{greenpart?\texttt{greenpart}}\index{bluepart?\texttt{bluepart}} +ÉÌÉ +$$ \hbox{\tt (greypart p)} $$% +\index{greypart?\texttt{greypart}} +ÉÌÉ +$$ \hbox{\tt false}. $$ +%%Depending on the color model the color of a picture component \ttt{p} is +%%$$ \hbox{\tt (cyanpart p, magentapart p, yellowpart p, blackpart p)} $$% +%%\index{cyanpart?\texttt{cyanpart}}\index{magentapart?\texttt{magentapart}}\index{yellowpart?\texttt{yellowpart}}\index{blackpart?\texttt{blackpart}} +%%or +%%$$ \hbox{\tt (redpart p, greenpart p, bluepart p)} $$% +%%\index{redpart?\texttt{redpart}}\index{greenpart?\texttt{greenpart}}\index{bluepart?\texttt{bluepart}} +%%or +%%$$ \hbox{\tt greypart p} $$% +%%\index{greypart?\texttt{greypart}} +%%or +%%$$ \hbox{\tt false}. $$ + +úÁÍÅÔØÔÅ, ÞÔÏ ÏÐÅÒÁÔÏÒÙ ÞÁÓÔÅÊ Ã×ÅÔÁ {\tt redpart}, {\tt cyanpart} É Ô.~Ð. +ÄÏÌÖÎÙ ÓÏÏÔ×ÅÔÓÔ×Ï×ÁÔØ ÍÏÄÅÌÉ Ã×ÅÔÁ ËÏÍÐÏÎÅÎÔÁ ÒÉÓÕÎËÁ × ×ÏÐÒÏÓÅ. +%%Note, color part operators {\tt redpart}, {\tt cyanpart} etc. have to +%%match the color model of the picture component in question. +ðÒÉÍÅÎÅÎÉÅ ÎÅÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÇÏ ÏÐÅÒÁÔÏÒÁ ÞÁÓÔÉ Ã×ÅÔÁ Ë ËÏÍÐÏÎÅÎÔÕ ËÁÒÔÉÎËÉ +ÉÎÉÃÉÉÒÕÅÔ ÏÛÉÂËÕ É ×ÏÚ×ÒÁÝÁÅÔ ÞÁÓÔØ Ã×ÅÔÁ \ttindex{black} × ÚÁÐÒÏÛÅÎÎÏÊ +ÍÏÄÅÌÉ Ã×ÅÔÁ. +%%Applying a non-matching color part +%%operator to a picture component triggers an error and returns +%%a \ttindex{black} color part in the requested color model. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÄÌÑ ËÏÄÁ +%%That is, for the code +$$\begin{verbatim} +picture pic; +pic := image(fill unitsquare scaled 1cm withcolor (0.3, 0.6, 0.9);); +for item within pic: + show greypart item; + show cyanpart item; + show blackpart item; + show redpart item; +endfor +\end{verbatim} +$$ +×Ù×ÏÄÏÍ ÂÕÄÅÔ (ÓÏÏÂÝÅÎÉÑ Ï ÏÛÉÂËÁÈ ÏÐÕÝÅÎÙ) +%%the output is (omitting the error messages) +$$\begin{verbatim} +>> 0 +>> 0 +>> 1 +>> 0.3, +\end{verbatim} +$$ +ÐÏÔÏÍÕ ÞÔÏ × ÍÏÄÅÌÉ ÏÔÔÅÎËÏ× ÓÅÒÏÇÏ ÞÅÒÎÙÊ --- ÜÔÏ {\tt 0}, Á × ÍÏÄÅÌÉ +cmyk-Ã×ÅÔÏ× ÞÅÒÎÙÊ --- ÜÔÏ {\tt (0,0,0,1)}. +%%since in grey scale color model black is {\tt 0} and in CMYK color model +%%black is {\tt (0, 0, 0, 1)}. +äÌÑ ÐÏÄÏÛÅÄÛÅÊ ÍÏÄÅÌÉ rgb-Ã×ÅÔÁ ÂÙÌ ×ÏÚ×ÒÁÝÅÎ ×ÅÒÎÙÊ Ã×ÅÔÏ×ÏÊ ËÏÍÐÏÎÅÎÔ. +%%For the matching RGB color model the true +%%color component is returned. + +ëÏÇÄÁ {\tt clipped p} ÉÌÉ {\tt bounded p} --- ÉÓÔÉÎÎÏ, ÔÏ {\tt pathpart p} +ÄÁÅÔ ÐÕÔØ ×ÙÒÅÚËÉ ÉÌÉ {\tt setbounds}, Á ÄÒÕÇÉÅ ÏÐÅÒÁÔÏÒÙ ÉÚ×ÌÅÞÅÎÉÑ ÞÁÓÔÅÊ +ÎÅ ÉÍÅÀÔ ÓÍÙÓÌÁ. +%%When {\tt clipped p} or {\tt bounded p} is true, {\tt pathpart p} gives the +%%clipping or {\tt setbounds} path and the other part extraction operators are +%%not meaningful. +ôÁËÉÅ ÎÅ ÉÍÅÀÝÉÅ ÓÍÙÓÌÁ ÐÏÌÕÞÅÎÉÑ ÞÁÓÔÅÊ ÎÅ ÇÅÎÅÒÉÒÕÀÔ ÏÛÉÂÏË. +%%Such non-meaningful part extractions do not generate +%%errors. +ïÎÉ ×ÍÅÓÔÏ ÜÔÏÇÏ ×ÏÚ×ÒÁÝÁÀÔ (ËÏÍÐÏÎÅÎÔÙ) ÎÕÌÅ×ÙÅ ÚÎÁÞÅÎÉÑ ÉÌÉ ÞÅÒÎÙÊ Ã×ÅÔ: +ÐÕÓÔÏÊ ÐÕÔØ {\tt (0,0)} ÄÌÑ {\tt pathpart}, +{\tt nullpen}\index{nullpen?\texttt{nullpen}}\label{Dnlpen} ÄÌÑ {\tt penpart}, +ÐÕÓÔÏÊ ÒÉÓÕÎÏË ÄÌÑ {\tt dashpart}, +ÐÕÓÔÕÀ ÓÔÒÏËÕ ÄÌÑ {\tt textpart} ÉÌÉ {\tt fontpart}, +0 ÄÌÑ {\tt colormodel}, {\tt greypart}, {\tt redpart}, {\tt greenpart}, +{\tt bluepart}, {\tt cyanpart}, {\tt magentapart}, {\tt yellowpart}, +ÏÄÉÎ ÄÌÑ {\tt blackpart} É ÞÅÒÎÙÊ × ÔÅËÕÝÅÊ ÔÉÐÏ×ÏÊ ÍÏÄÅÌÉ Ã×ÅÔÁ ÄÌÑ {\tt colorpart}. +%%Instead, they return null values or black color (components): +%%the trivial path {\tt (0,0)} for {\tt pathpart}, +%%{\tt nullpen}\index{nullpen?\texttt{nullpen}}\label{Dnlpen} for {\tt penpart}, +%%an empty picture for {\tt dashpart}, +%%the null string for {\tt textpart} or {\tt fontpart}, +%%zero for {\tt colormodel}, +%%{\tt greypart}, +%%{\tt redpart}, {\tt greenpart}, {\tt bluepart}, +%%{\tt cyanpart}, {\tt magentapart}, {\tt yellowpart}, +%%one for {\tt blackpart}, and +%%black in the current default color model for {\tt colorpart}. + +ðÏÄ×ÅÄÅÍ ÉÔÏÇ ÄÉÓËÕÓÓÉÉ Ï ÎÅÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÈ ÏÐÅÒÁÔÏÒÁÈ ×ÙÄÅÌÅÎÉÑ ÞÁÓÔÅÊ. +%%To summarize the discussion of mismatching part operators: +\begin{enumerate} +\item ÷ÏÐÒÏÓ Ï ÂÅÓÓÍÙÓÌÅÎÎÙÈ ÞÁÓÔÑÈ ËÏÍÐÏÎÅÎÔÙ ÒÉÓÕÎËÁ, ÔÁËÉÈ ËÁË {\tt + redpart} ÄÌÑ ÐÕÔÉ ×ÙÒÅÚËÉ, {\tt textpart} ÄÌÑ ÉÚÏÂÒÁÖÅÎÉÑ ÐÅÒÏÍ + ÉÌÉ {\tt pathpart} ÄÌÑ ÔÅËÓÔÁ, ÓÐÏËÏÊÎÏ ÐÒÉÎÉÍÁÅÔÓÑ É + ÏÔ×ÅÔÏÍ ÎÁ ÎÅÇÏ ÂÕÄÅÔ ÌÉÂÏ ÎÕÌÅ×ÏÅ ÚÎÁÞÅÎÉÅ, ÌÉÂÏ ÞÅÒÎÙÊ Ã×ÅÔ + (ËÏÍÐÏÎÅÎÔ). +%%\item Asking for non-meaningful parts of an item---such as the {\tt +%% redpart} of a clipping path, the {\tt textpart} of a stroked item, +%% or the {\tt pathpart} of a textual item---is silently accepted and +%% returns a null value or a black color (component). +\item ðÒÉÍÅÎÅÎÉÅ ÏÐÅÒÁÔÏÒÁ Ã×ÅÔÏ×ÏÊ ÞÁÓÔÉ × ÎÅÐÒÁ×ÉÌØÎÏÊ ÍÏÄÅÌÉ Ã×ÅÔÁ Ë + Ã×ÅÔÎÏÍÕ ËÏÍÐÏÎÅÎÔÕ ×ÏÚ×ÒÁÝÁÅÔ ÞÅÒÎÙÊ ËÏÍÐÏÎÅÎÔ. âÏÌÅÅ ÔÏÇÏ, ÜÔÏ ÉÎÉÉÃÉÉÒÕÅÔ + ÏÛÉÂËÕ. +%%\item Applying a color part operator of the wrong color model to a +%% coloured item returns a black color component. Additionally, this +%% triggers an error. +\end{enumerate} + +\index{setbounds?\texttt{setbounds}|)} +\index{stroked?\texttt{stroked}|)} +\index{filled?\texttt{filled}|)} +\index{textual?\texttt{textual}|)} +\index{clipped?\texttt{clipped}|)} +\index{bounded?\texttt{bounded}|)} +\index{pathpart?\texttt{pathpart}|)} +\index{penpart?\texttt{penpart}|)} +\index{dashpart?\texttt{dashpart}|)} +\index{colormodel?\texttt{colormodel}|)} +\index{colorpart?\texttt{colorpart}|)} +\index{redpart?\texttt{redpart}|)} +\index{greenpart?\texttt{greenpart}|)} +\index{bluepart?\texttt{bluepart}|)} +\index{cyanpart?\texttt{cyanpart}|)} +\index{magentapart?\texttt{magentapart}|)} +\index{yellowpart?\texttt{yellowpart}|)} +\index{blackpart?\texttt{blackpart}|)} +\index{greypart?\texttt{greypart}|)} + +\section{íÁËÒÏÓÙ} +%%\section{Macros} +\label{macros} + +õÖÅ ÕÐÏÍÉÎÁÌÏÓØ, ÞÔÏ MetaPost ÉÍÅÅÔ ÍÎÏÖÅÓÔ×Ï Á×ÔÏÍÁÔÉÞÅÓËÉ +×ËÌÀÞÁÅÍÙÈ ÍÁËÒÏÓÏ×, ÎÁÚÙ×ÁÅÍÏÅ ÍÁËÒÏÐÁËÅÔ Plain\index{ÍÁËÒÏÓÙ Plain}, É +ÎÅËÏÔÏÒÙÅ ËÏÍÁÎÄÙ, ÒÁÓÓÍÏÔÒÅÎÎÙÅ × ÐÒÅÄÛÅÓÔ×ÕÀÝÉÈ ÒÁÚÄÅÌÁÈ, ÏÐÒÅÄÅÌÅÎÙ +ËÁË ÍÁËÒÏÓÙ É ÎÅ Ñ×ÌÑÀÔÓÑ ×ÓÔÒÏÅÎÎÙÍÉ × MetaPost. +%%As alluded to earlier, MetaPost has a set of automatically included +%%macros called the Plain macro package\index{Plain macros}, and some of +%%the commands discussed in previous sections are defined as macros +%%instead of being built into MetaPost. +ãÅÌØ ÜÔÏÇÏ ÒÁÚÄÅÌÁ ÏÂßÑÓÎÉÔØ, ËÁË ÐÉÓÁÔØ ÔÁËÉÅ ÍÁËÒÏÓÙ. +%%The purpose of this section is to +%%explain how to write such macros. + +íÁËÒÏÓÙ ÂÅÚ ÁÒÇÕÍÅÎÔÏ× ÏÞÅÎØ ÐÒÏÓÔÙ. +%%Macros with no arguments are very simple. +ïÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ\index{ÔÅËÓÔ ÚÁÍÅÎÙ?\tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ}}% +\index{def?\texttt{def}}\index{enddef?\texttt{enddef}} +$$ {\tt def}\, \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}\, \hbox{\tt =}\, + \descr{ÔÅËÓÔ ÚÁÍÅÎÙ}\, {\tt enddef} +$$ +ÄÅÌÁÅÔ \tdescr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} ÓÏËÒÁÝÅÎÉÅÍ ÄÌÑ +\tdescr{ÔÅËÓÔÁ ÚÁÍÅÎÙ}, ÇÄÅ \tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ} ÍÏÖÅÔ ÂÙÔØ, × ÓÕÝÎÏÓÔÉ, +ÌÀÂÏÊ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØÀ ÚÎÁËÏ×. +%%A macro definition\index{replacement text?\tdescr{replacement text}}% +%%\index{def?\texttt{def}}\index{enddef?\texttt{enddef}} +%%$$ {\tt def}\, \descr{symbolic token}\, \hbox{\tt =}\, +%% \descr{replacement text}\, {\tt enddef} +%%$$ +%%makes the \tdescr{symbolic token} an abbreviation for the +%%\tdescr{replacement text}, where the \tdescr{replacement text} can be +%%virtually any sequence of tokens. +îÁÐÒÉÍÅÒ, ÍÁËÒÏÐÁËÅÔ Plain ÍÏÇ ÂÙ ÏÐÒÅÄÅÌÉÔØ ËÏÍÁÎÄÕ {\tt fill} ÐÒÉÍÅÒÎÏ +ÔÁË\index{fill?\texttt{fill}}: +$$ \hbox{\tt def fill = addto currentpicture contour enddef} $$ +%%For example, the Plain macro package +%%could almost define the {\tt fill} statement like +%%this\index{fill?\texttt{fill}}: +%%$$ \hbox{\tt def fill = addto currentpicture contour enddef} $$ + +íÁËÒÏÓÙ Ó ÁÒÇÕÍÅÎÔÁÍÉ ÐÏÈÏÖÉ, ÚÁ ÉÓËÌÀÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ ÏÎÉ ÉÍÅÀÔ +ÆÏÒÍÁÌØÎÙÅ ÐÁÒÁÍÅÔÒÙ, ËÏÔÏÒÙÅ ÇÏ×ÏÒÑÔ, ËÁË ÉÓÐÏÌØÚÏ×ÁÔØ ÁÒÇÕÍÅÎÔÙ × +\tdescr{ÔÅËÓÔÅ ÚÁÍÅÎÙ}. +%%Macros with arguments are similar, except they have formal parameters +%%hat tell how to use the arguments in the \tdescr{replacement text}. +îÁÐÒÉÍÅÒ, ÍÁËÒÏÓ {\tt +rotatedaround}\index{rotatedaround?\texttt{rotatedaround}} ÏÐÒÅÄÅÌÑÅÔÓÑ +ÐÒÉÍÅÒÎÏ ÔÁË: +$$\begin{verbatim} +def rotatedaround(expr z, d) = + shifted -z rotated d shifted z enddef; +\end{verbatim} +$$ +%%For example, the {\tt +%%rotatedaround}\index{rotatedaround?\texttt{rotatedaround}} macro is +%%defined like this: +%%$$\begin{verbatim} +%%def rotatedaround(expr z, d) = +%% shifted -z rotated d shifted z enddef; +%%\end{verbatim} +%%$$ +óÌÏ×Ï {\tt expr}\index{expr?\texttt{expr}} × ÜÔÏÍ ÏÐÒÅÄÅÌÅÎÉÉ ÚÎÁÞÉÔ, ÞÔÏ +ÆÏÒÍÁÌØÎÙÅ ÐÁÒÁÍÅÔÒÙ {\tt z} É {\tt d} ÍÏÇÕÔ ÂÙÔØ ÐÒÏÉÚ×ÏÌØÎÙÍÉ ×ÙÒÁÖÅÎÉÑÍÉ. +%%The {\tt expr}\index{expr?\texttt{expr}} in this definition means that +%%formal parameters {\tt z} and {\tt d} can be arbitrary expressions. +üÔÉÍ ÐÁÒÁÍÅÔÒÁÍ ÓÌÅÄÕÅÔ ÓÏÏÔ×ÅÔÓÔ×Ï×ÁÔØ ×ÙÒÁÖÅÎÉÑÍ-ÐÁÒÁÍ, ÎÏ MetaPost ÎÅ +ÐÒÏ×ÅÒÑÅÔ ÜÔÏÇÏ ÓÒÁÚÕ. +%%(They should be pair expressions but the MetaPost interpreter does not +%%immediately check for that.) + +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ MetaPost --- ÜÔÏ ÉÎÔÅÒÐÒÅÔÉÒÕÅÍÙÊ ÑÚÙË, ÍÁËÒÏÓÙ Ó +ÁÒÇÕÍÅÎÔÁÍÉ ÏÞÅÎØ ÐÏÈÏÖÉ ÎÁ ÐÏÄÐÒÏÇÒÁÍÍÙ\index{ÐÏÄÐÒÏÇÒÁÍÍÙ}. +%%Since MetaPost is an interpreted language, macros with arguments are a +%%lot like subroutines\index{subroutines}. +íÁËÒÏÓÙ MetaPost ÞÁÓÔÏ ÉÓÐÏÌØÚÕÀÔÓÑ ÐÏÄÏÂÎÏ ÐÏÄÐÒÏÇÒÁÍÍÁÍ, ÐÏÜÔÏÍÕ ÑÚÙË +×ËÌÀÞÁÅÔ × ÓÅÂÑ ÐÒÏÇÒÁÍÍÎÙÅ ËÏÎÃÅÐÃÉÉ ÄÌÑ ÔÁËÏÇÏ ÉÓÐÏÌØÚÏ×ÁÎÉÑ. +%%MetaPost macros are often used +%%like subroutines, so the language includes programming concepts to +%%support this. +üÔÉ ËÏÎÃÅÐÃÉÉ ×ËÌÀÞÁÀÔ ÌÏËÁÌØÎÙÅ ÐÅÒÅÍÅÎÎÙÅ, ÃÉËÌÙ É ÕÓÌÏ×ÎÙÅ ËÏÍÁÎÄÙ. +%%These concepts include local variables, loops, and +%%conditional statements. + +\subsection{çÒÕÐÐÉÒÏ×ËÁ} +%%\subsection{Grouping} +\label{grsec} + +çÒÕÐÐÉÒÏ×ËÁ × MetaPost ×ÅÓØÍÁ ×ÁÖÎÁ ÄÌÑ ÆÕÎËÃÉÊ\index{ÆÕÎËÃÉÉ} É +ÌÏËÁÌØÎÙÈ\index{ÐÅÒÅÍÅÎÎÙÅ!ÌÏËÁÌØÎÙÅ}\index{ÌÏËÁÌØÎÏÓÔØ} ÐÅÒÅÍÅÎÎÙÈ. +%%Grouping in MetaPost is essential for functions\index{functions} and +%%local\index{variables!local}\index{locality} variables. +âÁÚÏ×ÁÑ ÉÄÅÑ × ÔÏÍ, ÞÔÏ ÇÒÕÐÐÁ --- ÜÔÏ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ËÏÍÁÎÄ, +×ÏÚÍÏÖÎÏ ÚÁ×ÅÒÛÁÀÝÁÑÓÑ ×ÙÒÁÖÅÎÉÅÍ, Ó ÏÂÅÓÐÅÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ ÎÅËÏÔÏÒÙÅ +ÓÉÍ×ÏÌØÎÙÅ ÚÎÁËÉ\index{ÚÎÁËÉ!ÓÉÍ×ÏÌÉÞÅÓËÉÅ} ÍÏÇÕÔ ×ÏÓÓÔÁÎÏ×ÉÔØ Ó×ÏÉ +ÓÔÁÒÙÅ ÚÎÁÞÅÎÉÑ × ËÏÎÃÅ ÇÒÕÐÐÙ. +%%The basic idea +%%is that a group is a sequence of statements possibly followed by an +%%expression with the provision that certain symbolic +%%tokens\index{tokens!symbolic} can have their old meanings restored at +%%the end of the group. +åÓÌÉ ÇÒÕÐÐÁ ÚÁËÁÎÞÉ×ÁÅÔÓÑ ×ÙÒÁÖÅÎÉÅÍ, ÔÏ ÇÒÕÐÐÁ ×ÅÄÅÔ ÓÅÂÑ ÐÏÄÏÂÎÏ +×ÙÚÏ×Õ ÆÕÎËÃÉÉ, ÞÔÏ ×ÏÚ×ÒÁÝÁÅÔ ÜÔÏ ×ÙÒÁÖÅÎÉÅ. +%%If the group ends with an expression, the group +%%behaves like a function call that returns that expression. +÷ ÐÒÏÔÉ×ÎÏÍ ÓÌÕÞÁÅ, ÇÒÕÐÐÁ --- ÜÔÏ ÐÒÏÓÔÏ ÓÏÓÔÁ×ÎÁÑ +ËÏÍÁÎÄÁ\index{ÂÌÏË}. +%%Otherwise, +%%the group is just a compound statement\index{compound statement}. +óÉÎÔÁËÓÉÓ ÄÌÑ ÇÒÕÐÐÙ\index{begingroup?\texttt{begingroup}}\index{endgroup?\texttt{endgroup}} +--- +$$ {\tt begingroup}\, \descr{ÓÐÉÓÏË ËÏÍÁÎÄ}\, {\tt endgroup} $$ +ÉÌÉ +$$ {\tt begingroup}\, \descr{ÓÐÉÓÏË ËÏÍÁÎÄ}\, \descr{×ÙÒÁÖÅÎÉÅ}\, {\tt endgroup}, +$$ +ÇÄÅ \tdescr{ÓÐÉÓÏË ËÏÍÁÎÄ} --- ÜÔÏ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ËÏÍÁÎÄ, ÚÁ +ËÁÖÄÏÊ ÉÚ ËÏÔÏÒÙÈ ÓÌÅÄÕÅÔ ÔÏÞËÁ Ó ÚÁÐÑÔÏÊ. +%%The syntax for a group +%%is\index{begingroup?\texttt{begingroup}}\index{endgroup?\texttt{endgroup}} +%%$$ {\tt begingroup}\, \descr{statement list}\, {\tt endgroup} $$ +%%or +%%$$ {\tt begingroup}\, \descr{statement list}\, \descr{expression}\, {\tt %%endgroup} +%%$$ +%%where a \tdescr{statement list} is a sequence of statements each +%%followed by a semicolon. +çÒÕÐÐÁ Ó \tdescr{×ÙÒÁÖÅÎÉÅÍ} ÐÏÓÌÅ +\tdescr{ÓÐÉÓËÁ ËÏÍÁÎÄ} ×ÅÄÅÔ ÓÅÂÑ ËÁË \tdescr{ÐÅÒ×ÉÞÎÏÓÔØ} ÉÚ +ÒÉÓ.~\ref{syexpr} ÉÌÉ ÐÏÄÏÂÎÏ \tdescr{ÞÉÓÌÏ×ÏÍÕ ÁÔÏÍÕ} ÉÚ +ÒÉÓ.~\ref{synprim}. +%%A group with an \tdescr{expression} after the +%%\tdescr{statement list} behaves like a \tdescr{primary} in +%%Figure~\ref{syexpr} or like a \tdescr{numeric atom} in +%%Figure~\ref{synprim}. + +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ \tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ} ÄÌÑ ÍÁËÒÏÓÁ {\tt +beginfig}\index{beginfig?\texttt{beginfig}} ÎÁÞÉÎÁÅÔÓÑ Ó {\tt +begingroup}, Á \tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ} ÄÌÑ {\tt +endfig}\index{endfig?\texttt{endfig}} ÚÁËÁÎÞÉ×ÁÅÔÓÑ ÎÁ {\tt endgroup}, +ËÁÖÄÁÑ ËÁÒÔÉÎËÁ ×ÈÏÄÎÏÇÏ ÆÁÊÌÁ MetaPost ×ÅÄÅÔ ÓÅÂÑ ËÁË ÇÒÕÐÐÁ. +%%Since the \tdescr{replacement text} for the {\tt +%%beginfig}\index{beginfig?\texttt{beginfig}} macro starts with {\tt +%%begingroup} and the \tdescr{replacement text} for {\tt +%%endfig}\index{endfig?\texttt{endfig}} ends with {\tt endgroup}, each +%%figure in a MetaPost input file behaves like a group. +üÔÏ ÐÏÚ×ÏÌÑÅÔ ËÁÒÔÉÎËÁÍ ÉÍÅÔØ ÌÏËÁÌØÎÙÅ ÐÅÒÅÍÅÎÎÙÅ. +%%This is what allows figures can have local variables. +íÙ ÕÖÅ ×ÉÄÅÌÉ × ÒÁÚÄÅÌÅ~\ref{vardecl}, ÞÔÏ ÉÍÅÎÁ ÐÅÒÅÍÅÎÎÙÈ, +ÎÁÞÉÎÁÀÝÉÅÓÑ Ó {\tt x} ÉÌÉ {\tt y} Ñ×ÌÑÀÔÓÑ ÌÏËÁÌØÎÙÍÉ × ÔÏÍ ÓÍÙÓÌÅ, +ÞÔÏ ÏÎÉ ÓÞÉÔÁÀÔÓÑ ÎÅÉÚ×ÅÓÔÎÙÍÉ × ÎÁÞÁÌÅ ËÁÖÄÏÊ ËÁÒÔÉÎËÉ É ÉÈ ÚÎÁÞÅÎÉÑ +ÚÁÂÙ×ÁÀÔÓÑ × ËÏÎÃÅ ËÁÖÄÏÊ ËÁÒÔÉÎËÉ. +%%We have already seen in +%%Section~\ref{vardecl} that variable names beginning with {\tt x} or {\tt +%%y} are local in the sense that they have unknown values at the beginning +%%of each figure and these values are forgotten at the end of each figure. +óÌÅÄÕÀÝÉÊ ÐÒÉÍÅÒ ÉÌÌÀÓÔÒÉÒÕÅÔ ËÁË ÒÁÂÏÔÁÅÔ ÌÏËÁÌØÎÏÓÔØ. +%%The following example illustrates how locality works: +\begin{eqnarray*} +&& \hbox{\tt x23 = 3.1;}\\ +&& \hbox{\tt beginfig(17);}\\ +&& \qquad \vdots\\ +&& \hbox{\tt y3a=1; x23=2;}\\ +&& \qquad \vdots\\ +&& \hbox{\tt endfig;}\\ +&& \hbox{\tt show x23, y3a;} +\end{eqnarray*} +òÅÚÕÌØÔÁÔ ËÏÍÁÎÄÙ {\tt show}\index{show?\texttt{show}} +%%The result of the {\tt show}\index{show?\texttt{show}} command is +$$\begin{verbatim} +>> 3.1 +>> y3a +\end{verbatim} +$$ +ÐÏËÁÚÙ×ÁÅÔ, ÞÔÏ {\tt x23} ×ÏÚ×ÒÁÝÁÅÔÓÑ Ë Ó×ÏÅÍÕ ÐÒÅÖÎÅÍÕ ÚÎÁÞÅÎÉÀ {\tt 3.1}, +Á {\tt y3a} ÓÏ×ÅÒÛÅÎÎÏ ÎÅÉÚ×ÅÓÔÎÏ, ËÁË ÏÎÏ É ÂÙÌÏ × {\tt beginfig(17)}. +%%indicating that {\tt x23} has returned to its former value of {\tt 3.1} and +%%{\tt y3a} is completely unknown as it was at {\tt beginfig(17)}. + +ìÏËÁÌØÎÏÓÔØ ÐÅÒÅÍÅÎÎÙÈ {\tt x} É {\tt y} ÄÏÓÔÉÇÁÅÔÓÑ +ËÏÍÁÎÄÏÊ\index{save?\texttt{save}}\label{Dsave} +$$ \hbox{\tt save x,y} $$ +× \tdescr{ÔÅËÓÔÅ ÚÁÍÅÎÙ} ÄÌÑ {\tt +beginfig}\index{beginfig?\texttt{beginfig}}. +%%The locality of {\tt x} and {\tt y} variables is achieved by the +%%statement\index{save?\texttt{save}}\label{Dsave} +%%$$ \hbox{\tt save x,y} $$ +%%in the \tdescr{replacement text} for {\tt +%%beginfig}\index{beginfig?\texttt{beginfig}}. +÷ ÏÂÝÅÍ, ÐÅÒÅÍÅÎÎÙÅ ÄÅÌÁÀÔÓÑ ÌÏËÁÌØÎÙÍÉ ËÏÍÁÎÄÏÊ +$$ {\tt save}\, \descr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×}, $$ +ÇÄÅ \tdescr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×} --- ÜÔÏ ÒÁÚÄÅÌÅÎÎÙÊ ÚÁÐÑÔÙÍÉ +ÓÐÉÓÏË ÚÎÁËÏ×:\index{ÚÎÁËÉ!ÓÉÍ×ÏÌÉÞÅÓËÉÅ} +\begin{ctabbing} +$\tt \descr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×} \rightarrow \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}$\\ + $\tt \qquad \;|\; \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}\hbox{\tt ,} + \descr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×}$ +\end{ctabbing} +%%In general, variables are made local by the statement +%%$$ {\tt save}\, \descr{symbolic token list} $$ +%%where \tdescr{symbolic token list} is a comma-separated list of +%%tokens:\index{tokens!symbolic} +%%\begin{ctabbing} +%%$\tt \descr{symbolic token list} \rightarrow \descr{symbolic token}$\\ +%% $\tt \qquad \;|\; \descr{symbolic token}\hbox{\tt ,} +%% \descr{symbolic token list}$ +%%\end{ctabbing} +÷ÓÅ ÐÅÒÅÍÅÎÎÙÅ, ÞØÉ ÉÍÅÎÁ ÎÁÞÉÎÁÀÔÓÑ Ó ÏÄÎÏÇÏ ÉÚ ÕËÁÚÁÎÎÙÈ ÓÉÍ×ÏÌÉÞÅÓËÉÈ +ÚÎÁËÏ×, ÓÔÁÎÏ×ÑÔÓÑ ÎÅÉÚ×ÅÓÔÎÙÍÉ ÞÉÓÌÁÍÉ, Á ÉÈ ÐÒÅÖÎÉÅ ÚÎÁÞÅÎÉÑ ÓÏÈÒÁÎÑÀÔÓÑ +ÄÌÑ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÑ × ËÏÎÃÅ ÔÅËÕÝÅÊ ÇÒÕÐÐÙ. +%%All variables whose names begin with one of the specified symbolic +%%tokens become unknown numerics and their present values are saved for +%%restoration at the end of the current group. +åÓÌÉ ËÏÍÁÎÄÁ {\tt save} ÉÓÐÏÌØÚÕÅÔÓÑ ×ÎÅ ÇÒÕÐÐÙ, ÔÏ ÚÎÁÞÅÎÉÑ ÐÏ-ÐÒÏÓÔÕ +ÎÅ×ÏÓÓÔÁÎÏ×ÉÍÏ ÕÎÉÞÔÏÖÁÀÔÓÑ. +%%If the {\tt save} +%%statement is used outside of a group, the original values are simply +%%discarded. + +çÌÁ×ÎÁÑ ÃÅÌØ ËÏÍÁÎÄÙ {\tt save} ÐÏÚ×ÏÌÉÔØ ÍÁËÒÏÓÁÍ ÉÓÐÏÌØÚÏ×ÁÔØ +ÐÅÒÅÍÅÎÎÙÅ ÂÅÚ ×ÚÁÉÍÏÄÅÊÓÔ×ÉÑ Ó ÓÕÝÅÓÔ×ÕÀÝÉÍÉ ÐÅÒÅÍÅÎÎÙÍÉ ÉÌÉ ÐÅÒÅÍÅÎÎÙÍÉ +× ÎÅÓËÏÌØËÉÈ ×ÙÚÏ×ÁÈ ÏÄÎÏÇÏ É ÔÏÇÏ ÖÅ ÍÁËÒÏÓÁ. +%%The main purpose of the {\tt save} statement is to allow macros to use +%%variables without interfering with existing variables or variables in +%%other calls to the same macro. +îÁÐÒÉÍÅÒ, ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ {\tt +whatever}\index{whatever?\texttt{whatever}} ÉÍÅÅÔ ÔÁËÏÊ \tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ} +$$ \hbox{\tt begingroup save ?; ? endgroup} $$ +%%For example, the predefined macro {\tt +%%whatever}\index{whatever?\texttt{whatever}} has the \tdescr{replacement text} +%%$$ \hbox{\tt begingroup save ?; ? endgroup} $$ +ïÎ ×ÏÚ×ÒÁÝÁÅÔ ÎÅÉÚ×ÅÓÔÎÏÅ ÞÉÓÌÏ×ÏÅ ËÏÌÉÞÅÓÔ×Ï, ÎÏ ÏÎÏ ÎÅ ÚÏ×ÅÔÓÑ ÂÏÌØÛÅ +ÚÎÁËÏÍ ×ÏÐÒÏÓÁ, ÐÏÔÏÍÕ ÞÔÏ ÜÔÏ ÉÍÑ ÂÙÌÏ ÌÏËÁÌØÎÙÍ × ÇÒÕÐÐÅ. +%%This returns an unknown numeric quantity, but it is no longer called +%%question mark since that name was local to the group. +óÐÒÁÛÉ×ÁÑ ÉÍÑ ÞÅÒÅÚ {\tt show\index{show?\texttt{show}} whatever}, +ÐÏÌÕÞÁÅÍ\index{CAPSULE?\texttt{CAPSULE}} +$$ \hbox{\tt >> \%CAPSULE}{\it nnnn}, $$ +ÇÄÅ {\it nnnn} --- ÜÔÏ ÉÄÅÎÔÉÆÉËÁÃÉÏÎÎÙÊ ÎÏÍÅÒ, ×ÙÂÉÒÁÅÍÙÊ, ËÏÇÄÁ {\tt save} +ÏÒÇÁÎÉÚÕÅÔ ÉÓÞÅÚÎÏ×ÅÎÉÅ ÉÍÅÎÉ ÚÎÁË ×ÏÐÒÏÓÁ. +%%Asking the name via {\tt show\index{show?\texttt{show}} whatever} +%%yields\index{CAPSULE?\texttt{CAPSULE}} +%%$$ \hbox{\tt >> \%CAPSULE}{\it nnnn} $$ +%%where {\it nnnn} is an identification number that is chosen when {\tt save} +%%makes the name question mark disappear. + +÷ÏÐÒÅËÉ ÕÎÉ×ÅÒÓÁÌØÎÏÓÔÉ, {\tt save} ÎÅ ÍÏÖÅÔ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ +ÄÌÑ ÌÏËÁÌØÎÏÇÏ ÉÚÍÅÎÅÎÉÑ ÌÀÂÏÊ ×ÎÕÔÒÅÎÎÅÊ ÐÅÒÅÍÅÎÎÏÊ\index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} MetaPost. +%%In spite of the versatility of {\tt save}, it cannot be used to make +%%local changes to any of MetaPost's internal variables\index{internal +%%variables}\index{variables!internal}. +ëÏÍÁÎÄÁ, ÔÁËÁÑ ËÁË +$$ \hbox{\tt save linecap}, $$ +ÐÒÉ×ÅÄÅÔ MetaPost Ë ×ÒÅÍÅÎÎÏÍÕ ÚÁÂÙ×ÁÎÉÀ ÓÐÅÃÉÁÌØÎÏÇÏ ÚÎÁÞÅÎÉÑ ÜÔÏÊ +ÐÅÒÅÍÅÎÎÏÊ É ÓÄÅÌÁÅÔ ÅÅ ÏÂÙÞÎÏÊ ÎÅÉÚ×ÅÓÔÎÏÊ ÞÉÓÌÏ×ÏÊ ×ÅÌÉÞÉÎÏÊ. +%%A statement such as\index{linecap?\texttt{linecap}} +%%$$ \hbox{\tt save linecap} $$ +%%would cause MetaPost to temporarily forget the special meaning of this +%%variable and just make it an unknown numeric. +åÓÌÉ ×Ù ÈÏÔÉÔÅ ÎÁÒÉÓÏ×ÁÔØ ÏÄÎÕ ÐÕÎËÔÉÒÎÕÀ ÌÉÎÉÀ Ó {\tt linecap:=butt} É +ÚÁÔÅÍ ×ÅÒÎÕÔØÓÑ ÎÁÚÁÄ Ë ÐÒÅÖÎÅÍÕ ÚÎÁÞÅÎÉÀ, ÔÏ ×Ù ÍÏÖÅÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ +ËÏÍÁÎÄÕ {\tt +interim}\index{interim?\texttt{interim}}\label{Dinterm} ËÁË +× ÓÌÅÄÕÀÝÅÍ ÐÒÉÍÅÒÅ: +\begin{eqnarray*} +&& \hbox{\tt begingroup interim linecap:=butt;}\\ +&& {\tt draw}\, \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\, \hbox{\tt dashed evenly; endgroup} +\end{eqnarray*} +%%If you want to draw one +%%dashed line with {\tt linecap:=butt} and then go back to the previous +%%value, you can use the {\tt +%%interim}\index{interim?\texttt{interim}}\label{Dinterm} statement as +%%follows: +%%\begin{eqnarray*} +%%&& \hbox{\tt begingroup interim linecap:=butt;}\\ +%%&& {\tt draw}\, \descr{path expression}\, \hbox{\tt dashed evenly; endgroup} +%%\end{eqnarray*} +üÔÏ ÓÏÈÒÁÎÉÔ ÚÎÁÞÅÎÉÅ ×ÎÕÔÒÅÎÎÅÊ +ÐÅÒÅÍÅÎÎÏÊ\index{×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} +{\tt linecap}, ×ÒÅÍÅÎÎÏ ÄÁÓÔ ÅÊ ÎÏ×ÏÅ ÚÎÁÞÅÎÉÅ É ÜÔÏ ÎÅ ÐÒÉ×ÅÄÅÔ Ë +ÚÁÂÙ×ÁÎÉÀ ÔÏÇÏ, ÞÔÏ {\tt linecap} --- ×ÎÕÔÒÅÎÎÑÑ ÐÅÒÅÍÅÎÎÁÑ. +%%This saves the value of the +%%internal variable\index{internal variables}\index{variables!internal} +%%{\tt linecap} and temporarily +%%gives it a new value without forgetting that {\tt linecap} is an internal +%%variable. +ïÂÝÉÊ ÓÉÎÔÁËÓÉÓ: +$$ {\tt interim}\, \descr{×ÎÕÔÒÅÎÎÑÑ ÐÅÒÅÍÅÎÎÁÑ} \mathrel{\hbox{\tt:=}} + \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} +$$ +%%The general syntax is +%%$$ {\tt interim}\, \descr{internal variable} \mathrel{\hbox{\tt:=}} +%% \descr{numeric expression} +%%$$ + +\subsection{ðÁÒÁÍÅÔÒÉÚÏ×ÁÎÎÙÅ ÍÁËÒÏÓÙ} +%%\subsection{Parameterized Macros} + +âÁÚÏ×ÁÑ ÉÄÅÑ ÍÁËÒÏÓÏ× Ó ÐÁÒÁÍÅÔÒÁÍÉ × ÄÏÓÔÉÖÅÎÉÉ ÂÏÌØÛÅÊ ÇÉÂËÏÓÔÉ ÐÅÒÅÄÁÞÅÊ +ÄÏÂÁ×ÏÞÎÏÊ ÉÎÆÏÒÍÁÃÉÉ × ÍÁËÒÏÓ. +%%The basic idea behind parameterized macros is to achieve greater flexibility by +%%allowing auxiliary information to be passed to a macro. +íÙ ÕÖÅ ×ÉÄÅÌÉ, ÞÔÏ ÏÐÒÅÄÅÌÅÎÉÑ ÍÁËÒÏÓÏ× ÍÏÇÕÔ ÉÍÅÔØ ÆÏÒÍÁÌØÎÙÅ ÐÁÒÁÍÅÔÒÙ ÄÌÑ +×ÙÒÁÖÅÎÉÊ, ÚÁÄÁ×ÁÅÍÙÈ ÐÒÉ ×ÙÚÏ×Å ÍÁËÒÏÓÁ. +%%We have already seen +%%that macro definitions can have formal parameters that represent expressions +%%to be given when the macro is called. +îÁÐÒÉÍÅÒ, ÏÐÒÅÄÅÌÅÎÉÅ +$$ \hbox{\tt def rotatedaround(expr z, d) = } \descr{ÔÅËÓÔ ÚÁÍÅÎÙ}\, + {\tt enddef} +$$ +ÐÏÚ×ÏÌÑÅÔ MetaPost-ÉÎÔÅÒÐÒÅÔÁÔÏÒÕ ÐÏÎÉÍÁÔØ ×ÙÚÏ×Ù ÍÁËÒÏÓÁ × ÆÏÒÍÅ +$$\tt rotatedaround\hbox{\tt (} + \descr{×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ}\hbox{\tt )} +$$ +%%For instance a definition such as +%%$$ \hbox{\tt def rotatedaround(expr z, d) = } \descr{replacement text}\, +%% {\tt enddef} +%%$$ +%%allows the MetaPost interpreter to understand macro calls of the form +%%$$\tt rotatedaround\hbox{\tt (} +%% \descr{expression}\hbox{\tt ,} \descr{expression}\hbox{\tt )} +%%$$ + +ëÌÀÞÅ×ÏÅ ÓÌÏ×Ï {\tt expr}\index{expr?\texttt{expr}}\index{ÐÁÒÁÍÅÔÒ!expr} +× ÏÐÒÅÄÅÌÅÎÉÉ ÍÁËÒÏÓÁ ÚÎÁÞÉÔ, ÞÔÏ ÐÁÒÁÍÅÔÒÙ ÍÏÇÕÔ ÂÙÔØ ×ÙÒÁÖÅÎÉÑÍÉ ÌÀÂÏÇÏ +ÔÉÐÁ. +%%The keyword {\tt expr}\index{expr?\texttt{expr}}\index{parameter!expr} +%%in the macro definition means that the parameters can be expressions of +%%any type. +ëÏÇÄÁ ÏÐÒÅÄÅÌÅÎÉÅ ÕËÁÚÙ×ÁÅÔ {\tt (expr z, d)}, ÔÏ ÆÏÒÍÁÌØÎÙÅ +ÐÁÒÁÍÅÔÒÙ {\tt z} É {\tt d} ×ÅÄÕÔ ÓÅÂÑ ÐÏÄÏÂÎÏ ÐÅÒÅÍÅÎÎÙÍ ÐÏÄÈÏÄÑÝÅÇÏ ÔÉÐÁ. +%%When the definition specifies {\tt (expr z, d)}, the formal +%%parameters {\tt z} and {\tt d} behave like variables of the appropriate +%%types. +÷ÎÕÔÒÉ \tdescr{ÔÅËÓÔÁ ÚÁÍÅÎÙ} ÏÎÉ ÍÏÇÕÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÙ × ×ÙÒÁÖÅÎÉÑÈ, +ËÁË ÏÂÙÞÎÙÅ ÐÅÒÅÍÅÎÎÙÅ, ÎÏ ÏÎÉ ÎÅ ÍÏÇÕÔ ÐÏ×ÔÏÒÎÏ ÄÅËÌÁÒÉÒÏ×ÁÔØÓÑ ÉÌÉ +ÐÏÌÕÞÁÔØ ÎÏ×ÙÅ ÚÎÁÞÅÎÉÑ. +%%Within the \tdescr{replacement text}, they can be used in +%%expressions just like variables, but they cannot be redeclared or +%%assigned to. +îÅÔ ÏÇÒÁÎÉÞÅÎÉÊ ÎÁ ÎÅÉÚ×ÅÓÔÎÙÅ ÉÌÉ ÞÁÓÔÉÞÎÏ ÉÚ×ÅÓÔÎÙÅ ÁÒÇÕÍÅÎÔÙ. +%%There is no restriction against unknown or partially known +%%arguments. +ðÏÜÔÏÍÕ ÏÐÒÅÄÅÌÅÎÉÅ\index{midpoint?\texttt{midpoint}} +$$ \hbox{\tt def midpoint(expr a, b) = (.5[a,b]) enddef} $$ +ÐÒÅËÒÁÓÎÏ ÒÁÂÏÔÁÅÔ ÄÌÑ ÎÅÉÚ×ÅÓÔÎÙÈ {\tt a} É {\tt b}. +%%Thus the definition\index{midpoint?\texttt{midpoint}} +%%$$ \hbox{\tt def midpoint(expr a, b) = (.5[a,b]) enddef} $$ +%%works perfectly well when {\tt a} and {\tt b} are unknown. +õÒÁ×ÎÅÎÉÅ, ÔÁËÏÅ ËÁË +$$ \hbox{\tt midpoint(z1,z2) = (1,1)}, $$ +ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÏ ÄÌÑ ÏÐÒÅÄÅÌÅÎÉÑ {\tt z1} É {\tt z2}. +%%An equation such as +%%$$ \hbox{\tt midpoint(z1,z2) = (1,1)} $$ +%%could be used to help determine {\tt z1} and {\tt z2}. + +úÁÍÅÔØÔÅ, ÞÔÏ ÏÐÒÅÄÅÌÅÎÉÅ ×ÙÛÅ ÄÌÑ {\tt midpoint} ÒÁÂÏÔÁÅÔ ÄÌÑ ÞÉÓÅÌ, +ÐÁÒ ÉÌÉ Ã×ÅÔÏ× --- ÎÕÖÎÏ ÔÏÌØËÏ ÓÏ×ÐÁÄÅÎÉÅ ÔÉÐÏ× ÏÂÏÉÈ ÐÁÒÁÍÅÔÒÏ×. +%%Notice that the above definition for {\tt midpoint} works for numerics, +%%pairs, or colors as long as both parameters have the same type. +åÓÌÉ ÚÁÞÅÍ-ÔÏ ÎÕÖÅÎ ÍÁËÒÏÓ {\tt +middlepoint}\index{middlepoint?\texttt{middlepoint}}, ÒÁÂÏÔÁÀÝÉÊ ÔÏÌØËÏ +ÄÌÑ ÐÕÔÉ ÉÌÉ ÒÉÓÕÎËÁ, ÔÏ ÂÕÄÅÔ ÎÅÏÂÈÏÄÉÍÏ ×ÙÐÏÌÎÑÔØ +ÐÒÏ×ÅÒËÕ {\tt if}\index{if?\texttt{if}} ÔÉÐÁ ÁÒÇÕÍÅÎÔÁ. +%%If for some reason we want a {\tt +%%middlepoint}\index{middlepoint?\texttt{middlepoint}} macro that works +%%for a single path or picture, it would be necessary to do an {\tt +%%if}\index{if?\texttt{if}} test on the argument type. +åÓÔØ ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ\index{path?\texttt{path}} +$$ {\tt path}\, \descr{ÐÅÒ×ÉÞÎÏÓÔØ}, $$ +×ÏÚ×ÒÁÝÁÀÝÉÊ ÌÏÇÉÞÅÓËÉÊ ÒÅÚÕÌØÔÁÔ, ÐÏËÁÚÙ×ÁÀÝÉÊ Ñ×ÌÑÅÔÓÑ ÌÉ ÅÇÏ ÁÒÇÕÍÅÎÔ ÐÕÔÅÍ. +%%This uses the fact +%%there is a unary operator\index{path?\texttt{path}} +%%$$ {\tt path}\, \descr{primary} $$ +%%that returns a boolean result indicating whether its argument is a path. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÐÒÏ×ÅÒËÁ {\tt if} ÉÍÅÅÔ ÂÁÚÏ×ÙÊ +ÓÉÎÔÁËÓÉÓ\index{else?\texttt{else}}\index{fi?\texttt{fi}} +$$ {\tt if}\, \descr{ÌÏÇÉÞÅÓËÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt:}\, \descr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ}\, + \hbox{\tt else:}\, \descr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ}\, {\tt fi}, +$$ +ÇÄÅ \tdescr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ}\index{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ?\tdescr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ}} +ÍÏÇÕÔ ÂÙÔØ ÞÅÍ-ÕÇÏÄÎÏ, ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÍ +ÏÔÎÏÓÉÔÅÌØÎÏ {\tt if} É {\tt fi}, ÐÏÌÎÙÊ ÍÁËÒÏÓ {\tt +middlepoint}\index{middlepoint?\texttt{middlepoint}} Ó ÐÒÏ×ÅÒËÏÊ ÔÉÐÁ ÍÏÖÅÔ ×ÙÇÌÑÄÅÔØ +ÔÁË: +$$\begin{verbatim} +def middlepoint(expr a) = if path a: (point .5*length a of a) + else: .5(llcorner a + urcorner a) fi enddef; +\end{verbatim} +$$ +%%Since the basic {\tt if} test has the +%%syntax\index{else?\texttt{else}}\index{fi?\texttt{fi}} +%%$$ {\tt if}\, \descr{boolean expression}\hbox{\tt:}\, \descr{balanced tokens}\, +%% \hbox{\tt else:}\, \descr{balanced tokens}\, {\tt fi} +%%$$ +%%where the \tdescr{balanced tokens}\index{balanced +%%tokens?\tdescr{balanced tokens}} can be anything that is balanced with +%%respect to {\tt if} and {\tt fi}, the complete {\tt +%%middlepoint}\index{middlepoint?\texttt{middlepoint}} macro with type test +%%looks like this: +%%$$\begin{verbatim} +%%def middlepoint(expr a) = if path a: (point .5*length a of a) +%% else: .5(llcorner a + urcorner a) fi enddef; +%%\end{verbatim} +%%$$ +ðÏÌÎÙÊ ÓÉÎÔÁËÓÉÓ ÐÒÏ×ÅÒËÉ {\tt if} ÐÏËÁÚÁÎ ÎÁ ÒÉÓ.~\ref{syif}. +%%The complete syntax for {\tt if} tests is shown in Figure~\ref{syif}. +ðÏÚ×ÏÌÑÀÔÓÑ ÍÎÏÇÏËÒÁÔÎÙÅ ÐÒÏ×ÅÒËÉ {\tt if}, ÎÁÐÒÉÍÅÒ, +$$ \hbox{\tt if $e_1$: \ldots\ else: if $e_2$: \ldots\ else: \ldots\ fi fi},$$ +ËÏÔÏÒÙÅ ÍÏÖÎÏ ÓÏËÒÁÔÉÔØ ÄÏ\index{elseif?\texttt{elseif}} +$$ \hbox{\tt if $e_1$: \ldots\ elseif $e_2$: \ldots\ else: \ldots\ fi}, $$ +ÇÄÅ $e_1$ É $e_2$ ÐÒÅÄÓÔÁ×ÌÑÀÔ ÌÏÇÉÞÅÓËÉÅ ×ÙÒÁÖÅÎÉÑ. +%%It allows multiple {\tt if} tests like +%%$$ \hbox{\tt if $e_1$: \ldots\ else: if $e_2$: \ldots\ else: \ldots\ fi fi} $$ +%%to be shortened to\index{elseif?\texttt{elseif}} +%%$$ \hbox{\tt if $e_1$: \ldots\ elseif $e_2$: \ldots\ else: \ldots\ fi} $$ +%%where $e_1$ and $e_2$ represent boolean expressions. + +ïÂÒÁÔÉÔÅ ×ÎÉÍÁÎÉÅ, ÞÔÏ ÐÒÏ×ÅÒËÉ {\tt if} ÎÅ Ñ×ÌÑÀÔÓÑ ËÏÍÁÎÄÁÍÉ É +\tdescr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ} +× ÓÉÎÔÁËÓÉÞÅÓËÉÈ ÐÒÁ×ÉÌÁÈ ÍÏÇÕÔ ÎÅ ÂÙÔØ ÐÏÌÎÙÍÉ ×ÙÒÁÖÅÎÉÑÍÉ ÉÌÉ ËÏÍÁÎÄÁÍÉ. +%%Note that {\tt if} tests are not statements and the \tdescr{balanced +%%tokens} in the syntax rules can be any sequence of balanced tokens even +%%if they do not form a complete expression or statement. +ðÏÜÔÏÍÕ ÍÏÖÎÏ, ÐÏÖÅÒÔ×Ï×Á× ÎÁÇÌÑÄÎÏÓÔØÀ, ÕÂÒÁÔØ Ä×Á ÚÎÁËÁ × ÏÐÒÅÄÅÌÅÎÉÉ +{\tt middlepoint}: +$$\begin{verbatim} +def middlepoint(expr a) = if path a: (point .5*length a of + else: .5(llcorner a + urcorner fi a) enddef; +\end{verbatim} +$$ +%%Thus we could +%%have saved two tokens at the expense of clarity by defining {\tt +%%middlepoint} like this: +%%$$\begin{verbatim} +%%def middlepoint(expr a) = if path a: (point .5*length a of +%% else: .5(llcorner a + urcorner fi a) enddef; +%%\end{verbatim} +%%$$ + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÐÒÏ×ÅÒËÁ if} \rightarrow if \descr{ÌÏÇÉÞÅÓËÏÅ ×ÙÒÁÖÅÎÉÅ} \hbox{\tt :} + \descr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ} \descr{ÁÌØÔÅÒÎÁÔÉ×Ù} fi$\\ +%%$\tt \descr{if test} \rightarrow if \descr{boolean expression} \hbox{\tt :} +%% \descr{balanced tokens} \descr{alternatives} fi$\\ +$\tt \descr{ÁÌØÔÅÒÎÁÔÉ×Ù} \rightarrow \descr{ÐÕÓÔÏ}$\\ +%%$\tt \descr{alternatives} \rightarrow \descr{empty}$\\ +$\tt \qquad \;|\; else\hbox{\tt :} \descr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ}$\\ +%%$\tt \qquad \;|\; else\hbox{\tt :} \descr{balanced tokens}$\\ +$\tt \qquad \;|\; elseif \descr{ÌÏÇÉÞÅÓËÏÅ ×ÙÒÁÖÅÎÉÅ} \hbox{\tt :} + \descr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ} \descr{ÁÌØÔÅÒÎÁÔÉ×Ù}$ +%%$\tt \qquad \;|\; elseif \descr{boolean expression} \hbox{\tt :} +%% \descr{balanced tokens} \descr{alternatives}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ÐÒÏ×ÅÒËÉ {\tt if}.} +%%\caption{The syntax for {\tt if} tests.} +\label{syif} +\end{figure} + +îÁÓÔÏÑÝÅÅ ÎÁÚÎÁÞÅÎÉÅ ÍÁËÒÏÓÏ× É ÐÒÏ×ÅÒÏË {\tt if} × Á×ÔÏÍÁÔÉÚÁÃÉÉ ÒÅÛÅÎÉÑ +ÐÏ×ÔÏÒÑÀÝÉÈÓÑ ÚÁÄÁÞ, Á ÔÁËÖÅ × ×ÏÚÍÏÖÎÏÓÔÉ ÒÅÛÁÔØ ÐÏÄÚÁÄÁÞÉ ÐÏ-ÏÔÄÅÌØÎÏÓÔÉ. +%%The real purpose of macros and {\tt if} tests is to automate repetitive +%%tasks and allow important subtasks to be solved separately. +îÁÐÒÉÍÅÒ, ÒÉÓ.~\ref{fig42} ÉÓÐÏÌØÚÕÅÔ ÍÁËÒÏÓÙ \verb|draw_marked|, +\verb|mark_angle| É \verb|mark_rt_angle| ÄÌÑ ÏÔÍÅÔËÉ ÌÉÎÉÊ É ÕÇÌÏ×, +ÐÏÑ×ÌÑÀÝÉÈÓÑ ÎÁ ÒÉÓÕÎËÅ. +%%For example, Figure~\ref{fig42} uses macros \verb|draw_marked|, +%%\verb|mark_angle|, and \verb|mark_rt_angle| to mark lines and angles +%%that appear in the figure. + +\begin{figure}[htp] +$$\begin{verbatim} +beginfig(42); +pair a,b,c,d; +b=(0,0); c=(1.5in,0); a=(0,.6in); +d-c = (a-b) rotated 25; +dotlabel.lft("a",a); +dotlabel.lft("b",b); +dotlabel.bot("c",c); +dotlabel.llft("d",d); +z0=.5[a,d]; +z1=.5[b,c]; +(z.p-z0) dotprod (d-a) = 0; +(z.p-z1) dotprod (c-b) = 0; +draw a--d; +draw b--c; +draw z0--z.p--z1; +draw_marked(a--b, 1); +draw_marked(c--d, 1); +draw_marked(a--z.p, 2); +draw_marked(d--z.p, 2); +draw_marked(b--z.p, 3); +draw_marked(c--z.p, 3); +mark_angle(z.p, b, a, 1); +mark_angle(z.p, c, d, 1); +mark_angle(z.p, c, b, 2); +mark_angle(c, b, z.p, 2); +mark_rt_angle(z.p, z0, a); +mark_rt_angle(z.p, z1, b); +endfig; +\end{verbatim} +\quad \mathcenter{\includegraphics{manfig-ru-42}} +$$ +\caption{ëÏÄ MetaPost É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ÒÉÓÕÎÏË} +%%\caption{MetaPost code and the corresponding figure} +\label{fig42} +\end{figure} + +úÁÄÁÞÁ ÍÁËÒÏÓÁ \verb|draw_marked|\index{draw_marked?\texttt{draw\_marked}} +--- ÎÁÒÉÓÏ×ÁÔØ ÐÕÔØ Ó ÚÁÄÁÎÎÙÍ ÞÉÓÌÏÍ ÐÅÒÅÓÅËÁÀÝÉÈ ÏÔÍÅÔÏË ÐÏÓÅÒÅÄÉÎÅ. +%%The task of the +%%\verb|draw_marked|\index{draw_marked?\texttt{draw\_marked}} macro is to +%%draw a path with a given number of cross marks near its midpoint. +óÔÏÉÔ ÎÁÞÁÔØ Ó ÐÏÄÚÁÄÁÞÉ ÒÉÓÏ×ÁÎÉÑ ÏÄÎÏÊ ÐÅÒÅÓÅËÁÀÝÅÊ ÐÕÔØ {\tt p} +ÐÅÒÐÅÎÄÉËÕÌÑÒÎÏ ÏÔÍÅÔËÉ × ÎÅËÏÔÏÒÏÅ ×ÒÅÍÑ {\tt t}. +%%A convenient starting place is the subproblem of drawing a single cross +%%mark perpendicular to a path {\tt p} at some time {\tt t}. +íÁËÒÏÓ \verb|draw_mark|\index{draw_mark?\texttt{draw\_mark}} ÎÁ +ÒÉÓ.~\ref{drawmarked} ÒÅÛÁÅÔ ÜÔÕ ÐÏÄÚÁÄÁÞÕ ÎÁÈÏÖÄÅÎÉÅÍ ÓÎÁÞÁÌÁ ×ÅËÔÏÒÁ +{\tt dm}, ÐÅÒÐÅÎÄÉËÕÌÑÒÎÏÇÏ {\tt p} ×~{\tt t}. +%%The \verb|draw_mark|\index{draw_mark?\texttt{draw\_mark}} macro in +%%Figure~\ref{drawmarked} does this by first finding a vector {\tt dm} +%%perpendicular to~{\tt p} at~{\tt t}. +äÌÑ ÕÐÒÏÝÅÎÉÑ ÐÏÚÉÃÉÏÎÉÒÏ×ÁÎÉÑ ÐÅÒÅÓÅËÁÀÝÅÊ ÏÔÍÅÔËÉ ÏÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ +\verb|draw_marked| ÂÅÒÅÔ ÄÌÉÎÕ ÄÕÇÉ\index{ÄÌÉÎÁ ÄÕÇÉ} {\tt a} +×ÄÏÌØ {\tt p} É ÏÐÅÒÁÔÏÒÏÍ {\tt +arctime}\index{arctime of?\texttt{arctime of}} ×ÙÞÉÓÌÑÅÔ~{\tt t} +%%To simplify positioning the cross +%%mark, the \verb|draw_marked| macro is defined to take an arc +%%length\index{arc length} {\tt a} along {\tt p} and use the {\tt +%%arctime}\index{arctime} operator to compute~{\tt t} + +ó ÒÅÛÅÎÉÅÍ ÐÏÄÚÁÄÁÞÉ ÒÉÓÏ×ÁÎÉÑ ÏÄÎÏÊ ÏÔÍÅÔËÉ, ÍÁËÒÏÓÕ \verb|draw_marked| +ÏÓÔÁÎÅÔÓÑ ÔÏÌØËÏ ÎÁÒÉÓÏ×ÁÔØ ÐÕÔØ É ×ÙÚ×ÁÔØ \verb|draw_mark| Ó +ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÊ ÄÌÉÎÏÊ ÄÕÇÉ. +%%With the subproblem of drawing a single mark out of the way, the +%%\verb|draw_marked| macro only needs to draw the path and call +%%\verb|draw_mark| with the appropriate arc length values. +íÁËÒÏÓ \verb|draw_marked| ÎÁ ÒÉÓ.~\ref{drawmarked} ÉÓÐÏÌØÚÕÅÔ +ÁÒÉÆÍÅÔÉÞÅÓËÕÀ ÐÒÏÇÒÅÓÓÉÀ ÉÚ {\tt n} ÚÎÁÞÅÎÉÊ {\tt a}, ÃÅÎÔÒ ËÏÔÏÒÙÈ +ÐÏÍÅÝÁÅÔÓÑ × {\tt .5*arclength~p}\index{arclength?\texttt{arclength}}. +%%The \verb|draw_marked| macro in Figure~\ref{drawmarked} uses {\tt n} +%%equally-spaced {\tt a} values centered on {\tt +%%.5*arclength~p}\index{arclength?\texttt{arclength}}. + +\begin{figure}[htp] +$$\begin{verbatim} +marksize=4pt; + +def draw_mark(expr p, a) = + begingroup + save t, dm; pair dm; + t = arctime a of p; + dm = marksize*unitvector direction t of p + rotated 90; + draw (-.5dm.. .5dm) shifted point t of p; + endgroup +enddef; + +def draw_marked(expr p, n) = + begingroup + save amid; + amid = .5*arclength p; + for i=-(n-1)/2 upto (n-1)/2: + draw_mark(p, amid+.6marksize*i); + endfor + draw p; + endgroup +enddef; +\end{verbatim} +$$ +\caption{íÁËÒÏÓÙ ÄÌÑ ÒÉÓÏ×ÁÎÉÑ ÐÕÔÉ {\tt p} Ó {\tt n} ÐÅÒÅÓÅËÁÀÝÉÍÉ ÏÔÍÅÔËÁÍÉ.} +%%\caption{Macros for drawing a path {\tt p} with {\tt n} cross marks.} +\label{drawmarked} +\end{figure} + +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ \verb|draw_marked| ÒÁÂÏÔÁÅÔ ÄÌÑ ËÒÉ×ÙÈ, ÏÎ ÍÏÖÅÔ ÂÙÔØ +ÉÓÐÏÌØÚÏ×ÁÎ ÄÌÑ ÒÉÓÏ×ÁÎÉÑ ÄÕÇ, ÇÅÎÅÒÉÒÕÅÍÙÈ ÍÁËÒÏÓÏÍ +\verb|mark_angle|\index{mark_angle?\texttt{mark\_angle}}. +%%Since \verb|draw_marked| works for curved lines, it can be used to draw +%%the arcs that the +%%\verb|mark_angle|\index{mark_angle?\texttt{mark\_angle}} macro +%%generates. +ó ÚÁÄÁÎÎÙÍÉ ÔÏÞËÁÍÉ {\tt a}, {\tt b} É {\tt c}, ÏÐÒÅÄÅÌÑÀÝÉÍÉ +ÎÁÐÒÁ×ÌÅÎÎÙÊ ÐÒÏÔÉ× ÞÁÓÏ×ÏÊ ÓÔÒÅÌËÉ ÕÇÏÌ × {\tt b}, \verb|mark_angle| +ÄÏÌÖÅÎ ÓÇÅÎÅÒÉÒÏ×ÁÔØ ÍÁÌÅÎØËÕÀ ÄÕÇÕ ÏÔ ÏÔÒÅÚËÁ {\tt ba} ÄÏ +ÏÔÒÅÚËÁ {\tt bc}. +%%Given points {\tt a}, {\tt b}, and {\tt c} that define a +%%counter-clockwise angle at {\tt b}, the \verb|mark_angle| needs to +%%generate a small arc from segment {\tt ba} to segment {\tt bc}. +ïÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ ÎÁ ÒÉÓ.~\ref{markangle} ÄÅÌÁÅÔ ÜÔÏ ÓÏÚÄÁÎÉÅÍ +ÄÕÇÉ {\tt p} Ó ÅÄÉÎÉÞÎÙÍ ÒÁÄÉÕÓÏÍ É ÚÁÔÅÍ ×ÙÞÉÓÌÅÎÉÅÍ ÍÁÓÛÔÁÂÉÒÕÀÝÅÇÏ +ÍÎÏÖÉÔÅÌÑ {\tt s}, ËÏÔÏÒÙÊ ÄÅÌÁÅÔ ÅÅ ÄÏÓÔÁÔÏÞÎÏ ÂÏÌØÛÏÊ ÎÁ ×ÉÄ. +%%The +%%macro definition in Figure~\ref{markangle} does this by creating an arc +%%{\tt p} of radius one and then computing a scale factor {\tt s} that +%%makes it big enough to see clearly. + +íÁËÒÏÓ \verb|mark_rt_angle|\index{mark_rt_angle?\texttt{mark\_rt\_angle}} +ÎÁÍÎÏÇÏ ÐÒÏÝÅ. +%%The \verb|mark_rt_angle|\index{mark_rt_angle?\texttt{mark\_rt\_angle}} +%%macro is much simpler. +ïÎ ÂÅÒÅÔ ÏÂÝÉÊ ÐÒÑÍÏÊ ÕÇÏÌ É ÉÓÐÏÌØÚÕÅÔ ÏÐÅÒÁÔÏÒ {\tt zscaled}\index{zscaled?\texttt{zscaled}} ÄÌÑ ÎÅÏÂÈÏÄÉÍÙÈ ×ÒÁÝÅÎÉÑ É +ÍÁÓÛÔÁÂÉÒÏ×ÁÎÉÑ. +%%It takes a generic right-angle corner and uses +%%the {\tt zscaled}\index{zscaled?\texttt{zscaled}} operator to rotate it +%%and scale it as necessary. + +\begin{figure}[htp] +$$\begin{verbatim} +angle_radius=8pt; + +def mark_angle(expr a, b, c, n) = + begingroup + save s, p; path p; + p = unitvector(a-b){(a-b)rotated 90}..unitvector(c-b); + s = .9marksize/length(point 1 of p - point 0 of p); + if s<angle_radius: s:=angle_radius; fi + draw_marked(p scaled s shifted b, n); + endgroup +enddef; + +def mark_rt_angle(expr a, b, c) = + draw ((1,0)--(1,1)--(0,1)) + zscaled (angle_radius*unitvector(a-b)) shifted b +enddef; +\end{verbatim} +$$ +\caption{íÁËÒÏÓÙ ÄÌÑ ÏÔÍÅÔËÉ ÕÇÌÏ×.} +%%\caption{Macros for marking angles.} +\label{markangle} +\end{figure} + + +\subsection{óÕÆÆÉËÓÎÙÅ É ÔÅËÓÔÏ×ÙÅ ÐÁÒÁÍÅÔÒÙ} +%%\subsection{Suffix and Text Parameters} + +ðÁÒÁÍÅÔÒÙ ÍÁËÒÏÓÁ ÎÅ ×ÓÅÇÄÁ ÄÏÌÖÎÙ ÂÙÔØ ×ÙÒÁÖÅÎÉÑÍÉ, ËÁË × ÐÒÅÄÙÄÕÝÉÈ +ÐÒÉÍÅÒÁÈ. +%%Macro parameters need not always be expressions as in the previous +%%examples. +úÁÍÅÎÁ ËÌÀÞÅ×ÏÇÏ ÓÌÏ×Á {\tt expr} ÎÁ {\tt +suffix}\index{suffix?\texttt{suffix}} ÉÌÉ {\tt +text}\index{text?\texttt{text}} × ÏÐÒÅÄÅÌÅÎÉÉ ÍÁËÒÏÓÁ ÏÂßÑ×ÌÑÅÔ ÐÁÒÁÍÅÔÒÙ +ÓÏÏÔ×ÅÔÓÔ×ÅÎÎÏ ÉÍÅÎÁÍÉ ÐÅÒÅÍÅÎÎÙÈ ÉÌÉ ÐÒÏÉÚ×ÏÌØÎÏÊ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØÀ +ÚÎÁËÏ×. +%%Replacing the keyword {\tt expr} with {\tt +%%suffix}\index{suffix?\texttt{suffix}} or {\tt +%%text}\index{text?\texttt{text}} in a macro definition declares the +%%parameters to be variable names or arbitrary sequences of tokens. +îÁÐÒÉÍÅÒ, ÅÓÔØ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ Ó ÉÍÅÎÅÍ {\tt +hide}\index{hide?\texttt{hide}} É ÔÅËÓÔÏ×ÙÍ ÐÁÒÁÍÅÔÒÏÍ\index{ÐÁÒÁÍÅÔÒ!text}, +ÉÎÔÅÒÐÒÅÔÉÒÕÅÍÙÍ ËÁË ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ËÏÍÁÎÄ, +ÐÒÏÉÚ×ÏÄÑÝÉÊ ÐÕÓÔÏÊ \tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ}. +%%For example, there is a predefined macro called {\tt +%%hide}\index{hide?\texttt{hide}} that takes a text +%%parameter\index{parameter!text} and interprets it as a sequence of +%%statements while ultimately producing an empty \tdescr{replacement +%%text}. +äÒÕÇÉÍÉ ÓÌÏ×ÁÍÉ, {\tt hide} ÉÓÐÏÌÎÑÅÔ Ó×ÏÊ ÁÒÇÕÍÅÎÔ, Á ÓÌÅÄÕÀÝÉÊ ÚÎÁË +ÐÏÓÌÅ ÎÅÇÏ ÂÅÒÅÔÓÑ ÔÁË, ËÁË ÂÕÄÔÏ ÎÉÞÅÇÏ ÎÅ ÐÒÏÉÚÏÛÌÏ. +%%In other words, {\tt hide} executes its argument and then gets +%%the next token as if nothing happened. +ôÁËÉÍ ÏÂÒÁÚÏÍ, +$$ \hbox{\tt show hide(numeric a,b; a+b=3; a-b=1) a;} $$ +ÐÅÞÁÔÁÅÔ ``\verb|>> 2|.'' +%%Thus +%%$$ \hbox{\tt show hide(numeric a,b; a+b=3; a-b=1) a;} $$ +%%prints ``\verb|>> 2|.'' + +åÓÌÉ ÂÙ {\tt hide} ÎÅ ÂÙÌ ÐÒÅÄÏÐÒÅÄÅÌÅÎ, ÔÏ ÅÇÏ ÍÏÖÎÏ ÂÙÌÏ ÏÐÒÅÄÅÌÉÔØ ÐÒÉÍÅÒÎÏ ÔÁË: +%%If the {\tt hide} macro were not predefined, it could be defined like this: +$$\begin{verbatim} +def ignore(expr a) = enddef; +def hide(text t) = ignore(begingroup t; 0 endgroup) enddef; +\end{verbatim} +$$ +ëÏÍÁÎÄÙ, ÐÒÅÄÓÔÁ×ÌÅÎÎÙÅ ÐÁÒÁÍÅÔÒÏÍ-ÔÅËÓÔÏÍ {\tt t}, ÂÕÄÕÔ ÓÞÉÔÁÔØÓÑ +ËÁË ÞÁÓÔØ ÇÒÕÐÐÙ, ÆÏÒÍÉÒÕÀÝÅÊ ÁÒÇÕÍÅÎÔ ÄÌÑ {\tt ignore}. +%%The statements represented by the text parameter {\tt t} would be +%%evaluated as part of the group that forms the argument to {\tt ignore}. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ {\tt ignore} ÉÍÅÅÔ ÐÕÓÔÏÊ \tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ}, ÒÁÓËÒÙÔÉÅ +{\tt hide} ÎÅ ÐÒÏÉÚ×ÅÄÅÔ ÓÏ×ÅÒÛÅÎÎÏ ÎÉÞÅÇÏ. +%%Since {\tt ignore} has an empty \tdescr{replacement text}, expansion of +%%the {\tt hide} macro ultimately produces nothing. + +äÒÕÇÏÊ ÐÒÉÍÅÒ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÏÇÏ ÍÁËÒÏÓÁ Ó ÔÅËÓÔÏ×ÙÍ ÐÁÒÁÍÅÔÒÏÍ --- ÜÔÏ +{\tt dashpattern}\index{dashpattern?\texttt{dashpattern}}. +%%Another example of a predefined macro with a text parameter is {\tt +%%dashpattern}\index{dashpattern?\texttt{dashpattern}}. +ïÐÒÅÄÅÌÅÎÉÅ {\tt dashpattern} ÎÁÞÉÎÁÅÔ +$$\begin{verbatim} +def dashpattern(text t) = + begingroup save on, off; +\end{verbatim} +$$ +É ÚÁÔÅÍ ÏÎÏ ÏÐÒÅÄÅÌÑÅÔ {\tt on} É {\tt off} ÍÁËÒÏÓÁÍÉ, ÓÏÚÄÁÀÝÉÍÉ +ÔÒÅÂÕÅÍÕÀ ËÁÒÔÉÎËÕ ÐÒÉ ÐÏÑ×ÌÅÎÉÉ ÔÅËÓÔÏ×ÏÇÏ ÐÁÒÁÍÅÔÒÁ {\tt t} × ÔÅËÓÔÅ ÚÁÍÅÎÙ. +%%The definition of {\tt dashpattern} starts +%%$$\begin{verbatim} +%%def dashpattern(text t) = +%% begingroup save on, off; +%%\end{verbatim} +%%$$ +%%then it defines {\tt on} and {\tt off} to be macros that create the desired +%%picture when the text parameter~{\tt t} appears in the replacement text. + +ôÅËÓÔÏ×ÙÅ ÐÁÒÁÍÅÔÒÙ ÏÞÅÎØ ÏÂÝÉÅ, ÎÏ ÉÈ ÏÂÝÎÏÓÔØ ÉÎÏÇÄÁ ÄÏÐÕÓÔÉÍÁ. +%%Text parameters are very general, but their generality sometimes gets in +%%the way. +åÓÌÉ ÖÅ ×Ù ÈÏÔÉÔÅ × ÔÏÞÎÏÓÔÉ ÐÅÒÅÄÁ×ÁÔØ ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ × ÍÁËÒÏÓ, ÔÏ ÌÕÞÛÅ +ÏÂßÑ×ÉÔØ ÅÅ ËÁË ÐÁÒÁÍÅÔÒ-ÓÕÆÆÉËÓ\index{ÐÁÒÁÍÅÔÒ!suffix}. +%%If you just want to pass a variable name to a macro, it is +%%better to declare it as a suffix parameter\index{parameter!suffix}. +îÁÐÒÉÍÅÒ, \index{incr?\texttt{incr}} +$$ \hbox{\verb|def incr(suffix $) = begingroup $:=$+1; $ endgroup enddef;|} $$ +ÏÐÒÅÄÅÌÑÅÔ ÍÁËÒÏÓ, ÞÔÏ ÂÕÄÅÔ ÐÏÌÕÞÁÔØ ÌÀÂÕÀ ÞÉÓÌÏ×ÕÀ ÐÅÒÅÍÅÎÎÕÀ, ÄÏÂÁ×ÌÑÔØ +ÏÄÉÎ Ë ÎÅÊ É ×ÏÚ×ÒÁÝÁÔØ ÎÏ×ÏÅ ÚÎÁÞÅÎÉÅ. +%%For example,\index{incr?\texttt{incr}} +%%$$ \hbox{\verb|def incr(suffix $) = begingroup $:=$+1; $ endgroup enddef;|} $$ +%%defines a macro that will take any numeric variable, add one to it, and return +%%the new value. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÉÍÅÎÁ ÐÅÒÅÍÅÎÎÙÈ ÍÏÇÕÔ ÓÏÓÔÏÑÔØ ÉÚ ÂÏÌÅÅ ÏÄÎÏÇÏ ÚÎÁËÁ, +$$ \hbox{\tt incr(a3b)} $$ +×ÐÏÌÎÅ ÄÏÐÕÓÔÉÍÏ, ÅÓÌÉ {\tt a3b} --- ÞÉÓÌÏ×ÁÑ ÐÅÒÅÍÅÎÎÁÑ. +%%Since variable names can be more than one token long, +%%$$ \hbox{\tt incr(a3b)} $$ +%%is perfectly acceptable if {\tt a3b} is a numeric variable. +ðÁÒÁÍÅÔÒÙ-ÓÕÆÆÉËÓÙ Ñ×ÌÑÀÔÓÑ ÎÅÓËÏÌØËÏ ÂÏÌÅÅ ÏÂÝÉÍÉ, ÞÅÍ ÉÍÅÎÁ ÐÅÒÅÍÅÎÎÙÈ, +ÐÏÔÏÍÕ ÞÔÏ ÏÐÒÅÄÅÌÅÎÉÑ ÎÁ ÒÉÓ.~\ref{syvar} ÄÏÐÕÓËÁÅÔ +\tdescr{ÓÕÆÆÉËÓ}\index{ÓÕÆÆÉËÓ?\tdescr{ÓÕÆÆÉËÓ}}, ÎÁÞÉÎÁÀÝÉÊÓÑ +Ó \tdescr{ÉÎÄÅËÓÁ}\index{ÉÎÄÅËÓ?\tdescr{ÉÎÄÅËÓ}}. +%%Suffix parameters are slightly more general than variable names because the +%%definition in Figure~\ref{syvar} allows a +%%\tdescr{suffix}\index{suffix?\tdescr{suffix}} to start with a +%%\tdescr{subscript}\index{subscript?\tdescr{subscript}}. + +òÉÓ.~\ref{fig45} ÐÏËÁÚÙ×ÁÅÔ ËÁË ÐÁÒÁÍÅÔÒÙ suffix É expr ÍÏÇÕÔ ÂÙÔØ +ÉÓÐÏÌØÚÏ×ÁÎÙ ×ÍÅÓÔÅ. +%%Figure~\ref{fig45} shows how suffix and expr parameters can be used +%%together. +íÁËÒÏÓ {\tt getmid}\index{getmid?\texttt{getmid}} ÂÅÒÅÔ ÐÅÒÅÍÅÎÎÕÀ-ÐÕÔØ +É ÓÏÚÄÁÅÔ ÍÁÓÓÉ×Ù ÔÏÞÅË É ÎÁÐÒÁ×ÌÅÎÉÑ, ÞØÉ ÉÍÅÎÁ ÐÏÌÕÞÁÀÔÓÑ +ÐÒÉÓÏÅÄÉÎÅÎÉÅÍ {\tt mid}, {\tt off} É {\tt dir} Ë ÐÅÒÅÍÅÎÎÏÊ-ÐÕÔÉ. +%%The {\tt getmid}\index{getmid?\texttt{getmid}} macro takes a +%%path variable and creates arrays of points and directions whose names +%%are obtained by appending {\tt mid}, {\tt off}, and {\tt dir} to the +%%path variable. +íÁËÒÏÓ {\tt joinup}\index{joinup?\texttt{joinup}} ÂÅÒÅÔ +ÍÁÓÓÉ× ÔÏÞÅË É ÎÁÐÒÁ×ÌÅÎÉÊ É ÓÏÚÄÁÅÔ ÐÕÔØ ÄÌÉÎÙ {\tt +n}, ÐÒÏÈÏÄÑÝÉÊ ÞÅÒÅÚ ËÁÖÄÕÀ {\tt pt[i]} Ó ÎÁÐÒÁ×ÌÅÎÉÅÍ {\tt d[i]} ÉÌÉ +$-\hbox{\tt d[i]}$. +%%The {\tt joinup}\index{joinup?\texttt{joinup}} macro +%%takes arrays of points and directions and creates a path of length {\tt +%%n} that passes through each {\tt pt[i]} with direction {\tt d[i]} or +%%$-\hbox{\tt d[i]}$. + +\begin{figure}[htp] +$$\begin{verbatim} +def getmid(suffix p) = + pair p.mid[], p.off[], p.dir[]; + for i=0 upto 36: + p.dir[i] = dir(5*i); + p.mid[i]+p.off[i] = directionpoint p.dir[i] of p; + p.mid[i]-p.off[i] = directionpoint -p.dir[i] of p; + endfor +enddef; + +def joinup(suffix pt, d)(expr n) = + begingroup + save res, g; path res; + res = pt[0]{d[0]}; + for i=1 upto n: + g:= if (pt[i]-pt[i-1]) dotprod d[i] <0: - fi 1; + res := res{g*d[i-1]}...{g*d[i]}pt[i]; + endfor + res + endgroup +enddef; + +beginfig(45) +path p, q; +p = ((5,2)...(3,4)...(1,3)...(-2,-3)...(0,-5)...(3,-4) + ...(5,-3)...cycle) scaled .3cm shifted (0,5cm); +getmid(p); +draw p; +draw joinup(p.mid, p.dir, 36)..cycle; +q = joinup(p.off, p.dir, 36); +draw q..(q rotated 180)..cycle; +drawoptions(dashed evenly); +for i=0 upto 3: + draw p.mid[9i]-p.off[9i]..p.mid[9i]+p.off[9i]; + draw -p.off[9i]..p.off[9i]; +endfor +endfig; +\end{verbatim} +\quad \mathcenter{\includegraphics{manfig-ru-45}} +$$ +\caption{ëÏÄ MetaPost É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ÒÉÓÕÎÏË} +%%\caption{MetaPost code and the corresponding figure} +\label{fig45} +\end{figure} + +îÁÞÉÎÁÀÝÅÅÓÑ Ó +$$ \hbox{\tt def joinup(suffix pt, d)(expr n) =} $$ +ÏÐÒÅÄÅÌÅÎÉÅ ÍÏÖÅÔ ×ÏÓÐÒÉÎÉÍÁÔØÓÑ ÔÁË, ÞÔÏ ×ÙÚÏ× ÍÁËÒÏÓÁ {\tt joinup} ÍÏÖÅÔ +ÉÍÅÔØ Ä×Á ÎÁÂÏÒÁ ÓËÏÂÏË ËÁË × +$$ \hbox{\tt joinup(p.mid, p.dir)(36)} $$ +×ÍÅÓÔÏ +$$ \hbox{\tt joinup(p.mid, p.dir, 36)} $$ +%%A definition that starts +%%$$ \hbox{\tt def joinup(suffix pt, d)(expr n) =} $$ +%%might suggest that calls to the {\tt joinup} macro should have two sets of +%%parentheses as in +%%$$ \hbox{\tt joinup(p.mid, p.dir)(36)} $$ +%%instead of +%%$$ \hbox{\tt joinup(p.mid, p.dir, 36)} $$ +ïÂÅ ÆÏÒÍÙ Ñ×ÌÑÀÔÓÑ ÄÏÐÕÓÔÉÍÙÍÉ. +%%In fact, both forms are acceptable. +ðÁÒÁÍÅÔÒÙ × ×ÙÚÏ×Å ÍÁËÒÏÓÁ ÍÏÇÕÔ ÒÁÚÄÅÌÑÔØÓÑ ÚÁÐÑÔÙÍÉ ÉÌÉ ÐÁÒÁÍÉ {\tt )(}. +%%Parameters in a macro call can be +%%separated by commas or by {\tt )(} pairs. +åÓÔØ ÔÏÌØËÏ ÏÄÎÏ ÏÇÒÁÎÉÞÅÎÉÅ --- ÚÁ ÔÅËÓÔÏ×ÙÍ ÐÁÒÁÍÅÔÒÏÍ\index{ÐÁÒÁÍÅÔÒ!text} +ÄÏÌÖÎÁ ÉÄÔÉ ÐÒÁ×ÁÑ ÓËÏÂËÁ. +%%The only restriction is that +%%a text parameter\index{parameter!text} must be followed by a right +%%parenthesis. +îÁÐÒÉÍÅÒ, ÍÁËÒÏÓ {\tt foo} Ó ÏÄÎÉÍ ÐÁÒÁÍÅÔÒÏÍ text É ÄÒÕÇÉÍ expr ÍÏÖÅÔ +ÂÙÔØ ×ÙÚ×ÁÎ +$$ \hbox{\tt foo(a,b)(c),} $$ +× ÜÔÏÍ ÓÌÕÞÁÅ ÔÅËÓÔÏ×ÙÊ ÐÁÒÁÍÅÔÒ --- ÜÔÏ ``{\tt a,b}'', Á ÐÁÒÁÍÅÔÒ-×ÙÒÁÖÅÎÉÅ +--- {\tt c}, ÎÏ +$$ \hbox{\tt foo(a,b,c)} $$ +ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ ÐÁÒÁÍÅÔÒ-ÔÅËÓÔ × ``{\tt a,b,c}'' É ÏÓÔÁ×ÌÑÅÔ ÉÎÔÅÒÐÒÅÔÁÔÏÒ +MetaPost ÐÒÏÄÏÌÖÁÔØ ÉÓËÁÔØ ÐÁÒÁÍÅÔÒ-×ÙÒÁÖÅÎÉÅ. +%%For instance, a macro {\tt foo} with one text parameter +%%and one expr parameter can be called +%%$$ \hbox{\tt foo(a,b)(c)} $$ +%%in which case the text parameter is ``{\tt a,b}'' and the expr parameter is +%{\tt c}, but +%%$$ \hbox{\tt foo(a,b,c)} $$ +%%sets the text parameter to ``{\tt a,b,c}'' and leaves the MetaPost interpreter +%%still looking for the expr parameter. + +\subsection{íÁËÒÏÓÙ vardef} +%%\subsection{Vardef Macros} + +ïÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ ÍÏÖÅÔ ÎÁÞÉÎÁÔØÓÑ Ó {\tt +vardef}\index{vardef?\texttt{vardef}} ×ÍÅÓÔÏ {\tt def}. +%%A macro definition can begin with {\tt +%%vardef}\index{vardef?\texttt{vardef}} instead of {\tt def}. +íÁËÒÏÓ, ÏÐÒÅÄÅÌÅÎÎÙÊ ÔÁËÉÍ ÏÂÒÁÚÏÍ, ÎÁÚÙ×ÁÅÔÓÑ vardef-ÍÁËÒÏÓÏÍ. +%%Macros defined in this way are called vardef macros. +ïÎÉ ÏÓÏÂÅÎÎÏ ÈÏÒÏÛÏ ÐÏÄÈÏÄÑÔ Ë ÐÒÉÌÏÖÅÎÉÑÍ, ÇÄÅ ÍÁËÒÏÓÙ ÉÓÐÏÌØÚÕÀÔÓÑ +ËÁË ÆÕÎËÃÉÉ ÉÌÉ ÐÒÏÃÅÄÕÒÙ. +%%They are particularly +%%well-suited to applications where macros are being used like functions +%%or subroutines. +çÌÁ×ÎÁÑ ÉÄÅÑ × ÔÏÍ, ÞÔÏ vardef-ÍÁËÒÏÓ ÐÏÄÏÂÅÎ ÐÅÒÅÍÅÎÎÏÊ ÔÉÐÁ ``ÍÁËÒÏÓ''. +%%The main idea is that a vardef macro is like a variable +%%of type ``macro.'' + +÷ÍÅÓÔÏ {\tt def} \tdescr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} vardef-ÍÁËÒÏÓ ÎÁÞÉÎÁÅÔ +$$ {\tt vardef}\, \descr{ÏÂÏÂÝÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ}, $$ +ÇÄÅ \tdescr{ÏÂÏÂÝÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ}\index{ÏÂÏÂÝÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ?\tdescr{ÏÂÏÂÝÅÎÎÁÑ +ÐÅÒÅÍÅÎÎÁÑ}} -- ÜÔÏ ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ Ó ÞÉÓÌÏ×ÙÍÉ ÉÎÄÅËÓÁÍÉ, ÚÁÍÅÎÅÎÎÙÍÉ +ÎÁ ÓÉÍ×ÏÌ ÏÂÏÂÝÅÎÎÏÇÏ ÉÎÄÅËÓÁ\index{ÉÎÄÅËÓ!ÏÂÏÂÝÅÎÎÙÊ} --- {\tt +[]}\index{[]?\texttt{[]}!vardef macro?\texttt{vardef}-ÍÁËÒÏÓ}. +%%Instead of {\tt def} \tdescr{symbolic token}, a vardef macro begins +%%$$ {\tt vardef}\, \descr{generic variable} $$ +%%where a \tdescr{generic variable}\index{generic variable?\tdescr{generic +%%variable}} is a variable name with numeric subscripts replaced by the +%%generic subscript\index{subscript!generic} symbol {\tt +%%[]}\index{[]?\texttt{[]}!vardef macro?\texttt{vardef} macro}. +äÒÕÇÉÍÉ ÓÌÏ×ÁÍÉ, ÉÍÑ ÐÏÓÌÅ {\tt vardef} ÏÂÑÚÁÎÏ ÉÍÅÔØ × ÔÏÞÎÏÓÔÉ +ÔÁËÏÊ ÖÅ ÓÉÎÔÁËÓÉÓ ËÁË É ÉÍÑ × ÄÅËÌÁÒÁÃÉÉ ÐÅÒÅÍÅÎÎÏÊ. +%%In other words, the name following {\tt +%%vardef} obeys exactly the same syntax as the name given in a variable +%%declaration. +ïÎÏ --- ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÜÔÉËÅÔÏË É ÓÉÍ×ÏÌÏ× ÏÂÏÂÝÅÎÎÏÇÏ ÉÎÄÅËÓÁ, +ÎÁÞÉÎÁÀÝÁÑÓÑ Ó ÜÔÉËÅÔËÉ, ÇÄÅ ÜÔÉËÅÔËÁ\index{ÜÔÉËÅÔËÉ} --- ÜÔÏ ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË, +ÎÅ Ñ×ÌÑÀÝÉÊÓÑ ÍÁËÒÏÓÏÍ ÉÌÉ ÐÒÉÍÉÔÉ×ÎÙÍ ÏÐÅÒÁÔÏÒÏÍ, ËÁË ÏÂßÑÓÎÑÌÏÓØ × +ÒÁÚÄÅÌÅ~\ref{vardecl}. +%%It is a sequence of tags and generic subscript symbols +%%starting with a tag, where a tag\index{tags} is a symbolic token that is +%%not a macro or a primitive operator as explained in +%%Section~\ref{vardecl}. + +÷ ÐÒÏÓÔÅÊÛÅÍ ÓÌÕÞÁÅ ÉÍÑ vardef-ÍÁËÒÏÓÁ ÓÏÓÔÏÉÔ ÉÚ ÏÄÎÏÊ ÜÔÉËÅÔËÉ. +%%The simplest case is when the name of a vardef macro consists of a +%%single tag. +÷ ÔÁËÉÈ ÏÂÓÔÏÑÔÅÌØÓÔ×ÁÈ {\tt def} É {\tt vardef} ÏÂÅÓÐÅÞÉ×ÁÀÔ ÐÏÞÔÉ +ÏÄÉÎÁËÏ×ÕÀ ÆÕÎËÃÉÏÎÁÌØÎÏÓÔØ. +%%Under such circumstances, {\tt def} and {\tt vardef} +%%provide roughly the same functionality. +îÁÉÂÏÌÅÅ ÏÞÅ×ÉÄÎÁÑ ÒÁÚÎÉÃÁ × ÔÏÍ, ÞÔÏ {\tt begingroup}\index{begingroup?\texttt{begingroup}} É {\tt +endgroup}\index{endgroup?\texttt{endgroup}} Á×ÔÏÍÁÔÉÞÅÓËÉ ×ÓÔÁ×ÌÑÀÔÓÑ +ÓÏÏÔ×ÅÔÓÔ×ÅÎÎÏ × ÎÁÞÁÌÏ É ËÏÎÅà \tdescr{ÔÅËÓÔÁ ÚÁÍÅÎÙ} ËÁÖÄÏÇÏ +vardef-ÍÁËÒÏÓÁ. +%%The most obvious difference is +%%that {\tt begingroup}\index{begingroup?\texttt{begingroup}} and {\tt +%%endgroup}\index{endgroup?\texttt{endgroup}} are automatically inserted +%%at the beginning and end of the \tdescr{replacement text} of every +%%vardef macro. +üÔÏ ÄÅÌÁÅÔ \tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ} ÇÒÕÐÐÏÊ É ÐÏÜÔÏÍÕ vardef-ÍÁËÒÏÓ +×ÅÄÅÔ ÓÅÂÑ ÐÏÄÏÂÎÏ ÐÒÏÃÅÄÕÒÅ ÉÌÉ ÆÕÎËÃÉÉ. +%%This makes the \tdescr{replacement text} a group so that +%%a vardef macro behaves like a subroutine or a function call. + +äÒÕÇÏÅ Ó×ÏÊÓÔ×Ï vardef-ÍÁËÒÏÓÏ× ÚÁËÌÀÞÁÅÔÓÑ × ÒÁÚÒÅÛÅÎÉÉ ÉÍÅÎ ÉÚ ÍÎÏÇÉÈ +ÜÔÉËÅÔÏË É ÉÍÅÎ, ÓÏÄÅÒÖÁÝÉÈ ÏÂÏÂÝÅÎÎÙÅ ÉÎÄÅËÓÙ. +%%Another property of vardef macros is that they allow multi-token macro +%%names and macro names involving generic subscripts. +ëÏÇÄÁ ÉÍÑ vardef-ÍÁËÒÏÓÁ ÉÍÅÅÔ ÏÂÏÂÝÅÎÎÙÅ ÉÎÄÅËÓÙ, ÔÏ ÞÉÓÌÏ×ÙÅ ÚÎÁÞÅÎÉÑ +ÄÌÑ ÎÉÈ ÄÏÌÖÎÙ ÂÙÔØ ÚÁÄÁÎÙ ÐÒÉ ×ÙÚÏ×Å ÜÔÏÇÏ ÍÁËÒÏÓÁ. +%%When a vardef macro +%%name has generic subscripts, numeric values have to be given when the +%%macro is called. +ðÏÓÌÅ ÏÐÒÅÄÅÌÅÎÉÑ ÍÁËÒÏÓÁ +$$ \hbox{\tt vardef a[]b(expr p) =}\, \descr{ÔÅËÓÔ ÚÁÍÅÎÙ}\, + \hbox{\tt enddef;} +$$ +{\tt a2b((1,2))} É {\tt a3b((1,2)..(3,4))} --- ÜÔÏ ×ÙÚÏ×Ù ÍÁËÒÏÓÁ. +%%After a macro definition +%%$$ \hbox{\tt vardef a[]b(expr p) =}\, \descr{replacement text}\, +%% \hbox{\tt enddef;} +%%$$ +%%{\tt a2b((1,2))} and {\tt a3b((1,2)..(3,4))} are macro calls. +îÏ ËÁË ÍÏÖÅÔ \tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ} ÓËÁÚÁÔØ Ï ÒÁÚÎÉÃÅ ÍÅÖÄÕ {\tt a2b} +É {\tt a3b}? +%%But how +%%can the \tdescr{replacement text} tell the difference between {\tt a2b} +%%and {\tt a3b}? +ä×Á ÎÅÑ×ÎÙÈ ÐÁÒÁÍÅÔÒÁ-ÓÕÆÆÉËÓÁ\index{ÐÁÒÁÍÅÔÒ!suffix} +Á×ÔÏÍÁÔÉÞÅÓËÉ ÐÒÅÄÏÓÔÁ×ÌÑÀÔÓÑ ÄÌÑ ÜÔÏÊ ÃÅÌÉ. +%%Two implicit suffix parameters\index{parameter!suffix} +%%are automatically provided for this purpose. +ëÁÖÄÙÊ vardef-ÍÁËÒÏÓ ÉÍÅÅÔ ÐÁÒÁÍÅÔÒÙ-ÓÕÆÆÉËÓÙ +\verb|#@|\index{#@?\texttt{\#@}} É +\verb|@|\index{@?\texttt{@}}, ÇÄÅ \verb|@| --- ÜÔÏ ÐÏÓÌÅÄÎÉÊ ÚÎÁË × ÉÍÅÎÉ +×ÙÚÏ×Á ÍÁËÒÏÓÁ, Á \verb|#@| --- ÜÔÏ ×ÓÅ ÐÒÅÄÛÅÓÔ×ÕÀÝÅÅ ÐÏÓÌÅÄÎÅÍÕ ÚÎÁËÕ. +%%Every vardef macro has +%%suffix parameters \verb|#@|\index{#@?\texttt{\#@}} and +%%\verb|@|\index{@?\texttt{@}}, where \verb|@| is the last token in the +%%name from the macro call and \verb|#@| is everything preceding the last +%%token. +ðÏÜÔÏÍÕ \verb|#@| ÒÁ×ÎÏ {\tt a2}, ËÏÇÄÁ ÄÁÎÎÏÅ ÉÍÑ --- {\tt a2b}, É +{\tt a3}, ËÏÇÄÁ ÄÁÎÎÏÅ ÉÍÑ --- {\tt a3b}. +%%Thus \verb|#@| is {\tt a2} when the name is given as {\tt a2b} +%%and {\tt a3} when the name is given as {\tt a3b}. + +ðÒÅÄÐÏÌÏÖÉÍ, ÎÁÐÒÉÍÅÒ, ÞÔÏ ÍÁËÒÏÓ {\tt a[]b} ÓÄ×ÉÇÁÅÔ Ó×ÏÊ ÁÒÇÕÍÅÎÔ ÎÁ +×ÅÌÉÞÉÎÕ, ÚÁ×ÉÓÑÝÕÀ ÏÔ ÉÍÅÎÉ ×ÙÚÏ×Á ÜÔÏÇÏ ÍÁËÒÏÓÁ. +%%Suppose, for example, that the {\tt a[]b} macro is to take its argument +%%and shift it by an amount that depends on the macro name. +ôÁËÏÊ ÍÁËÒÏÓ ÍÏÖÎÏ ÏÐÒÅÄÅÌÉÔØ ÐÒÉÍÅÒÎÏ ÔÁË: +$$ \hbox{\verb|vardef a[]b(expr p) = p shifted (#@,b) enddef;|} $$ +%%The macro could be defined like this: +%%$$ \hbox{\verb|vardef a[]b(expr p) = p shifted (#@,b) enddef;|} $$ +ôÏÇÄÁ {\tt a2b((1,2))} ÏÚÎÁÞÁÅÔ {\tt (1,2) shifted (a2,b)} +É {\tt a3b((1,2)..(3,4))} ÏÚÎÁÞÁÅÔ +$$ \hbox{\tt ((1,2)..(3,4)) shifted (a3,b)}. $$ +%%Then {\tt a2b((1,2))} means {\tt (1,2) shifted (a2,b)} +%%and {\tt a3b((1,2)..(3,4))} means +%%$$ \hbox{\tt ((1,2)..(3,4)) shifted (a3,b)}. $$ + +åÓÌÉ ÍÁËÒÏÓ ÂÙÌ {\tt a.b[]}, ÔÏ \verb|#@| ×ÓÅÇÄÁ ÂÕÄÅÔ {\tt a.b}, +Á ÐÁÒÁÍÅÔÒ \verb|@| ÂÕÄÅÔ ÄÁ×ÁÔØ ÞÉÓÌÏ×ÏÊ ÉÎÄÅËÓ. +%%If the macro had been {\tt a.b[]}, \verb|#@| would always be {\tt a.b} +%%and the \verb|@| parameter would give the numeric subscript. +ôÁËÉÍ ÏÂÒÁÚÏÍ, {\tt a@} ÂÕÄÅÔ ÓÓÙÌÁÔØÓÑ ÎÁ ÜÌÅÍÅÎÔ ÍÁÓÓÉ×Á {\tt a[]}. +%%Then {\tt a@} would refer to an element of the array {\tt a[]}. +úÁÍÅÔØÔÅ, ÞÔÏ \verb|@| --- ÜÔÏ ÐÁÒÁÍÅÔÒ-ÓÕÆÆÉËÓ, Á ÎÅ ÐÁÒÁÍÅÔÒ-×ÙÒÁÖÅÎÉÅ, +ÐÏÜÔÏÍÕ ×ÙÒÁÖÅÎÉÅ, ÐÏÄÏÂÎÏÅ {\tt @+1}, ÏÛÉÂÏÞÎÏ. +%%Note that +%%\verb|@| is a suffix parameter, not an expr parameter, so an expression +%%like {\tt @+1} would be illegal. +åÄÉÎÓÔ×ÅÎÎÙÊ ÓÐÏÓÏ ÐÏÌÕÞÉÔØ ÞÉÓÌÏ×ÙÅ ÚÎÁÞÅÎÉÑ ÉÎÄÅËÓÏ× +ÐÁÒÁÍÅÔÒÁ-ÓÕÆÆÉËÓÁ\index{ÐÁÒÁÍÅÔÒ!suffix} +× ÉÚ×ÌÅÞÅÎÉÉ ÉÈ ÉÚ ÓÔÒÏËÉ, ×ÏÚ×ÒÁÝÁÅÍÏÊ ÏÐÅÒÁÔÏÒÏÍ {\tt +str}\index{str?\texttt{str}}\label{Dstr}. +%%The only way to get at the numeric +%%values of subscripts in a suffix parameter\index{parameter!suffix} is by +%%extracting them from the string returned by the {\tt +%%str}\index{str?\texttt{str}}\label{Dstr} operator. +üÔÏÔ ÏÐÅÒÁÔÏÒ ÐÏ ÓÕÆÆÉËÓÕ ×ÏÚ×ÒÁÝÁÅÔ ÅÇÏ ÓÔÒÏËÏ×ÏÅ ÐÒÅÄÓÔÁ×ÌÅÎÉÅ. +%%This operator takes +%%a suffix and returns a string representation of a suffix. +ðÏÜÔÏÍÕ {\tt str @} ÂÕÄÅÔ \verb|"3"| ÄÌÑ {\tt a.b3} É \verb|"3.14"| ÄÌÑ {\tt a.b3.14} ÉÌÉ {\tt a.b[3.14]}. +%%Thus {\tt str +%%@} would be \verb|"3"| in {\tt a.b3} and \verb|"3.14"| in {\tt a.b3.14} +%%or {\tt a.b[3.14]}. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÓÉÎÔÁËÓÉÓ ÄÌÑ \tdescr{ÓÕÆÆÉËÓÁ}\index{ÓÕÆÆÉËÓ?\tdescr{ÓÕÆÆÉËÓ}} +ÎÁ ÒÉÓ.~\ref{syvar} ÔÒÅÂÕÅÔ ÚÁËÌÀÞÁÔØ ÏÔÒÉÃÁÔÅÌØÎÙÅ ÉÎÄÅËÓÙ × Ë×ÁÄÒÁÔÎÙÅ +ÓËÏÂËÉ, {\tt str @} ×ÏÚ×ÒÁÝÁÅÔ {\tt \qq{[-3]}\qq} ÄÌÑ {\tt a.b[-3]}. +%%Since the syntax for a +%%\tdescr{suffix}\index{suffix?\tdescr{suffix}} in Figure~\ref{syvar} +%%requires negative subscripts to be in brackets, {\tt str @} returns {\tt +%%\qq{[-3]}\qq} in {\tt a.b[-3]}. + +ïÐÅÒÁÔÏÒ {\tt str}, ËÁË ÐÒÁ×ÉÌÏ, ÉÓÐÏÌØÚÕÅÔÓÑ ÔÏÌØËÏ ÐÒÉ ËÒÁÊÎÅÊ +ÎÅÏÂÈÏÄÉÍÏÓÔÉ. +%%The {\tt str} operator is generally for emergency use only. +ìÕÞÛÅ ÉÓÐÏÌØÚÏ×ÁÔØ ÐÁÒÁÍÅÔÒÙ-ÓÕÆÆÉËÓÙ ÔÏÌØËÏ ËÁË ÉÍÅÎÁ ÐÅÒÅÍÅÎÎÙÈ ÉÌÉ +ÓÕÆÆÉËÓÙ. +%%It is +%%better to use suffix parameters only as variable names or suffixes. +îÁÉÌÕÞÛÉÊ ÐÒÉÍÅÒ vardef-ÍÁËÒÏÓÁ, ÉÓÐÏÌØÚÕÀÝÅÇÏ ÓÕÆÆÉËÓÙ, --- ÜÔÏ ÍÁËÒÏÓ, +ÏÐÒÅÄÅÌÑÀÝÉÊ ÓÏÇÌÁÛÅÎÉÅ ÐÏ +{\tt z}\index{z convention?{\tt z}-ÓÏÇÌÁÛÅÎÉÅ}. +%%The +%%best example of a vardef macro involving suffixes is the {\tt z} macro +%%that defines the {\tt z} convention\index{z convention?{\tt z} +%%convention}. +ïÐÒÅÄÅÌÅÎÉÅ ÉÓÐÏÌØÚÕÅÔ ÓÐÅÃÉÁÌØÎÙÊ ÚÎÁË +\verb|@#|\index{@#?\texttt{@\#}}, ËÏÔÏÒÙÊ ÓÓÙÌÁÅÔÓÑ ÎÁ ÓÕÆÆÉËÓ ÐÏÓÌÅ ÉÍÅÎÉ +ÍÁËÒÏÓÁ: +$$ \hbox{\verb|vardef z@#=(x@#,y@#) enddef;|} $$ +%%The definition involves a special token +%%\verb|@#|\index{@#?\texttt{@\#}} that refers to the suffix following the +%%macro name: +%%$$ \hbox{\verb|vardef z@#=(x@#,y@#) enddef;|} $$ +ïÎÏ ÏÚÎÁÞÁÅÔ, ÞÔÏ ÌÀÂÏÅ ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ, ÞÅÊ ÐÅÒ×ÙÊ ÚÎÁË {\tt z}, +ÜË×É×ÁÌÅÎÔÎÏ ÐÁÒÅ ÐÅÒÅÍÅÎÎÙÈ, ÞØÉ ÉÍÅÎÁ ÐÏÌÕÞÁÀÔÓÑ ÚÁÍÅÎÏÊ {\tt z} ÎÁ +{\tt x} É~{\tt y}. +%%This means that any variable name whose first token is {\tt z} is +%%equivalent to a pair of variables whose names are obtained by replacing +%%{\tt z} with {\tt x} and~{\tt y}. +îÁÐÒÉÍÅÒ, {\tt z.a1} ×ÙÚÙ×ÁÅÔ ÍÁËÒÏÓ {\tt z} Ó ÐÁÒÁÍÅÔÒÏÍ-ÓÕÆÆÉËÓÏÍ +\verb|@#|, ÕÓÔÁÎÏ×ÌÅÎÎÙÍ × {\tt a1}. +%%For instance, {\tt z.a1} calls the +%%{\tt z} macro with the suffix parameter \verb|@#| set to {\tt a1}. + +÷ ÏÂÝÅÍ, +$$ {\tt vardef}\, \descr{ÏÂÏÂÝÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ} \hbox{\verb|@#|} $$ +Ñ×ÌÑÅÔÓÑ ÁÌØÔÅÒÎÁÔÉ×ÏÊ {\tt vardef} \tdescr{ÏÂÏÂÝÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ}, +ÐÒÉ×ÏÄÑÝÅÊ ÉÎÔÅÒÐÒÅÔÁÔÏÒ MetaPost Ë ×ÙÄÅÌÅÎÉÀ ÓÕÆÆÉËÓÁ, ÓÌÅÄÕÀÝÅÇÏ ÚÁ +ÉÍÅÎÅÍ, ÚÁÄÁÎÎÙÍ × ×ÙÚÏ×Å ÍÁËÒÏÓÁ, É ÄÅÌÁÀÝÅÊ ÅÇÏ ÄÏÓÔÕÐÎÙÍ ËÁË +ÐÁÒÁÍÅÔÒ-ÓÕÆÆÉËÓ \verb|@#|. +%%In general, +%%$$ {\tt vardef}\, \descr{generic variable} \hbox{\verb|@#|} $$ +%%is an alternative to {\tt vardef} \tdescr{generic variable} that causes the +%%MetaPost interpreter +%%to look for a suffix following the name given in the macro call and makes this +%%available as the \verb|@#| suffix parameter. + +óÕÍÍÉÒÕÅÍ ÏÓÏÂÙÅ Ó×ÏÊÓÔ×Á vardef-ÍÁËÒÏÓÏ×: ÏÎÉ ÄÏÐÕÓËÁÀÔ ËÁË ÛÉÒÏËÉÊ ËÌÁÓÓ +ÉÍÅÎ ÄÌÑ ÍÁËÒÏÓÏ×, ÔÁË É ÉÍÅÎÁ ÍÁËÒÏÓÏ×, ÚÁ ËÏÔÏÒÙÍÉ ÓÌÅÄÕÅÔ ÓÐÅÃÉÁÌØÎÙÊ +ÐÁÒÁÍÅÔÒ-ÓÕÆÆÉËÓ. +%%To summarize the special features of vardef macros, they allow a broad +%%class of macro names as well as macro names followed by a special suffix +%%parameter. +âÏÌÅÅ ÔÏÇÏ, {\tt begingroup} É {\tt endgroup} Á×ÔÏÍÁÔÉÞÅÓËÉ +ÄÏÂÁ×ÌÑÀÔÓÑ Ë \tdescr{ÔÅËÓÔÕ ÚÁÍÅÎÙ} vardef-ÍÁËÒÏÓÁ. +%%Furthermore, {\tt begingroup} and {\tt endgroup} are +%%automatically added to the \tdescr{replacement text} of a vardef macro. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÉÓÐÏÌØÚÏ×ÁÎÉÅ {\tt vardef} ×ÍÅÓÔÏ {\tt def} ÄÌÑ +ÏÐÒÅÄÅÌÅÎÉÑ ÍÁËÒÏÓÁ {\tt joinup}\index{joinup?\texttt{joinup}} ÎÁ +ÒÉÓ.~\ref{fig45} ÐÏÚ×ÏÌÉÔ ÉÚÂÅÖÁÔØ ÎÕÖÄÙ Ñ×ÎÏ ×ËÌÀÞÁÔØ {\tt begingroup} +É {\tt endgroup} × ÏÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ. +%%Thus using {\tt vardef} instead of {\tt def} to define the {\tt +%%joinup}\index{joinup?\texttt{joinup}} macro in Figure~\ref{fig45} would +%%have avoided the need to include {\tt begingroup} and {\tt endgroup} +%%explicitly in the macro definition. + +æÁËÔÉÞÅÓËÉ, ÂÏÌØÛÉÎÓÔ×Ï ÏÐÒÅÄÅÌÅÎÉÊ ÍÁËÒÏÓÏ× × ÐÒÅÄÙÄÕÝÉÈ ÐÒÉÍÅÒÁÈ ÍÏÇÕÔ +ÉÓÐÏÌØÚÏ×ÁÔØ {\tt vardef} ×ÍÅÓÔÏ {\tt def}. +%%In fact, most of the macro definitions given in previous examples could +%%equally well use {\tt vardef} instead of {\tt def}. +ïÂÙÞÎÏ ÎÅ ÉÍÅÅÔ ÂÏÌØÛÏÇÏ ÚÎÁÞÅÎÉÑ, ËÏÔÏÒÙÊ ÉÚ ÎÉÈ ÉÓÐÏÌØÚÏ×ÁÔØ, ÎÏ ÅÓÔØ +ÈÏÒÏÛÅÅ ÏÂÝÅÅ ÐÒÁ×ÉÌÏ: ÉÓÐÏÌØÚÕÊÔÅ {\tt vardef}, ÅÓÌÉ ×Ù ÓÏÂÉÒÁÅÔÅÓØ +ÉÓÐÏÌØÚÏ×ÁÔØ ÍÁËÒÏÓ ËÁË ÆÕÎËÃÉÀ ÉÌÉ ÐÒÏÃÅÄÕÒÕ. +%%It usually does not +%%matter very much which you use, but a good general rule is to use {\tt +%%vardef} if you intend the macro to be used like a function or a +%%subroutine. +óÌÅÄÕÀÝÅÅ ÓÒÁ×ÎÅÎÉÅ ÄÏÌÖÎÏ ÐÏÍÏÞØ ÐÒÉ ÒÅÛÅÎÉÉ, ËÏÇÄÁ ÉÓÐÏÌØÚÏ×ÁÔØ +{\tt vardef}. +%%The following comparison should help in deciding when to +%%use {\tt vardef}. + +\begin{itemize} +\item Vardef-ÍÁËÒÏÓ Á×ÔÏÍÁÔÉÞÅÓËÉ ÏËÒÕÖÅÎ {\tt begingroup} É +{\tt endgroup}. +%%\item Vardef macros are automatically surrounded by {\tt begingroup} +%%and {\tt endgroup}. +\item éÍÑ vardef-ÍÁËÒÏÓÁ ÍÏÖÅÔ ÂÙÔØ ÂÏÌÅÅ ÏÄÎÏÇÏ ÚÎÁËÁ ÄÌÉÎÏÊ É ÏÎÏ +ÍÏÖÅÔ ÓÏÄÅÒÖÁÔØ ÉÎÄÅËÓÙ. +%%\item The name of a vardef macro can be more than one token long and it can +%%contain subscripts. +\item Vardef-ÍÁËÒÏÓ ÍÏÖÅÔ ÉÍÅÔØ ÄÏÓÔÕÐ Ë ÓÕÆÆÉËÓÕ, ÓÌÅÄÕÀÝÅÍÕ ÚÁ ÉÍÅÎÅÍ +ÍÁËÒÏÓÁ ÐÒÉ ÅÇÏ ×ÙÚÏ×Å. +%%\item A vardef macro can have access to the suffix that follows the macro name +%%when the macro is called. +\item ëÏÇÄÁ ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË ÉÓÐÏÌØÚÕÅÔÓÑ × ÉÍÅÎÉ vardef-ÍÁËÒÏÓÁ, ÏÎ +ÏÓÔÁÅÔÓÑ ÜÔÉËÅÔËÏÊ\index{ÜÔÉËÅÔËÉ} É ÍÏÖÅÔ ÐÏ-ÐÒÅÖÎÅÍÕ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ × ÉÍÅÎÁÈ +ÄÒÕÇÉÈ ÐÅÒÅÍÅÎÎÙÈ. +%%\item When a symbolic token is used in the name of a vardef macro it remains +%%a tag\index{tags} and can still be used in other variable names. +ðÏÜÔÏÍÕ {\tt p5dir} --- ÜÔÏ ÐÒÁ×ÉÌØÎÏÅ ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ, ÎÅÓÍÏÔÒÑ ÎÁ ÔÏ, ÞÔÏ +{\tt dir} --- ÜÔÏ vardef-ÍÁËÒÏÓ, ÎÏ ÏÂÙÞÎÙÊ ÍÁËÒÏÓ, ÔÁËÏÊ ËÁË {\tt ...}\index{...?\texttt{...}}, ÎÅ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎ × ÉÍÅÎÉ ÐÅÒÅÍÅÎÎÏÊ. +%%Thus +%%{\tt p5dir} is a legal variable name even though {\tt dir} is a vardef +%%macro, but an ordinary macro such as {\tt ...}\index{...?\texttt{...}} +%%cannot be used in a variable name. +üÔÏ Ë ÌÕÞÛÅÍÕ, ÐÏÔÏÍÕ ËÁË {\tt z5...z6} ÅÓÔÅÓÔ×ÅÎÎÏ ÓÞÉÔÁÔØ ×ÙÒÁÖÅÎÉÅÍ-ÐÕÔÅÍ, +Á ÎÅ ÓÏÓÔÁ×ÎÙÍ ÉÍÅÎÅÍ ÐÅÒÅÍÅÎÎÏÊ. +%%(This is fortunate since {\tt +%%z5...z6} is supposed to be a path expression, not an elaborate variable +%%name). +\end{itemize} + +\subsection{ïÐÒÅÄÅÌÅÎÉÅ ÕÎÁÒÎÙÈ É ÂÉÎÁÒÎÙÈ ÍÁËÒÏÓÏ×} +%%\subsection{Defining Unary and Binary Macros} + +õÖÅ ÎÅ ÒÁÚ ÕÐÏÍÉÎÁÌÏÓØ, ÞÔÏ ÎÅËÏÔÏÒÙÅ ÏÂÓÕÖÄÁÅÍÙÅ ÄÏ ÓÉÈ ÐÏÒ ÏÐÅÒÁÔÏÒÙ +É ËÏÍÁÎÄÙ ÎÁ ÓÁÍÏÍ ÄÅÌÅ Ñ×ÌÑÀÔÓÑ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÍÉ ÍÁËÒÏÓÁÍÉ. +%%It has been mentioned several times that some of the operators and +%%commands discussed so far are actually predefined macros. +üÔÏ ËÁÓÁÅÔÓÑ ÕÎÁÒÎÙÈ ÏÐÅÒÁÔÏÒÏ× {\tt round}\index{round?\texttt{round}} É {\tt +unitvector}\index{unitvector?\texttt{unitvector}}, ËÏÍÁÎÄ +{\tt fill}\index{fill?\texttt{fill}} É {\tt +draw}\index{draw?\texttt{draw}}, ÂÉÎÁÒÎÙÈ ÏÐÅÒÁÔÏÒÏ× {\tt +dotprod}\index{dotprod?\texttt{dotprod}} É {\tt +intersectionpoint}\index{intersectionpoint?\texttt{intersectionpoint}}. +%%These include +%%unary operators such as {\tt round}\index{round?\texttt{round}} and {\tt +%%unitvector}\index{unitvector?\texttt{unitvector}}, statements such as +%%{\tt fill}\index{fill?\texttt{fill}} and {\tt +%%draw}\index{draw?\texttt{draw}}, and binary operators such as {\tt +%%dotprod}\index{dotprod?\texttt{dotprod}} and {\tt +%%intersectionpoint}\index{intersectionpoint?\texttt{intersectionpoint}}. +çÌÁ×ÎÁÑ ÒÁÚÎÉÃÁ ÍÅÖÄÕ ÜÔÉÍÉ ÍÁËÒÏÓÁÍÉ É ÔÅÍÉ, ÏÐÒÅÄÅÌÅÎÉÑ ËÏÔÏÒÙÈ ÍÙ ÕÖÅ +ÚÎÁÅÍ, × ÔÏÍ, ËÁË ÏÐÒÅÄÅÌÑÔØ ÓÉÎÔÁËÓÉÓ ÉÈ ÁÒÇÕÍÅÎÔÏ×. +%%The main difference between these macros and the ones we already know +%%how to define is their argument syntax. + +íÁËÒÏÓÙ {\tt round} É {\tt unitvector} --- ÜÔÏ ÐÒÉÍÅÒÙ ÔÏÇÏ, ÞÔÏ +ÎÁ ÒÉÓ.~\ref{syexpr} ÚÏ×ÅÔÓÑ \tdescr{ÕÎÁÒÎÙÍ ÏÐÅÒÁÔÏÒÏÍ}. +%%The {\tt round} and {\tt unitvector} macros are examples of what +%%Figure~\ref{syexpr} calls \tdescr{unary op}. +úÁ ÎÉÍÉ ÓÌÅÄÕÅÔ ×ÙÒÁÖÅÎÉÅ-ÐÅÒ×ÉÞÎÏÓÔØ. +%%That is, they are followed by a primary expression. +äÌÑ ÕËÁÚÁÎÉÑ ÁÒÇÕÍÅÎÔÁ ÍÁËÒÏÓÁ ÔÁËÏÇÏ ÔÉÐÁ ÏÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ ÄÏÌÖÎÏ +×ÙÇÌÑÄÅÔØ ÐÏÄÏÂÎÏ ÜÔÏÍÕ: +$$ \hbox{\tt vardef round primary u =}\, \descr{ÔÅËÓÔ ÚÁÍÅÎÙ}\, + \hbox{\tt enddef;} +$$ +%%To specify a macro argument of this type, the +%%macro definition should look like this: +%%$$ \hbox{\tt vardef round primary u =}\, \descr{replacement text}\, +%% \hbox{\tt enddef;} +%%$$ +ðÁÒÁÍÅÔÒ {\tt u} --- ÜÔÏ {\tt expr}-ÐÁÒÁÍÅÔÒ\index{ÐÁÒÁÍÅÔÒ!expr} É ÏÎ +ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎ × ÔÏÞÎÏÓÔÉ ÔÁËÖÅ ËÁË ÐÁÒÁÍÅÔÒ-×ÙÒÁÖÅÎÉÅ, +ÏÐÒÅÄÅÌÑÅÍÙÊ ÏÂÙÞÎÙÍ ÓÉÎÔÁËÓÉÓÏÍ, +$$ \hbox{\tt (expr u)} $$ +%%The {\tt u} parameter is an expr parameter\index{parameter!expr} and it can be +%%used exactly like the expr parameter defined using the ordinary +%%$$ \hbox{\tt (expr u)} $$ +%%syntax. + +ëÁË ÐÒÅÄÐÏÌÁÇÁÅÔ ÐÒÉÍÅÒ Ó {\tt round}, ÍÁËÒÏÓ ÍÏÖÅÔ ÏÐÒÅÄÅÌÑÔØÓÑ Ó +ÐÁÒÁÍÅÔÒÏÍ +\tdescr{×ÔÏÒÉÞÎÏÓÔØÀ}\index{×ÔÏÒÉÞÎÏÓÔØ?\tdescr{×ÔÏÒÉÞÎÏÓÔØ}}, +\tdescr{ÔÒÅÔÉÞÎÏÓÔØÀ}\index{ÔÒÅÔÉÞÎÏÓÔØ?\tdescr{ÔÒÅÔÉÞÎÏÓÔØ}} ÉÌÉ +\tdescr{×ÙÒÁÖÅÎÉÅÍ}\index{×ÙÒÁÖÅÎÉÅ?\tdescr{×ÙÒÁÖÅÎÉÅ}}. +%%As the {\tt round} example suggests, a macro can be defined to take a +%%\tdescr{secondary}\index{secondary?\tdescr{secondary}}, +%%\tdescr{tertiary}\index{tertiary?\tdescr{tertiary}}, or an +%%\tdescr{expression}\index{expression?\tdescr{expression}} parameter. +îÁÐÒÉÍÅÒ, ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÏÅ ÏÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ {\tt fill} ÐÒÉÍÅÒÎÏ ÔÁËÏÅ\index{fill?\texttt{fill}} +$$ \hbox{\tt def fill expr c = addto currentpicture contour c enddef;} $$ +%%For example, the predefined definition of the {\tt fill} macro is +%%roughly\index{fill?\texttt{fill}} +%%$$ \hbox{\tt def fill expr c = addto currentpicture contour c enddef;} $$ + +÷ÏÚÍÏÖÎÏ ÄÁÖÅ ÏÐÒÅÄÅÌÉÔØ ÍÁËÒÏÓ × ÒÏÌÉ \tdescr{of-ÏÐÅÒÁÔÏÒÁ}\index{of operator?\tdescr{of-ÏÐÅÒÁÔÏÒ}} ÉÚ ÒÉÓ.~\ref{syexpr}. +%%It is even possible to define a macro to play the role of \tdescr{of +%%operator}\index{of operator?\tdescr{of operator}} in +%%Figure~\ref{syexpr}. +îÁÐÒÉÍÅÒ, ÍÁËÒÏÓ {\tt direction +of}\index{direction of?\texttt{direction of}} ÉÍÅÅÔ ÏÐÒÅÄÅÌÅÎÉÅ ÔÁËÏÊ +ÆÏÒÍÙ: +$$ \hbox{\tt vardef direction expr t of p =}\, \descr{ÔÅËÓÔ ÚÁÍÅÎÙ}\, + \hbox{\tt enddef;} +$$ +%%For example, the {\tt direction +%%of}\index{direction of?\texttt{direction of}} macro has a definition of +%%this form: +%%$$ \hbox{\tt vardef direction expr t of p =}\, \descr{replacement text}\, +%% \hbox{\tt enddef;} +%%$$ + +íÁËÒÏÓÙ ÍÏÖÎÏ ÔÁËÖÅ ÏÐÒÅÄÅÌÑÔØ Ó ÐÏ×ÅÄÅÎÉÅÍ, ÐÏÄÏÂÎÙÍ ÂÉÎÁÒÎÙÍ ÏÐÅÒÁÔÏÒÁÍ. +%%Macros can also be defined to behave like binary operators. +îÁÐÒÉÍÅÒ, ÏÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ {\tt dotprod} ÉÍÅÅÔ +ÆÏÒÍÕ\index{dotprod?\texttt{dotprod}}\index{primarydef?\texttt{primarydef}} +$$ \hbox{\tt primarydef w dotprod z =}\, \descr{ÔÅËÓÔ ÚÁÍÅÎÙ}\, + \hbox{\tt enddef;} +$$ +%%For instance, the +%%definition of the {\tt dotprod} macro has the +%%form\index{dotprod?\texttt{dotprod}}\index{primarydef?\texttt{primarydef}} +%%$$ \hbox{\tt primarydef w dotprod z =}\, \descr{replacement text}\, +%% \hbox{\tt enddef;} +%%$$ +üÔÁ ÆÏÒÍÁ ÄÅÌÁÅÔ {\tt dotprod} \tdescr{ÐÅÒ×ÉÞÎÙÍ ÂÉÎÁÒÎÙÍ +ÏÐÅÒÁÔÏÒÏÍ}\index{ÐÅÒ×ÉÞÎÙÊ +binop?\tdescr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}. +%%This makes {\tt dotprod} a \tdescr{primary binop}\index{primary +%%binop?\tdescr{primary binop}}. +ðÏÈÏÖÉÍ ÏÂÒÁÚÏÍ {\tt +secondarydef}\index{secondarydef?\texttt{secondarydef}} É {\tt +tertiarydef}\index{tertiarydef?\texttt{tertiarydef}} ××ÏÄÑÔ ÏÐÒÅÄÅÌÅÎÉÑ +\tdescr{×ÔÏÒÉÞÎÏÇÏ ÂÉÎÁÒÎÏÇÏ ÏÐÅÒÁÔÏÒÁ}\index{×ÔÏÒÉÞÎÙÊ binop?\tdescr{×ÔÏÒÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}} +É \tdescr{ÔÒÅÔÉÞÎÏÇÏ ÂÉÎÁÒÎÏÇÏ ÏÐÅÒÁÔÏÒÁ}\index{ÔÒÅÔÉÞÎÙÊ binop?\tdescr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}. +%%Similarly, {\tt +%%secondarydef}\index{secondarydef?\texttt{secondarydef}} and {\tt +%%tertiarydef}\index{tertiarydef?\texttt{tertiarydef}} introduce +%%\tdescr{secondary binop}\index{secondary binop?\tdescr{secondary binop}} +%%and \tdescr{tertiary binop}\index{tertiary binop?\tdescr{tertiary +%%binop}} definitions. +÷ÓÅ ÏÎÉ ÏÐÒÅÄÅÌÑÀÔ ÏÂÙÞÎÙÅ ÍÁËÒÏÓÙ, Á ÎÅ vardef-ÍÁËÒÏÓÙ, ÎÁÐÒÉÍÅÒ, +``{\tt primaryvardef}'' ÎÅ ÓÕÝÅÓÔ×ÕÅÔ. +%%These all define ordinary macros, not vardef +%%macros; e.g., there is no ``{\tt primaryvardef}.'' + +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÏÐÒÅÄÅÌÅÎÉÑ ÍÁËÒÏÓÏ× ÍÏÇÕÔ ××ÏÄÉÔØÓÑ Ó {\tt def}, +{\tt vardef}, {\tt primarydef}, {\tt secondarydef} ÉÌÉ {\tt tertiarydef}. +%%Thus macro definitions can be introduced by {\tt def}, {\tt vardef}, +%%{\tt primarydef}, {\tt secondarydef}, or {\tt tertiarydef}. +\tdescr{ôÅËÓÔ ÚÁÍÅÎÙ}\index{ÔÅËÓÔ ÚÁÍÅÎÙ?\tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ}} +--- ÜÔÏ ÌÀÂÏÊ ÓÐÉÓÏË ÚÎÁËÏ×, ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÊ ÏÔÎÏÓÉÔÅÌØÎÏ ÐÁÒ {\tt +def}-{\tt enddef}, ÇÄÅ ×ÓÅ ÐÑÔØ ÏÐÒÅÄÅÌÑÀÝÉÈ ÍÁËÒÏÓ ÚÎÁËÏ× +ÒÁÓÓÍÁÔÒÉ×ÁÀÔÓÑ ÐÏÄÏÂÎÙÍÉ {\tt def} × ÓÏÏÔ×ÅÔÓÔ×ÉÉ {\tt def}-{\tt enddef}. +%%A \tdescr{replacement text}\index{replacement text?\tdescr{replacement +%%text}} is any list of tokens that is balanced with respect to {\tt +%%def}-{\tt enddef} pairs where all five macro definition tokens are +%%treated like {\tt def} for the purpose of {\tt def}-{\tt enddef} +%%matching. + +÷ÅÓØ ÓÉÎÔÁËÓÉÓ ÄÌÑ ÏÐÒÅÄÅÌÅÎÉÊ ÍÁËÒÏÓÏ× ÐÒÉ×ÏÄÉÔÓÑ ÎÁ ÒÉÓ.~\ref{symacro}. +%%The rest of the syntax for macro definitions is summarized in +%%Figure~\ref{symacro}. +÷ ÜÔÏÍ ÓÉÎÔÁËÓÉÓÅ ÅÓÔØ ÎÅÓËÏÌØËÏ ÓÀÒÐÒÉÚÏ×. +%%The syntax contains a few surprises. +ðÁÒÁÍÅÔÒÙ ÍÁËÒÏÓÁ ÍÏÇÕÔ ÉÍÅÔØ \tdescr{ÏÔÄÅÌÅÎÎÕÀ ÞÁÓÔØ} É +\tdescr{ÎÅÏÔÄÅÌÅÎÎÕÀ ÞÁÓÔØ}. +%%The macro +%%parameters can have a \tdescr{delimited part} and an \tdescr{undelimited +%%part}. +ïÂÙÞÎÏ ÏÄÎÁ ÉÚ ÎÉÈ \tdescr{ÐÕÓÔÏ}, ÎÏ ×ÏÚÍÏÖÎÏ ÉÍÅÔØ ÏÂÅ ÞÁÓÔÉ ÎÅÐÕÓÔÙÍÉ: +$$ \hbox{\tt def foo(text a) expr b =}\, \descr{ÔÅËÓÔ ÚÁÍÅÎÙ}\, + \hbox{\tt enddef;} +$$ +%%Normally, one of these is \tdescr{empty}, but it is possible to +%%have both parts nonempty: +%%$$ \hbox{\tt def foo(text a) expr b =}\, \descr{replacement text}\, +%% \hbox{\tt enddef;} +%%$$ +üÔÏ ÏÐÒÅÄÅÌÑÅÔ ÍÁËÒÏÓ {\tt foo} Ó ÔÅËÓÔÏ×ÙÍ ÐÁÒÁÍÅÔÒÏÍ × ÓËÏÂËÁÈ, ÚÁ ËÏÔÏÒÙÍ +ÉÄÅÔ ×ÙÒÁÖÅÎÉÅ. +%%This defines a macro {\tt foo} to take a text parameter in parentheses followed +%%by an expression. + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÏÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ} \rightarrow + \descr{ÚÁÇÏÌÏ×ÏË ÍÁËÒÏÓÁ} \hbox{\tt =} \descr{ÔÅËÓÔ ÚÁÍÅÎÙ}\, enddef$\\ +%%$\tt \descr{macro definition} \rightarrow +%% \descr{macro heading} \hbox{\tt =} \descr{replacement text}\, enddef$\\ +$\tt \descr{ÚÁÇÏÌÏ×ÏË ÍÁËÒÏÓÁ} \rightarrow def\, \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} + \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} \descr{ÎÅÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ}$\\ +%%$\tt \descr{macro heading} \rightarrow def\, \descr{symbolic token} +%% \descr{delimited part} \descr{undelimited part}$\\ +$\tt \qquad \;|\; vardef\, \descr{ÏÂÏÂÝÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ} \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} + \descr{ÎÅÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ}$\\ +%%$\tt \qquad \;|\; vardef\, \descr{generic variable} \descr{delimited part} +%% \descr{undelimited part}$\\ +$\tt \qquad \;|\; vardef\, \descr{ÏÂÏÂÝÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ} \hbox{\tt @\#} + \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} \descr{ÎÅÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ}$\\ +%%$\tt \qquad \;|\; vardef\, \descr{generic variable} \hbox{\tt @\#} +%% \descr{delimited part} \descr{undelimited part}$\\ +$\tt \qquad \;|\; \descr{ÏÐÒÅÄÅÌÅÎÉÅ ÂÉÎÁÒÎÏÓÔÉ} \descr{ÐÁÒÁÍÅÔÒ} + \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \qquad \;|\; \descr{binary def} \descr{parameter} +%% \descr{symbolic token} \descr{parameter}$\\ +$\tt \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} \rightarrow \descr{ÐÕÓÔÏ}$\\ +%%$\tt \descr{delimited part} \rightarrow \descr{empty}$\\ +$\tt \qquad \;|\; \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} + \hbox{\tt (}\descr{ÔÉÐ ÐÁÒÁÍÅÔÒÁ} \descr{ÚÎÁËÉ ÐÁÒÁÍÅÔÒÁ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; \descr{delimited part} +%% \hbox{\tt (}\descr{parameter type} \descr{parameter tokens}\hbox{\tt )}$\\ +$\tt \descr{ÔÉÐ ÐÁÒÁÍÅÔÒÁ} \rightarrow expr \;|\; suffix \;|\; text$\\ +%%$\tt \descr{parameter type} \rightarrow expr \;|\; suffix \;|\; text$\\ +$\tt \descr{ÚÎÁËÉ ÐÁÒÁÍÅÔÒÁ} \rightarrow \descr{ÐÁÒÁÍÅÔÒ} \;|\; + \descr{ÚÎÁËÉ ÐÁÒÁÍÅÔÒÁ}\hbox{\tt ,} \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \descr{parameter tokens} \rightarrow \descr{parameter} \;|\; +%% \descr{parameter tokens}\hbox{\tt ,} \descr{parameter}$\\ +$\tt \descr{ÐÁÒÁÍÅÔÒ} \rightarrow \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}$\\ +%%$\tt \descr{parameter} \rightarrow \descr{symbolic token}$\\ +$\tt \descr{ÎÅÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} \rightarrow \descr{ÐÕÓÔÏ}$\\ +%%$\tt \descr{undelimited part} \rightarrow \descr{empty}$\\ +$\tt \qquad \;|\; \descr{ÔÉÐ ÐÁÒÁÍÅÔÒÁ} \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \qquad \;|\; \descr{parameter type} \descr{parameter}$\\ +$\tt \qquad \;|\; \descr{ÐÒÉÏÒÉÔÅÔ} \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \qquad \;|\; \descr{precedence level} \descr{parameter}$\\ +$\tt \qquad \;|\; expr\, \descr{ÐÁÒÁÍÅÔÒ}\, of\, \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \qquad \;|\; expr\, \descr{parameter}\, of\, \descr{parameter}$\\ +$\tt \descr{ÐÒÉÏÒÉÔÅÔ} \rightarrow primary \;|\; secondary \;|\; + tertiary$\\ +%%$\tt \descr{precedence level} \rightarrow primary \;|\; secondary \;|\; +%% tertiary$\\ +$\tt \descr{ÏÐÒÅÄÅÌÅÎÉÅ ÂÉÎÁÒÎÏÓÔÉ} \rightarrow primarydef \;|\; secondarydef \;|\; + tertiatydef$ +%%$\tt \descr{binary def} \rightarrow primarydef \;|\; secondarydef \;|\; +%% tertiatydef$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ÏÐÒÅÄÅÌÅÎÉÊ ÍÁËÒÏÓÏ×} +%%\caption{The syntax for macro definitions} +\label{symacro} +\end{figure} + +óÉÎÔÁËÓÉÓ ÔÁËÖÅ ÐÏÚ×ÏÌÑÅÔ \tdescr{ÎÅÏÔÄÅÌÅÎÎÏÊ ÞÁÓÔÉ} ÕËÁÚÙ×ÁÔØ ÔÉÐ +ÁÒÇÕÍÅÎÔÁ {\tt suffix}\index{suffix?\texttt{suffix}} ÉÌÉ {\tt +text}\index{text?\texttt{text}}. +%%The syntax also allows the \tdescr{undelimited part} to specify an +%%argument type of {\tt suffix}\index{suffix?\texttt{suffix}} or {\tt +%%text}\index{text?\texttt{text}}. +ðÒÉÍÅÒ ÍÁËÒÏÓÁ Ó ÎÅÏÔÄÅÌÅÎÎÙÍ ÐÁÒÁÍÅÔÒÏÍ-ÓÕÆÆÉËÓÏÍ\index{ÐÁÒÁÍÅÔÒ!suffix} --- +ÜÔÏ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ {\tt incr}\index{incr?\texttt{incr}}\label{Dincr}, +ËÏÔÏÒÙÊ × ÄÅÊÓÔ×ÉÔÅÌØÎÏÓÔÉ ÏÐÒÅÄÅÌÑÅÔÓÑ ÐÒÉÍÅÒÎÏ ÔÁË: +$$ \hbox{\verb|vardef incr suffix $ = $:=$+1; $ enddef;|} $$ +%%An example of a macro with an +%%undelimited suffix parameter\index{parameter!suffix} is the predefined +%%macro {\tt incr}\index{incr?\texttt{incr}}\label{Dincr} that is actually +%%defined like this: +%%$$ \hbox{\verb|vardef incr suffix $ = $:=$+1; $ enddef;|} $$ +üÔÏ ÄÅÌÁÅÔ {\tt incr} ÆÕÎËÃÉÅÊ, ÞÔÏ ÂÅÒÅÔ ÐÅÒÅÍÅÎÎÕÀ, Õ×ÅÌÉÞÉ×ÁÅÔ ÅÅ É +×ÏÚ×ÒÁÝÁÅÔ ÎÏ×ÏÅ ÚÎÁÞÅÎÉÅ. +%%This makes {\tt incr} a function that takes a variable, increments it, +%%and returns the new value. +îÅÏÔÄÅÌÅÎÎÙÅ ÐÁÒÁÍÅÔÒÙ-ÓÕÆÆÉËÓÙ ÍÏÇÕÔ ÂÙÔØ × ÓËÏÂËÁÈ, ÐÏÜÔÏÍÕ É {\tt incr a}, +É {\tt incr(a)} ÐÒÁ×ÉÌØÎÙ, ÅÓÌÉ {\tt a} --- ÜÔÏ ÞÉÓÌÏ×ÁÑ ÐÅÒÅÍÅÎÎÁÑ. +%%Undelimited suffix parameters may be +%%parenthesized, so {\tt incr a} and {\tt incr(a)} are both legal if {\tt +%%a} is a numeric variable. +åÓÔØ ÔÁËÖÅ ÐÏÈÏÖÉÊ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ {\tt +decr}\index{decr?\texttt{decr}}, ×ÙÞÉÔÁÀÝÉÊ~1. +%%There is also a similar predefined macro {\tt +%%decr}\index{decr?\texttt{decr}} that subtracts~1. + +îÅÏÔÄÅÌÅÎÎÙÅ ÔÅËÓÔÏ×ÙÅ ÐÁÒÁÍÅÔÒÙ\index{ÐÁÒÁÍÅÔÒ!text} ÒÁÓÐÒÏÓÔÒÁÎÑÀÔÓÑ ÄÏ +ËÏÎÃÁ ËÏÍÁÎÄÙ. +%%Undelimited text parameters\index{parameter!text} run to the end of a +%%statement. +âÏÌÅÅ ÔÏÞÎÏ, ÎÅÏÔÄÅÌÅÎÎÙÊ ÔÅËÓÔÏ×ÙÊ ÐÁÒÁÍÅÔÒ --- ÜÔÏ ÓÐÉÓÏË ÚÎÁËÏ×, ÓÌÅÄÕÀÝÉÈ +ÚÁ ×ÙÚÏ×ÏÍ ÍÁËÒÏÓÁ ÄÏ ÐÅÒ×ÏÇÏ ``{\tt ;}\index{ÔÏÞËÁ Ó ÚÁÐÑÔÏÊ}'' ÉÌÉ ``{\tt +endgroup}\index{endgroup?\texttt{endgroup}}'' ÉÌÉ ``{\tt +end}\index{end?\texttt{end}}'', Ó ÔÅÍ ÕÔÏÞÎÅÎÉÅÍ, ÞÔÏ ÁÒÇÕÍÅÎÔ, ÓÏÄÅÒÖÁÝÉÊ +``{\tt begingroup}'' ÂÕÄÅÔ ×ÓÅÇÄÁ ×ËÌÀÞÁÔØ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ``{\tt endgroup}''. +%%More precisely, an undelimited text parameter is the list of +%%tokens following the macro call up to the first ``{\tt +%%;}\index{semicolon}'' or ``{\tt +%%endgroup}\index{endgroup?\texttt{endgroup}}'' or ``{\tt +%%end}\index{end?\texttt{end}}'' except that an argument containing ``{\tt +%%begingroup}'' will always include the matching ``{\tt endgroup}.'' +ðÒÉÍÅÒ ÎÅÏÔÄÅÌÅÎÎÏÇÏ ÔÅËÓÔÏ×ÏÇÏ ÐÁÒÁÍÅÔÒÁ --- × ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÏÍ ÍÁËÒÏÓÅ +{\tt cutdraw}\index{cutdraw?\texttt{cutdraw}}\label{Dctdraw}, ÞØÅ +ÏÐÒÅÄÅÌÅÎÉÅ ×ÙÇÌÑÄÉÔ ÐÒÉÍÅÒÎÏ ÔÁË\index{linecap?\texttt{linecap}}\index{butt?\texttt{butt}}\index{interim?\texttt{interim}} +$$\begin{verbatim} +def cutdraw text t = + begingroup interim linecap:=butt; draw t; endgroup enddef; +\end{verbatim} +$$ +%%An example of an undelimited text parameter comes from the predefined macro +%%{\tt cutdraw}\index{cutdraw?\texttt{cutdraw}}\label{Dctdraw} whose +%%definition is +%%roughly\index{linecap?\texttt{linecap}}\index{butt?\texttt{butt}}\index{interim?\texttt{interim}} +%%$$\begin{verbatim} +%%def cutdraw text t = +%% begingroup interim linecap:=butt; draw t; endgroup enddef; +%%\end{verbatim} +%%$$ +üÔÏ ÄÅÌÁÅÔ {\tt cutdraw} ÓÉÎÏÎÉÍÏÍ {\tt draw}, ÎÏ Ó ÄÒÕÇÉÍ ÚÎÁÞÅÎÉÅÍ {\tt linecap}. +%%This makes {\tt cutdraw} synonymous with {\tt draw} except for the {\tt +%%linecap} value. +üÔÏ ÍÁËÒÏÓ ÐÒÅÄÏÓÔÁ×ÌÑÅÔÓÑ × ÏÓÎÏ×ÎÏÍ ÄÌÑ ÓÏ×ÍÅÓÔÉÍÏÓÔÉ Ó \MF\index{metafont?\MF}. +%%(This macro is provided mainly for compatibility with +%%\MF\index{metafont?\MF}.) + +\section{ãÉËÌÙ} +%%\section{Loops} + +íÎÏÇÏÞÉÓÌÅÎÎÙÅ ÐÒÉÍÅÒÙ × ÐÒÅÄÙÄÕÝÉÈ ÒÁÚÄÅÌÁÈ ÉÓÐÏÌØÚÏ×ÁÌÉ ÐÒÏÓÔÕÀ ÆÏÒÍÕ ÃÉËÌÁ +{\tt for}\index{ÃÉËÌÙ}\index{for?\texttt{for}}\index{endfor?\texttt{endfor}}, +$$ {\tt for}\, \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}\, \hbox{\tt =}\, + \descr{×ÙÒÁÖÅÎÉÅ}\, {\tt upto}\, \descr{×ÙÒÁÖÅÎÉÅ}:\ + \descr{ÔÅÌÏ ÃÉËÌÁ}\, {\tt endfor} +$$ +%%Numerous examples in previous sections have used simple {\tt for} loops of the +%%form\index{loops}\index{for?\texttt{for}}\index{endfor?\texttt{endfor}} +%%$$ {\tt for}\, \descr{symbolic token}\, \hbox{\tt =}\, +%% \descr{expression}\, {\tt upto}\, \descr{expression}:\ +%% \descr{loop text}\, {\tt endfor} +%%$$ +ëÏÎÓÔÒÕÉÒÏ×ÁÔØ ÃÉËÌ Ó ÕÍÅÎØÛÅÎÉÅÍ ÔÁËÖÅ ÐÒÏÓÔÏ --- ÎÕÖÎÏ ÌÉÛØ ÚÁÍÅÎÉÔØ +{\tt upto} ÎÁ {\tt +downto}\index{downto?\texttt{downto}}\label{Ddwnto} É ÓÄÅÌÁÔØ ×ÔÏÒÏÅ +\tdescr{×ÙÒÁÖÅÎÉÅ} ÍÅÎØÛÉÍ ÐÅÒ×ÏÇÏ. +%%It is equally simple to construct a loop that counts downward: just +%%replace {\tt upto} by {\tt +%%downto}\index{downto?\texttt{downto}}\label{Ddwnto} make the second +%%\tdescr{expression} smaller than the first. +üÔÏÔ ÒÁÚÄÅÌ ÏÐÉÓÙ×ÁÅÔ ÂÏÌÅÅ ÓÌÏÖÎÙÅ ÓÉÔÕÁÃÉÉ: ÐÒÏÇÒÅÓÓÉÉ; ÃÉËÌÙ, ÇÄÅ ÐÁÒÁÍÅÔÒ +ÃÉËÌÁ ×ÅÄÅÔ ÓÅÂÑ ËÁË ÓÕÆÆÉËÓ; ÓÐÏÓÏÂÙ ×ÙÈÏÄÁ ÉÚ ÃÉËÌÁ. +%%This section covers more +%%complicated types of progressions, loops where the loop counter behaves +%%like a suffix parameter, and ways of exiting from a loop. + +îÁÞÎÅÍ Ó ÐÒÅÄÓÔÁ×ÌÅÎÉÑ ÏÂÝÅÇÏ ÆÁËÔÁ ÔÏÇÏ, ÞÔÏ {\tt +upto}\index{upto?\texttt{upto}} --- ÜÔÏ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ, +ÒÁ×ÎÙÊ\index{step?\texttt{step}}\index{until?\texttt{until}} +$$ \hbox{\tt step 1 until}, $$ +É {\tt downto}\index{downto?\texttt{downto}} --- ÍÁËÒÏÓ, ÒÁ×ÎÙÊ +{\tt step -1 until}. +%%The first generalization is suggested by the fact that {\tt +%%upto}\index{upto?\texttt{upto}} is a predefined macro +%%for\index{step?\texttt{step}}\index{until?\texttt{until}} +%%$$ \hbox{\tt step 1 until} $$ +%%and {\tt downto}\index{downto?\texttt{downto}} is a macro for {\tt step +%%-1 until}. +ãÉËÌ, ÎÁÞÉÎÁÀÝÉÊÓÑ Ó +$$ \hbox{\tt for i=a step b until c}, $$ +ÐÅÒÅÂÉÒÁÅÔ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ {\tt i} ÉÚ ÚÎÁÞÅÎÉÊ {\tt a}, ${\tt a}+{\tt b}$, ${\tt +a}+2{\tt b}$, \ldots, ÏÓÔÁÎÁ×ÌÉ×ÁÑÓØ ÄÏ ÔÏÇÏ ËÁË {\tt i} ÐÒÏÊÄÅÔ ÚÁ {\tt c}, +Ô.~Å. ÃÉËÌ ÐÅÒÅÂÉÒÁÅÔ ÚÎÁÞÅÎÉÑ {\tt i}, ÇÄÅ ${\tt i}\leqslant {\tt c}$ ÐÒÉ ${\tt b}>0$ É +${\tt i}\geqslant {\tt c}$ ÐÒÉ ${\tt b}<0$. +%%A loop begining +%%$$ \hbox{\tt for i=a step b until c} $$ +%%scans a sequence of {\tt i} values {\tt a}, ${\tt a}+{\tt b}$, ${\tt +%%a}+2{\tt b}$, \ldots, stopping before {\tt i} passes {\tt c}; i.e., the +%%loop scans {\tt i} values where ${\tt i}\le {\tt c}$ if ${\tt b}>0$ and +%%${\tt i}\ge {\tt c}$ if ${\tt b}<0$. +äÌÑ ${\tt b}=0$ ÃÉËÌ ÎÉËÏÇÄÁ ÎÅ ÚÁËÏÎÞÉÔÓÑ ÄÁÖÅ ÐÒÉ ${\tt a}={\tt c}$. +%%For ${\tt b}=0$ the loop never +%%terminates, even if ${\tt a}={\tt c}$. + +ìÕÞÛÅ ×ÓÅÇÏ ÉÓÐÏÌØÚÏ×ÁÔØ ÔÁËÏÊ ÃÉËÌ ÔÏÌØËÏ ÔÏÇÄÁ, ËÏÇÄÁ ÛÁÇ ÃÉËÌÁ --- +ÜÔÏ ÃÅÌÏÅ\index{ÁÒÉÆÍÅÔÉËÁ} ÉÌÉ ÞÉÓÌÏ, ÐÒÅÄÓÔÁ×ÉÍÏÅ ÔÏÞÎÏ × ×ÉÄÅ ÄÒÏÂÉ, ËÒÁÔÎÏÊ $1\over65536$. +%%It is best to use this feature only when the step size is an integer or +%%some number that can be represented exactly in fixed point +%%arithmetic\index{arithmetic} as a multiple of $1\over65536$. +÷ ÐÒÏÔÉ×ÎÏÍ ÓÌÕÞÁÅ ÂÕÄÅÔ ÎÁËÁÐÌÉ×ÁÔØÓÑ ÏÛÉÂËÁ É ÐÁÒÁÍÅÔÒ ÃÉËÌÁ ÍÏÖÅÔ ÎÅ +ÄÏÓÔÉÞØ ÏÖÉÄÁÅÍÏÇÏ ËÏÎÅÞÎÏÇÏ ÚÎÁÞÅÎÉÑ. +%%Otherwise, +%%error will accumulate and the loop index might not reach the expected +%%termination value. +îÁÐÒÉÍÅÒ, +$$ \hbox{\tt for i=0 step .1 until 1: show i; endfor} $$ +ÐÏËÁÖÅÔ ÄÅÓÑÔØ ÚÎÁÞÅÎÉÊ {\tt i}, ÐÏÓÌÅÄÎÅÅ ÉÚ ËÏÔÏÒÙÈ ÂÕÄÅÔ 0.90005. +%%For instance, +%%$$ \hbox{\tt for i=0 step .1 until 1: show i; endfor} $$ +%%shows ten {\tt i} values the last of which is 0.90005. + +óÔÁÎÄÁÒÔÎÙÊ ÓÐÏÓÏ ÉÚÂÅÖÁÔØ ÐÒÏÂÌÅÍÙ, Ó×ÑÚÁÎÎÏÊ Ó ÎÅÃÅÌÙÍ ÒÁÚÍÅÒÏÍ ÛÁÇÁ, +× ÉÔÅÒÁÃÉÉ ÐÏ ÃÅÌÙÍ ÚÎÁÞÅÎÉÑÍ É ÕÍÎÏÖÅÎÉÀ ÉÈ ÐÒÉ ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÎÁ +ÍÁÓÛÔÁÂÉÒÕÀÝÉÊ ÍÎÏÖÉÔÅÌØ, ËÁË ÜÔÏ ÂÙÌÏ ÓÄÅÌÁÎÏ ÎÁ ÒÉÓÕÎËÁÈ \ref{fig1} +É~\ref{fig40}. +%%The standard way of avoid the problems associated with non-integer step +%%sizes is to iterate over integer values and then multiply by a scale +%%factor when using the loop index as was done in Figures \ref{fig1} +%%and~\ref{fig40}. + +åÓÔØ ÁÌØÔÅÒÎÁÔÉ×Á --- ÍÏÖÎÏ ÕËÁÚÙ×ÁÔØ ÚÎÁÞÅÎÉÑ ÄÌÑ ÐÅÒÅÂÏÒÁ Ñ×ÎÏ. +%%Alternatively, the values to iterate over can be given explicitly. +ìÀÂÁÑ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÉÚ ÎÕÌÑ É ÂÏÌÅÅ ×ÙÒÁÖÅÎÉÊ, ÒÁÚÄÅÌÅÎÎÙÈ ÚÁÐÑÔÙÍÉ, +ÍÏÖÅÔ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ ÎÁ ÍÅÓÔÅ {\tt a step b upto c}. +%%Any +%%sequence of zero or more expressions separated by commas can be used in +%%place of {\tt a step b upto c}. +ðÒÉÞÅÍ, ×ÓÅ ×ÙÒÁÖÅÎÉÑ ÎÅ ÏÂÑÚÁÎÙ ÉÍÅÔØ ÏÄÉÎÁËÏ×ÙÊ ÔÉÐ ÉÌÉ ÉÚ×ÅÓÔÎÙÅ +ÚÎÁÞÅÎÉÑ. +%%In fact, the expressions need not all +%%be the same type and they need not have known values. +ôÁËÉÍ ÏÂÒÁÚÏÍ, +$$ \hbox{\tt for t=3.14, 2.78, (a,2a), "hello": show t; endfor} $$ +ÐÏËÁÖÅÔ ÞÅÔÙÒÅ ÚÎÁÞÅÎÉÑ ÉÚ ÓÐÉÓËÁ. +%%Thus +%%$$ \hbox{\tt for t=3.14, 2.78, (a,2a), "hello": show t; endfor} $$ +%%shows the four values listed. + +úÁÍÅÔØÔÅ, ÞÔÏ ÔÅÌÏ ÃÉËÌÁ × ÐÒÉÍÅÒÅ ×ÙÛÅ --- ÜÔÏ ËÏÍÁÎÄÁ, ÚÁ ËÏÔÏÒÏÊ ÓÌÅÄÕÅÔ +ÔÏÞËÁ Ó ÚÁÐÑÔÏÊ. +%%Note that the loop body in the above example is a statement followed by a +%%semicolon. +äÌÑ ÔÅÌÁ ÃÉËÌÁ ÅÓÔÅÓÔ×ÅÎÎÏ ÓÏÄÅÒÖÁÔØ ÏÄÎÕ ÉÌÉ ÂÏÌÅÅ ËÏÍÁÎÄÕ, ÈÏÔÑ ÜÔÏ É ÎÅ +ÏÂÑÚÁÔÅÌØÎÏ. +%%It is common for the body of a loop to be one or more statements, +%%but this need not be the case. +ãÉËÌ ÐÏÄÏÂÅÎ ÏÐÒÅÄÅÌÅÎÉÀ ÍÁËÒÏÓÁ, ÚÁ ËÏÔÏÒÙÍ ÓÌÅÄÕÅÔ ×ÙÚÏ× ÜÔÏÇÏ ÍÁËÒÏÓÁ. +%%A loop is like a macro definition followed by +%%calls to the macro. +ôÅÌÏ ÃÉËÌÁ ÍÏÖÅÔ ÂÙÔØ ÐÒÁËÔÉÞÅÓËÉ ÌÀÂÏÊ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØÀ ÚÎÁËÏ×, ÉÍÅÀÝÉÈ +ÓÍÙÓÌ × ÓÏ×ÏËÕÐÎÏÓÔÉ. +%%The loop body can be virtually any sequence of tokens as +%%long as they make sense together. +ðÏÜÔÏÍÕ (ÎÅÌÅÐÁÑ) ËÏÍÁÎÄÁ +$$ \hbox{\tt draw for p=(3,1),(6,2),(7,5),(4,6),(1,3): p-{}- endfor cycle;} $$ +ÜË×É×ÁÌÅÎÔÁ +$$ \hbox{\tt draw (3,1)-{}-(6,2)-{}-(7,5)-{}-(4,6)-{}-(1,3)-{}-cycle;} $$ +%%Thus, the (ridiculous) statement +%%$$ \hbox{\tt draw for p=(3,1),(6,2),(7,5),(4,6),(1,3): p-- endfor cycle;} $$ +%%is equivalent to +%%$$ \hbox{\tt draw (3,1)--(6,2)--(7,5)--(4,6)--(1,3)--cycle;} $$ +óÍ. ÒÉÓ~\ref{fig17} Ó ÂÏÌÅÅ ÒÅÁÌÉÓÔÉÞÅÓËÉÍ ÐÏÄÈÏÄÑÝÉÍ ÐÒÉÍÅÒÏÍ. +%%(See Figure~\ref{fig17} for a more realistic example of this.) + +åÓÌÉ ÃÉËÌ ÐÏÄÏÂÅÎ ÏÐÒÅÄÅÌÅÎÉÀ ÍÁËÒÏÓÁ, ÔÏ ÐÁÒÁÍÅÔÒ ÃÉËÌÁ ÐÏÄÏÂÅÎ +{\tt expr}-ÐÁÒÁÍÅÔÒÕ\index{ÐÁÒÁÍÅÔÒ!expr}. +%%If a loop is like a macro definition, the loop index is like an expr +%%parameter\index{parameter!expr}. +ïÎ ÍÏÖÅÔ ÐÒÅÄÓÔÁ×ÌÑÔØ ÌÀÂÏÅ ÚÎÁÞÅÎÉÅ, ÎÏ ÏÎ ÎÅ Ñ×ÌÑÅÔÓÑ ÐÅÒÅÍÅÎÎÏÊ É +ÅÇÏ ÎÅÌØÚÑ ÍÅÎÑÔØ ËÏÍÁÎÄÏÊ ÐÒÉÓ×ÁÉ×ÁÎÉÑ\index{ÐÒÉÓ×ÁÉ×ÁÎÉÅ}. +%%It can represent any value, but it is +%%not a variable and it cannot be changed by an assignment +%%statement\index{assignment}. +ðÏÓÌÅÄÎÅÅ ÍÏÖÎÏ ÏÔÍÅÎÉÔØ ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ ÃÉËÌÁ {\tt +forsuffixes}\index{forsuffixes?\texttt{forsuffixes}}. +%%In order to do that, you need a {\tt +%%forsuffixes}\index{forsuffixes?\texttt{forsuffixes}} loop. +ãÉËÌ {\tt forsuffixes} ×Ï ÍÎÏÇÏÍ ÐÏÈÏÖ ÎÁ ÃÉËÌ {\tt for}, ÎÏ × ÎÅÍ +ÐÁÒÁÍÅÔÒ ÃÉËÌÁ ×ÅÄÅÔ ÓÅÂÑ ËÁË ÐÁÒÁÍÅÔÒ-ÓÕÆÆÉËÓ\index{ÐÁÒÁÍÅÔÒ!suffix}. +%%A {\tt +%%forsuffixes} loop is a lot like a {\tt for} loop, except the loop index +%%behaves like a suffix parameter\index{parameter!suffix}. +éÓÐÏÌØÚÕÅÔÓÑ ÓÉÎÔÁËÓÉÓ +$$ {\tt forsuffixes}\, \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}\, \hbox{\tt =}\, + \descr{ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×}:\ \descr{ÔÅÌÏ ÃÉËÌÁ}\, {\tt endfor}, +$$ +ÇÄÅ \tdescr{ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×} --- ÜÔÏ ÒÁÚÄÅÌÅÎÎÙÊ ÚÁÐÑÔÙÍÉ ÓÐÉÓÏË. +%%The syntax is +%%$$ {\tt forsuffixes}\, \descr{symbolic token}\, \hbox{\tt =}\, +%% \descr{suffix list}:\ \descr{loop text}\, {\tt endfor} +%%$$ +%%where a \tdescr{suffix list} is a comma-separated list of suffixes. +åÓÌÉ ÎÅËÏÔÏÒÙÅ ÓÕÆÆÉËÓÙ \tdescr{ÐÕÓÔÙ}, ÔÏ \tdescr{ÔÅÌÏ ÃÉËÌÁ} ×ÙÐÏÌÎÑÅÔÓÑ +Ó ÐÁÒÁÍÅÔÒÏÍ ÃÉËÌÁ, ÕÓÔÁÎÏ×ÌÅÎÎÙÍ × ÐÕÓÔÏÊ ÓÕÆÆÉËÓ. +%%If some of the suffixes are \tdescr{empty}, the \tdescr{loop text} gets +%%executed with the loop index parameter set to the empty suffix. + +èÏÒÏÛÉÊ ÐÒÉÍÅÒ ÄÌÑ ÃÉËÌÁ {\tt forsuffixes} --- ÜÔÏ ÏÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ {\tt +dotlabels}\index{dotlabels?\texttt{dotlabels}}\index{str?\texttt{str}}: +$$\begin{verbatim} +vardef dotlabels@#(text t) = + forsuffixes $=t: dotlabel@#(str$,z$); endfor enddef; +\end{verbatim} +$$ +%%A good example of a {\tt forsuffixes} loop is the definition of the {\tt +%%dotlabels}\index{dotlabels?\texttt{dotlabels}} +%%macro\index{str?\texttt{str}}: +%%$$\begin{verbatim} +%%vardef dotlabels@#(text t) = +%% forsuffixes $=t: dotlabel@#(str$,z$); endfor enddef; +%%\end{verbatim} +%%$$ +ïÎ ÏÂßÑÓÎÑÅÔ, ÐÏÞÅÍÕ ÐÁÒÁÍÅÔÒ {\tt dotlabels} ÄÏÌÖÅÎ ÂÙÔØ ÒÁÚÄÅÌÅÎÎÙÊ ÚÁÐÑÔÙÍÉ +ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×. +%%This should make it clear why the parameter to {\tt dotlabels} has to be a +%%comma-separated list of suffixes. +âÏÌØÛÉÎÓÔ×Ï ÍÁËÒÏÓÏ× Ó ÒÁÚÄÅÌÅÎÎÙÍÉ ÚÁÐÑÔÙÍÉ ÓÐÉÓËÁÍÉ ÐÅÒÅÍÅÎÎÏÊ ÄÌÉÎÙ +ÉÓÐÏÌØÚÕÀÔ ÉÈ × ÃÉËÌÁÈ {\tt for} ÉÌÉ {\tt forsuffixes} ÉÍÅÎÎÏ ÔÁËÉÍ ÏÂÒÁÚÏÍ, +Ô.~Å. ÄÌÑ ÐÅÒÅÂÏÒÁ ÚÎÁÞÅÎÉÊ. +%%Most macros that accept variable-length +%%comma-separated lists +%%use them in {\tt for} or {\tt forsuffixes} loops in this fashion as values to +%%iterate over. + +ëÏÇÄÁ ÎÅÔ ÚÎÁÞÅÎÉÊ ÄÌÑ ÐÅÒÅÂÏÒÁ, ×Ù ÍÏÖÅÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ ÃÉËÌ +{\tt forever}\index{forever?\texttt{forever}}, +$$ {\tt forever}\hbox{\tt :}\, \descr{ÔÅÌÏ ÃÉËÌÁ}\, {\tt endfor} $$ +%%When there are no values to iterate over, you can use a +%%{\tt forever}\index{forever?\texttt{forever}} loop: +%%$$ {\tt forever}\hbox{\tt :}\, \descr{loop text}\, {\tt endfor} $$ +äÌÑ ÚÁ×ÅÒÛÅÎÉÑ ÔÁËÏÇÏ ÃÉËÌÁ, ËÏÇÄÁ ÌÏÇÉÞÅÓËÏÅ ÕÓÌÏ×ÉÅ ÓÔÁÎÅÔ ÉÓÔÉÎÎÙÍ, +ÉÓÐÏÌØÚÕÊÔÅ ÐÕÎËÔ ×ÙÈÏÄÁ\index{exitif?\texttt{exitif}}: +$$ {\tt exitif}\, \descr{ÌÏÇÉÞÅÓËÏÅ ×ÙÒÁÖÅÎÉÅ} \hbox{\tt ;} $$ +%%To terminate such a loop when a boolean condition becomes true, use an exit +%%clause\index{exitif?\texttt{exitif}}: +%%$$ {\tt exitif}\, \descr{boolean expression} \hbox{\tt ;} $$ +ëÏÇÄÁ ÉÎÔÅÒÐÒÅÔÁÔÏÒ MetaPost ×ÓÔÒÅÞÁÅÔ ÐÕÎËÔ ×ÙÈÏÄÁ, ÏÎ +×ÙÞÉÓÌÑÅÔ \tdescr{ÌÏÇÉÞÅÓËÏÅ ×ÙÒÁÖÅÎÉÅ} É ×ÙÈÏÄÉÔ ÉÚ ÔÅËÕÝÅÇÏ ÃÉËÌÁ, +ÅÓÌÉ ÏÎÏ ÉÓÔÉÎÎÏ. +%%When the MetaPost interpreter encounters an exit clause, it evaluates +%%the \tdescr{boolean expression} and exits the current loop if the +%%expression is true. +åÓÌÉ ÂÏÌÅÅ ÕÄÏÂÎÏ ×ÙÊÔÉ ÉÚ ÃÉËÌÁ, ËÏÇÄÁ ×ÙÒÁÖÅÎÉÅ ÓÔÁÎÅÔ ÌÏÖÎÙÍ, +ÔÏ ÉÓÐÏÌØÚÕÊÔÅ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ {\tt +exitunless}\index{exitunless?\texttt{exitunless}}. +%%If it is more convenient to exit the loop when an +%%expression becomes false, use the predefined macro {\tt +%%exitunless}\index{exitunless?\texttt{exitunless}}. + +ðÏÜÔÏÍÕ ×ÁÒÉÁÎÔ MetaPost ÄÌÑ ÃÉËÌÁ {\bf while} --- ÜÔÏ +$$ \hbox{\tt forever: exitunless}\, \descr{ÌÏÇÉÞÅÓËÏÅ ×ÙÒÁÖÅÎÉÅ} \hbox{\tt ;}\, + \descr{ÔÅÌÏ ÃÉËÌÁ}\, {\tt endfor} +$$ +%%Thus MetaPost's version of a {\bf while} loop is +%%$$ \hbox{\tt forever: exitunless}\, \descr{boolean expression} \hbox{\tt ;}\, +%% \descr{loop text}\, {\tt endfor} +%%$$ +ðÕÎËÔ ×ÙÈÏÄÁ ÍÏÖÅÔ ÐÏÍÅÝÁÔØÓÑ ËÁË ÎÅÐÏÓÒÅÄÓÔ×ÅÎÎÏ ÐÅÒÅÄ {\tt endfor}, ÔÁË É +× ÌÀÂÏÍ ÄÒÕÇÏÍ ÍÅÓÔÅ \tdescr{ÔÅÌÁ ÃÉËÌÁ}. +%%The exit clause could equally well come just before {\tt endfor} or anywhere +%%in the \tdescr{loop text}. +ìÀÂÏÊ ÃÉËÌ {\tt for}, {\tt forever} ÉÌÉ {\tt forsuffixes} ÍÏÖÅÔ ÐÒÁËÔÉÞÅÓËÉ +ÓÏÄÅÒÖÁÔØ ÌÀÂÏÅ ËÏÌÉÞÅÓÔ×Ï ÐÕÎËÔÏ× ×ÙÈÏÄÁ. +%%In fact any {\tt for}, {\tt forever}, or +%%{\tt forsuffixes} loop can contain any number of exit clauses. + +ó×ÏÄËÁ ÓÉÎÔÁËÓÉÓÁ ÃÉËÌÁ, ÐÏËÁÚÁÎÎÁÑ ÎÁ ÒÉÓ.~\ref{syloop}, ÎÅ ÕÐÏÍÉÎÁÅÔ +Ñ×ÎÏ ÐÕÎËÔÙ ×ÙÈÏÄÁ, ÐÏÔÏÍÕ ÞÔÏ \tdescr{ÔÅÌÏ ÃÉËÌÁ} ÍÏÖÅÔ ÂÙÔØ × ÄÅÊÓÔ×ÉÔÅÌØÎÏÓÔÉ +ÌÀÂÏÊ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØÀ ÚÎÁËÏ×. +%%The summary of loop syntax shown in Figure~\ref{syloop} does not mention +%%exit clauses explicitly because a \tdescr{loop text} can be virtually +%%any sequence of tokens. +åÄÉÎÓÔ×ÅÎÎÏÅ ÏÇÒÁÎÉÞÅÎÉÅ × ÔÏÍ, ÞÔÏ \tdescr{ÔÅÌÏ ÃÉËÌÁ} ÄÏÌÖÎÏ ÂÙÔØ ÓÂÁÌÁÎÓÉÒÏ×ÁÎÏ +ÏÔÎÏÓÉÔÅÌØÎÏ {\tt for} É {\tt endfor}. +%%The only restriction is that a \tdescr{loop +%%text} must be balanced with respect to {\tt for} and {\tt endfor}. +ëÏÎÅÞÎÏ, × ÜÔÏÍ ÂÁÌÁÎÓÅ {\tt forsuffixes} É {\tt forever} ÒÁÓÓÍÁÔÒÉ×ÁÀÔÓÑ +ËÁË {\tt for}. +%%Of course this balancing process treats {\tt forsuffixes} and {\tt forever} +%%just like {\tt for}. + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÃÉËÌ} \rightarrow \descr{ÚÁÇÏÌÏ×ÏË ÃÉËÌÁ}\hbox{\tt :}\, + \descr{ÔÅÌÏ ÃÉËÌÁ} endfor$\\ +%%$\tt \descr{loop} \rightarrow \descr{loop header}\hbox{\tt :}\, +%% \descr{loop text} endfor$\\ +$\tt \descr{ÚÁÇÏÌÏ×ÏË ÃÉËÌÁ} \rightarrow for\, \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}\, + \hbox{\tt =}\, \descr{ÐÒÏÇÒÅÓÓÉÑ}$\\ +%%$\tt \descr{loop header} \rightarrow for\, \descr{symbolic token}\, +%% \hbox{\tt =}\, \descr{progression}$\\ +$\tt \qquad \;|\; for\, \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}\, \hbox{\tt =}\, + \descr{ÓÐÉÓÏË for}$\\ +%%$\tt \qquad \;|\; for\, \descr{symbolic token}\, \hbox{\tt =}\, +%% \descr{for list}$\\ +$\tt \qquad \;|\; forsuffixes\, \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}\, \hbox{\tt =}\, + \descr{ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×}$\\ +%%$\tt \qquad \;|\; forsuffixes\, \descr{symbolic token}\, \hbox{\tt =}\, +%% \descr{suffix list}$\\ +$\tt \qquad \;|\; forever$\\ +%%$\tt \qquad \;|\; forever$\\ +$\tt \descr{ÐÒÏÇÒÅÓÓÉÑ} \rightarrow \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\, upto\, + \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{progression} \rightarrow \descr{numeric expression}\, upto\, +%% \descr{numeric expression}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\, downto\, + \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; \descr{numeric expression}\, downto\, +%% \descr{numeric expression}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\, step\, + \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\, until\, \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} $\\ +%%$\tt \qquad \;|\; \descr{numeric expression}\, step\, +%% \descr{numeric expression}\, until\, \descr{numeric expression} $\\ +$\tt \descr{ÓÐÉÓÏË for} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ} + \;|\; \descr{ÓÐÉÓÏË for}\hbox{\tt ,}\, \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{for list} \rightarrow \descr{expression} +%% \;|\; \descr{for list}\hbox{\tt ,}\, \descr{expression}$\\ +$\tt \descr{ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×} \rightarrow \descr{ÓÕÆÆÉËÓ} + \;|\; \descr{ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×}\hbox{\tt ,}\, \descr{ÓÕÆÆÉËÓ}$ +%%$\tt \descr{suffix list} \rightarrow \descr{suffix} +%% \;|\; \descr{suffix list}\hbox{\tt ,}\, \descr{suffix}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ÄÌÑ ÃÉËÌÏ×} +%%\caption{The syntax for loops} +\label{syloop} +\end{figure} + + +\section{éÚÇÏÔÏ×ÌÅÎÉÅ ÒÁÍÏË} +%%\section{Making Boxes} +\label{boxessec} + +üÔÏÔ ÒÁÚÄÅÌ ÏÐÉÓÙ×ÁÅÔ ÄÏÐÏÌÎÉÔÅÌØÎÙÅ ÍÁËÒÏÓÙ, ÎÅ ×ËÌÀÞÅÎÎÙÅ × +Plain MetaPost, ÞÔÏ ÐÒÅÄÏÓÔÁ×ÌÑÀÔ ÕÄÏÂÓÔ×Á ÄÅÌÁÔØ ÔÏ, × ÞÅÍ ÈÏÒÏÛ +{\it pic} \cite{ke:pic}. +%%This section describes auxiliary macros not included in Plain MetaPost +%%that make it convenient to do things that {\it pic} is good at +%%\cite{ke:pic}. +á ÔÏ, ÞÔÏ ÓÌÅÄÕÅÔ ÄÁÌÅÅ --- ÜÔÏ ÏÐÉÓÁÎÉÅ, ËÁË ÉÓÐÏÌØÚÏ×ÁÔØ ÍÁËÒÏÓÙ, +ÓÏÄÅÒÖÁÝÉÅÓÑ × ÆÁÊÌÅ {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}}. +%%What follows is a description of how to use the macros +%%contained in the file {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}}. +üÔÏÔ ÆÁÊÌ ÒÁÚÍÅÝÁÅÔÓÑ × ÓÐÅÃÉÁÌØÎÏÍ ËÁÔÁÌÏÇÅ ÄÌÑ ÍÁËÒÏÓÏ× MetaPost +É ÏÂÅÓÐÅÞÉ×ÁÀÝÅÇÏ ÐÒÏÇÒÁÍÍÎÏÇÏ ÏÂÅÓÐÅÞÅÎÉÑ\footnote{éÍÑ ÜÔÏÇÏ ËÁÔÁÌÏÇÁ +ÐÏÄÏÂÎÏ ÞÅÍÕ-ÔÏ ÔÉÐÁ \texttt{/usr/lib/mp/lib}, ÎÏ ÚÁ×ÉÓÉÔ ÏÔ ÓÉÓÔÅÍÙ.} +É ÄÏÌÖÅÎ ÓÔÁÔØ ÄÏÓÔÕÐÎÙÍ ÞÅÒÅÚ ËÏÍÁÎÄÕ MetaPost {\tt input boxes} +ÄÏ ÌÀÂÙÈ ÒÉÓÕÎËÏ×, ÉÓÐÏÌØÚÕÀÝÉÈ ÍÁËÒÏÓÙ ÄÌÑ ÓÏÚÄÁÎÉÑ ÒÁÍÏË. +%%This file is included in a special directory reserved for MetaPost +%%macros and support software\footnote{The name of this directory is +%%likely to be something like \texttt{/usr/lib/mp/lib}, but this is system +%%dependent.} and can be accessed by giving the MetaPost command {\tt +%%input boxes} before any figures that use the box making macros. +óÉÎÔÁËÓÉÓ ËÏÍÁÎÄÙ {\tt input}\index{input?\texttt{input}} --- +$$ {\tt input}\, \descr{ÉÍÑ ÆÁÊÌÁ}, $$ +ÇÄÅ ÏËÏÎÞÁÎÉÅ ``{\tt .mp}'' ÍÏÖÅÔ ÏÐÕÓËÁÔØÓÑ × ÉÍÅÎÉ ÆÁÊÌÁ. +%%The +%%syntax for the {\tt input} command is \index{input?\texttt{input}} +%$$ {\tt input}\, \descr{file name} $$ +%%where a final ``{\tt .mp}'' can be omitted from the file name. +ëÏÍÁÎÄÁ {\tt input} ÓÍÏÔÒÉÔ ÓÎÁÞÁÌÁ × ÔÅËÕÝÅÍ ËÁÔÁÌÏÇÅ, Á ÚÁÔÅÍ × ÓÐÅÃÉÁÌØÎÏÍ +ËÁÔÁÌÏÇÅ ÄÌÑ ÍÁËÒÏÓÏ×. +%%The {\tt input} +%%command looks first in the current directory and then in the special macro +%%directory. +ðÏÌØÚÏ×ÁÔÅÌÉ, ÚÁÉÎÔÅÒÅÓÏ×Á×ÛÉÅÓÑ × ÎÁÐÉÓÁÎÉÉ ÍÁËÒÏÓÏ×, ×ÏÚÍÏÖÎÏ ÚÁÈÏÔÑÔ +ÐÏÓÍÏÔÒÅÔØ ÎÁ ÆÁÊÌ {\tt boxes.mp} × ÜÔÏÍ ËÁÔÁÌÏÇÅ. +%%Users interested in writing macros may want to look at the +%%{\tt boxes.mp} file in this directory. + +ó ×ÒÅÍÅÎÉ ÐÏÑ×ÌÅÎÉÑ ÐÁËÅÔÁ \texttt{boxes} × MetaPost-ÓÏÏÂÝÅÓÔ×Å ÂÙÌÉ +ÒÁÚÒÁÂÏÔÁÎÙ ÎÅÓËÏÌØËÏ ÁÌØÔÅÒÎÁÔÉ×ÎÙÈ ÐÁËÅÔÏ× ÒÁÚÎÙÈ ×ÉÄÏ× ÄÌÑ ÒÉÓÏ×ÁÎÉÑ ÒÁÍÏË. +%%Since the advent of the \texttt{boxes} package several alternative +%%packages for drawing boxes of all kinds have been developed by the +%%MetaPost community. +îÁÉÂÏÌÅÅ ÉÚ×ÅÓÔÎÙÅ ÉÚ ÎÉÈ --- ÜÔÏ +%%The most widely known ones are +\texttt{MetaObj}\index{MetaObj?\texttt{MetaObj}}, +\texttt{MetaUML}\index{MetaUML?\texttt{MetaUML}}, +\texttt{expressg}\index{expressg?\texttt{expressg}} É +%%\texttt{expressg}\index{expressg?\texttt{expressg}}, and +\texttt{blockdraw\_mp}\index{blockdraw\_mp?\texttt{blockdraw\_mp}}. +åÓÌÉ ×Ù ÓÏÂÉÒÁÅÔÅÓØ ÓÏÚÄÁ×ÁÔØ ÍÎÏÇÏ ÓÔÒÕËÔÕÒÎÙÈ ÒÉÓÕÎËÏ×, ÄÉÁÇÒÁÍÍ É +Ô.~Ð., ÔÏ ÜÔÉ ÐÁËÅÔÙ ÔÏÖÅ ÍÏÇÕÔ ÓÔÁÔØ ÄÌÑ ×ÁÓ ÉÎÔÅÒÅÓÎÙÍ ÒÅÓÕÒÓÏÍ. +%%If you intend to create lots of structural drawings, flow charts, +%%\emph{etc.}, those packages might be an interesting ressource, too. + +\subsection{ðÒÑÍÏÕÇÏÌØÎÙÅ ÒÁÍËÉ} +%%\subsection{Rectangular Boxes} + +çÌÁ×ÎÁÑ ÉÄÅÑ ÓÏÚÄÁÀÝÉÈ ÒÁÍËÉ ÍÁËÒÏÓÏ× × ÔÏÍ, ÞÔÏ ÍÏÖÎÏ +ÓËÁÚÁÔØ\index{boxit?\texttt{boxit}}\label{Dboxit} +$$ {\tt boxit.} \descr{ÓÕÆÆÉËÓ} + \hbox{\tt(} \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ} \hbox{\tt),} +$$ +ÇÄÅ \tdescr{ÓÕÆÆÉËÓ} ÎÅ ÎÁÞÉÎÁÅÔÓÑ Ó ÉÎÄÅËÓÁ\footnote{îÅËÏÔÏÒÙÅ ÒÁÎÎÉÅ +×ÅÒÓÉÉ ÄÅÌÁÀÝÉÈ ÒÁÍËÉ ÍÁËÒÏÓÏ× ÎÅ ÐÏÚ×ÏÌÑÌÉ ÎÉËÁËÉÈ ÉÎÄÅËÓÏ× × ÓÕÆÆÉËÓÅ +{\tt boxit}.}. +%%The main idea of the box-making macros is that one should +%%say\index{boxit?\texttt{boxit}}\label{Dboxit} +%%$$ {\tt boxit.} \descr{suffix} +%% \hbox{\tt(} \descr{picture expression} \hbox{\tt)} +%%$$ +%%where the \tdescr{suffix} does not start with a subscript.\footnote{Some early +%%versions of the box making macros did not allow any subscripts in the +%%{\tt boxit} suffix.} +üÔÁ ËÏÎÓÔÒÕËÃÉÑ ÓÏÚÄÁÅÔ ÐÅÒÅÍÅÎÎÙÅ-ÐÁÒÙ \tdescr{ÓÕÆÆÉËÓ}{\tt.c}, +\tdescr{ÓÕÆÆÉËÓ}{\tt.n}, \tdescr{ÓÕÆÆÉËÓ}{\tt.e}, \ldots, ÞÔÏ ÍÏÇÕÔ ÚÁÔÅÍ +ÉÓÐÏÌØÚÏ×ÁÔØÓÑ ÐÒÉ ÒÁÚÍÅÝÅÎÉÉ ÒÉÓÕÎËÁ ÐÅÒÅÄ ÅÇÏ ÒÉÓÏ×ÁÎÉÅÍ ÏÔÄÅÌØÎÏÊ +ËÏÍÁÎÄÏÊ\index{drawboxed?\texttt{drawboxed}}\label{Ddrbxed}, ÎÁÐÒÉÍÅÒ, +$$ \hbox{\tt drawboxed(} \descr{ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×} \hbox{\tt )} $$ +%%This creates pair variables \tdescr{suffix}{\tt.c}, +%%\tdescr{suffix}{\tt.n}, \tdescr{suffix}{\tt.e}, \ldots\ that can then be +%%used for positioning the picture before drawing it with a separate command such +%%as\index{drawboxed?\texttt{drawboxed}}\label{Ddrbxed} +%%$$ \hbox{\tt drawboxed(} \descr{suffix list} \hbox{\tt )} $$ +áÒÇÕÍÅÎÔ {\tt drawboxed} ÄÏÌÖÅÎ ÂÙÔØ ÒÁÚÄÅÌÅÎÎÙÍ ÚÁÐÑÔÙÍÉ ÓÐÉÓËÏÍ ÉÍÅÎ ÒÁÍÏË, +ÇÄÅ ÉÍÑ ÒÁÍËÉ\index{ÉÍÑ ÒÁÍËÉ} --- ÜÔÏ \tdescr{ÓÕÆÆÉËÓ}, Ó ËÏÔÏÒÙÍ +×ÙÚÙ×ÁÅÔÓÑ {\tt boxit}. +%%The argument to {\tt drawboxed} should be a comma-separated list of box names, +%%where a box name\index{box name} is a \tdescr{suffix} with which {\tt boxit} +%%has been called. + +äÌÑ ËÏÍÁÎÄÙ {\tt boxit.bb(pic)} ÉÍÑ ÒÁÍËÉ --- ÜÔÏ {\tt bb}, Á +ÓÏÄÅÒÖÉÍÏÅ ÒÁÍËÉ --- ÜÔÏ ÒÉÓÕÎÏË {\tt pic}. +%%For the command {\tt boxit.bb(pic)}, the box name is {\tt bb} and the +%%contents of the box is the picture {\tt pic}. +÷ ÜÔÏÍ ÓÌÕÞÁÅ, {\tt bb.c} --- ÜÔÏ ÐÏÚÉÃÉÑ ÐÏÍÅÝÅÎÉÑ ÃÅÎÔÒÁ ËÁÒÔÉÎËÉ {\tt pic}, +Á {\tt bb.sw}, {\tt bb.se}, {\tt bb.ne} É {\tt bb.nw} --- ÜÔÏ ÕÇÌÙ +ÐÒÑÍÏÕÇÏÌØÎÏÇÏ ÐÕÔÉ, ÞÔÏ ÂÕÄÅÔ ÏËÒÕÖÁÔØ ËÁÒÔÉÎËÕ-ÒÅÚÕÌØÔÁÔ. +%%In this case, {\tt bb.c} +%%the position where the center of picture {\tt pic} is to be placed, and +%%{\tt bb.sw}, {\tt bb.se}, {\tt bb.ne}, and {\tt bb.nw} are the corners +%%of a rectangular path that will surround the resulting picture. +ðÅÒÅÍÅÎÎÙÅ {\tt bb.dx} É {\tt bb.dy} ÄÁÀÔ ÐÒÏÍÅÖÕÔËÉ ÍÅÖÄÕ ÓÄ×ÉÎÕÔÏÊ +×ÅÒÓÉÅÊ {\tt pic} É ÏËÒÕÖÁÀÝÉÍ ÐÒÑÍÏÕÇÏÌØÎÉËÏÍ, Á {\tt bb.off} --- +ÜÔÏ ÒÁÓÓÔÏÑÎÉÅ, ÎÁ ËÏÔÏÒÏÅ {\tt pic} ÓÄ×ÉÇÁÅÔÓÑ ÄÌÑ ÄÏÓÔÉÖÅÎÉÑ ×ÓÅÇÏ +ÜÔÏÇÏ. +%%Variables {\tt bb.dx} and {\tt bb.dy} give the spacing between the +%%shifted version of {\tt pic} and the surrounding rectangle, and {\tt +%%bb.off} is the amount by which {\tt pic} has to be shifted to achieve +%%all this. + +ëÏÇÄÁ ÍÁËÒÏÓ {\tt boxit} ×ÙÚÙ×ÁÅÔÓÑ Ó ÉÍÅÎÅÍ ÒÁÍËÉ~$b$, ÔÏ ÜÔÏ ÄÁÅÔ +ÌÉÎÅÊÎÙÅ ÕÒÁ×ÎÅÎÉÑ, ÞÔÏ ÚÁÓÔÁ×ÌÑÀÔ $b${\tt.sw}, $b${\tt.se}, $b${\tt.ne} +É $b${\tt.nw} ÂÙÔØ ÕÇÌÁÍÉ ÐÒÑÍÏÕÇÏÌØÎÉËÁ ×ÄÏÌØ ÏÓÅÊ $x$ É $y$, +ÓÏÄÅÒÖÁÝÉÍ ×ÎÕÔÒÉ ËÁÒÔÉÎËÕ, ÐÏËÁÚÁÎÎÕÀ ÓÅÒÙÍ ÐÒÑÍÏÕÇÏÌØÎÉËÏÍ ÎÁ +ÒÉÓ.~\ref{fig48}. +%%When the {\tt boxit} macro is called with box name~$b$, it gives linear +%%equations that force $b${\tt.sw}, $b${\tt.se}, $b${\tt.ne}, and +%%$b${\tt.nw} to be the corners of a rectangle aligned on the $x$ and $y$ +%%axes with the box contents centered inside as indicated by the gray +%%rectangle in Figure~\ref{fig48}. +úÎÁÞÅÎÉÑ $b${\tt.dx}, $b${\tt.dy} É $b${\tt.c} ÏÓÔÁÀÔÓÑ ÎÅÕËÁÚÁÎÎÙÍÉ, ÔÁË ÞÔÏ +ÐÏÌØÚÏ×ÁÔÅÌØ ÍÏÖÅÔ ÚÁÄÁÔØ ÕÒÁ×ÎÅÎÉÑ ÄÌÑ ÒÁÚÍÅÝÅÎÉÑ ÒÁÍÏË. +%%The values of $b${\tt.dx}, +%%$b${\tt.dy}, and $b${\tt.c} are left unspecified so that the user can +%%give equations for positioning the boxes. +åÓÌÉ ÔÁËÉÅ ÕÒÁ×ÎÅÎÉÑ ÎÅ ÚÁÄÁÀÔÓÑ, ÔÏ ÍÁËÒÏÓÙ ÔÉÐÁ {\tt drawboxed} ÍÏÇÕÔ +ÜÔÏ ÏÂÎÁÒÕÖÉ×ÁÔØ É ÚÁÄÁ×ÁÔØ ÓÔÁÎÄÁÒÔÎÙÅ ÚÎÁÞÅÎÉÑ. +%%If no such equations are +%%given, macros such as {\tt drawboxed} can detect this and give default +%%values. +óÔÁÎÄÁÒÔÎÙÅ ÚÎÁÞÅÎÉÑ ÄÌÑ ÐÅÒÅÍÅÎÎÙÈ {\tt dx} É {\tt dy} ÕÐÒÁ×ÌÑÀÔÓÑ +×ÎÕÔÒÅÎÎÉÍÉ ÐÅÒÅÍÅÎÎÙÍÉ\index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} {\tt +defaultdx}\index{defaultdx?\texttt{defaultdx}}\label{Ddefaultdx} É +{\tt defaultdy}\index{defaultdy?\texttt{defaultdy}}\label{Ddefaultdy}. +%%The default values for {\tt dx} and {\tt dy} variables are +%%controlled by the internal variables\index{internal +%%variables}\index{variables!internal} {\tt +%%defaultdx}\index{defaultdx?\texttt{defaultdx}}\label{Ddefaultdx} and +%%{\tt defaultdy}\index{defaultdy?\texttt{defaultdy}}\label{Ddefaultdy}. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-48} $$ +\caption[ëÁË {\tt boxit}-ÒÉÓÕÎÏË ÓÏÏÔÎÏÓÉÔÓÑ Ó ÁÓÓÏÃÉÉÒÏ×ÁÎÎÙÍ ÐÅÒÅÍÅÎÎÙÍÉ] + {ïÔÎÏÛÅÎÉÑ ÍÅÖÄÕ ÒÉÓÕÎËÏÍ, ÚÁÄÁÎÎÙÍ ÄÌÑ {\tt boxit}, É + Ó×ÑÚÁÎÎÙÍÉ Ó ÜÔÉÍ ÐÅÒÅÍÅÎÎÙÍÉ. òÉÓÕÎÏË ÉÚÏÂÒÁÖÅÎ ÓÅÒÙÍ ÐÒÑÍÏÕÇÏÌØÎÉËÏÍ.} +%%\caption[How a {\tt boxit} picture relates to the associated variables] +%% {The relationship between the picture given to {\tt boxit} and the +%% associated variables. The picture is indicated by a gray rectangle.} +\label{fig48} +\end{figure} + +åÓÌÉ $b$ ÐÒÅÄÓÔÁ×ÌÑÅÔ ÉÍÑ ÒÁÍËÉ, ÔÏ {\tt drawboxed($b$)} ÒÉÓÕÅÔ +ÐÒÑÍÏÕÇÏÌØÎÕÀ ÇÒÁÎÉÃÕ ÓÏÄÅÒÖÉÍÏÇÏ~$b$, Á ÚÁÔÅÍ É ÓÁÍÏ ÓÏÄÅÒÖÉÍÏÅ. +%%If $b$ represents a box name, {\tt drawboxed($b$)} draws the rectangular +%%boundary of box~$b$ and then the contents of the box. +üÔÏÔ ÏÈ×ÁÔÙ×ÁÀÝÉÊ ÐÒÑÍÏÕÇÏÌØÎÉË ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎ ÏÔÄÅÌØÎÏ ËÁË +{\tt bpath~$b$} ÉÌÉ, × ÏÂÝÅÍ ÓÌÕÞÁÅ,\index{bpath?\texttt{bpath}}\label{Dbpath} +$$ {\tt bpath}\, \descr{ÉÍÑ ÒÁÍËÉ} $$ +%%This bounding +%%rectangle can be accessed separately as {\tt bpath~$b$}, or in +%%general\index{bpath?\texttt{bpath}}\label{Dbpath} +%%$$ {\tt bpath}\, \descr{box name} $$ +üÔÏ ÐÏÌÅÚÎÏ × ËÏÍÂÉÎÁÃÉÉ Ó ÏÐÅÒÁÔÏÒÁÍÉ ÔÉÐÁ {\tt +cutbefore}\index{cutbefore?\texttt{cutbefore}} É {\tt +cutafter}\index{cutafter?\texttt{cutafter}} ÄÌÑ ËÏÎÔÒÏÌÑ +ÚÁ ÐÕÔÑÍÉ, ×ÈÏÄÑÝÉÍÉ × ÒÁÍËÕ. +%%It is useful in combination with operators like +%%{\tt cutbefore}\index{cutbefore?\texttt{cutbefore}} and {\tt %%cutafter}\index{cutafter?\texttt{cutafter}} +%%in order to control paths that enter the box. +îÁÐÒÉÍÅÒ, ÅÓÌÉ $a$ É $b$ --- ÜÔÏ ÉÍÅÎÁ ÒÁÍÏË É $p$ --- ÜÔÏ ÐÕÔØ ÉÚ $a${\tt.c} +× $b${\tt.c},\index{drawarrow?\texttt{drawarrow}} ÔÏ +$$ \hbox{\tt drawarrow $p$ cutbefore bpath $a$ cutafter bpath $b$} $$ +ÒÉÓÕÅÔ ÓÔÒÅÌËÕ ÏÔ ËÒÁÑ ÒÁÍËÉ $a$ ÄÏ ËÒÁÑ ÒÁÍËÉ $b$. +%%For example, if $a$ and $b$ are box names and $p$ is a path from $a${\tt.c} +%%to $b${\tt.c},\index{drawarrow?\texttt{drawarrow}} +%%$$ \hbox{\tt drawarrow $p$ cutbefore bpath $a$ cutafter bpath $b$} $$ +%%draws an arrow from the edge of box $a$ to the edge of box $b$. + +òÉÓ.~\ref{fig49} ÐÏËÁÚÙ×ÁÅÔ ÐÒÁËÔÉÞÅÓËÉÊ ÐÒÉÍÅÒ ×ËÌÀÞÅÎÉÑ ÎÅÓËÏÌØËÉÈ +ÓÔÒÅÌÏË, ÎÁÒÉÓÏ×ÁÎÎÙÈ Ó {\tt cutafter bpath} \tdescr{ÉÍÑ ÒÁÍËÉ}. +%%Figure~\ref{fig49} shows a practical example including some arrows drawn +%%with {\tt cutafter bpath} \tdescr{box name}. +ðÏÕÞÉÔÅÌØÎÏ ÓÒÁ×ÎÉÔØ ÒÉÓ.~\ref{fig49} Ó ÐÏÈÏÖÅÊ ËÁÒÔÉÎËÏÊ × ÒÕËÏ×ÏÄÓÔ×Å ÐÏ +{\it pic} \cite{ke:pic}. +%%It is instructive to +%%compare Figure~\ref{fig49} to the similar figure in the pic manual +%%\cite{ke:pic}. +òÉÓÕÎÏË ÉÓÐÏÌØÚÕÅÔ ÍÁËÒÏÓ\index{boxjoin?\texttt{boxjoin}}\label{Dbxjoin} +$$ \hbox{\tt boxjoin(} \descr{ÔÅËÓÔ ÕÒÁ×ÎÅÎÉÊ} \hbox{\tt )} $$ +ÄÌÑ ÕÐÒÁ×ÌÅÎÉÑ ÏÔÎÏÛÅÎÉÑÍÉ ÍÅÖÄÕ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÙÍÉ ÒÁÍËÁÍÉ. +%%The figure uses a +%%macro\index{boxjoin?\texttt{boxjoin}}\label{Dbxjoin} +%%$$ \hbox{\tt boxjoin(} \descr{equation text} \hbox{\tt )} $$ +%%to control the relationship between consecutive boxes. +÷ \tdescr{ÔÅËÓÔÅ ÕÒÁ×ÎÅÎÉÊ} {\tt a} É {\tt b} ÐÒÅÄÓÔÁ×ÌÑÀÔ ÉÍÅÎÁ ÒÁÍÏË, +ÚÁÄÁÎÎÙÅ × ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÙÈ ×ÙÚÏ×ÁÈ {\tt boxit}, Á \tdescr{ÔÅËÓÔ ÕÒÁ×ÎÅÎÉÊ} +ÄÁÅÔ ÕÒÁ×ÎÅÎÉÑ ÄÌÑ ËÏÎÔÒÏÌÑ ÚÁ ÏÔÎÏÓÉÔÅÌØÎÙÍÉ ÒÁÚÍÅÒÁÍÉ É ÐÏÚÉÃÉÑÍÉ ÒÁÍÏË. +%%Within the +%%\tdescr{equation text}, {\tt a} and {\tt b} represent the box names given in +%%consecutive calls to {\tt boxit} and the \tdescr{equation text} gives equations +%%to control the relative sizes and positions of the boxes. + +\begin{figure}[htp] +$$\hbox{$\begin{verbatim} +input boxes +beginfig(49); +boxjoin(a.se=b.sw; a.ne=b.nw); +boxit.a(btex\strut$\cdots$ etex); boxit.ni(btex\strut$n_i$ etex); +boxit.di(btex\strut$d_i$ etex); boxit.ni1(btex\strut$n_{i+1}$ etex); +boxit.di1(btex\strut$d_{i+1}$ etex); boxit.aa(btex\strut$\cdots$ etex); +boxit.nk(btex\strut$n_k$ etex); boxit.dk(btex\strut$d_k$ etex); +drawboxed(di,a,ni,ni1,di1,aa,nk,dk); label.lft("ndtable:", a.w); +interim defaultdy:=7bp; +boxjoin(a.sw=b.nw; a.se=b.ne); +boxit.ba(); boxit.bb(); boxit.bc(); +boxit.bd(btex $\vdots$ etex); boxit.be(); boxit.bf(); +bd.dx=8bp; ba.ne=a.sw-(15bp,10bp); +drawboxed(ba,bb,bc,bd,be,bf); label.lft("hashtab:",ba.w); +vardef ndblock suffix $ = + boxjoin(a.sw=b.nw; a.se=b.ne); + forsuffixes $$=$1,$2,$3: boxit$$(); ($$dx,$$dy)=(5.5bp,4bp); + endfor; enddef; +ndblock nda; ndblock ndb; ndblock ndc; +nda1.c-bb.c = ndb1.c-nda3.c = (whatever,0); +xpart ndb3.se = xpart ndc1.ne = xpart di.c; +ndc1.c - be.c = (whatever,0); +drawboxed(nda1,nda2,nda3, ndb1,ndb2,ndb3, ndc1,ndc2,ndc3); +drawarrow bb.c -- nda1.w; +drawarrow be.c -- ndc1.w; +drawarrow nda3.c -- ndb1.w; +drawarrow nda1.c{right}..{curl0}ni.c cutafter bpath ni; +drawarrow nda2.c{right}..{curl0}di.c cutafter bpath di; +drawarrow ndc1.c{right}..{curl0}ni1.c cutafter bpath ni1; +drawarrow ndc2.c{right}..{curl0}di1.c cutafter bpath di1; +drawarrow ndb1.c{right}..nk.c cutafter bpath nk; +drawarrow ndb2.c{right}..dk.c cutafter bpath dk; +x.ptr=xpart aa.c; y.ptr=ypart ndc1.ne; +drawarrow subpath (0,.7) of (z.ptr..{left}ndc3.c) dashed evenly; +label.rt(btex \strut ndblock etex, z.ptr); endfig; +\end{verbatim} +$} +\atop \vcenter{\vskip8pt\hbox{\includegraphics{manfig-ru-49}}} +$$ +\caption{ëÏÄ MetaPost É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ÒÉÓÕÎÏË} +%%\caption{MetaPost code and the corresponding figure} +\label{fig49} +\end{figure} + +îÁÐÒÉÍÅÒ, ×ÔÏÒÁÑ ÓÔÒÏËÁ ××ÏÄÁ ÄÌÑ ÐÒÉ×ÅÄÅÎÎÏÇÏ ÒÉÓÕÎËÁ ÓÏÄÅÒÖÉÔ +$$ \hbox{\tt boxjoin(a.se=b.sw; a.ne=b.nw)} $$ +%%For example, the second line of input for the above figure contains +%%$$ \hbox{\tt boxjoin(a.se=b.sw; a.ne=b.nw)} $$ +üÔÏ ÒÁÚÍÅÝÁÅÔ ÒÁÍËÉ ÇÏÒÉÚÏÎÔÁÌØÎÏ × ÒÑÄ, ÂÌÁÇÏÄÁÒÑ ÚÁÄÁÎÉÀ ÄÏÐÏÌÎÉÔÅÌØÎÙÈ +ÕÒÁ×ÎÅÎÉÊ, ×ÙÚÙ×ÁÅÍÙÈ ×ÓÑËÉÊ ÒÁÚ, ËÏÇÄÁ ÎÅËÏÔÏÒÁÑ ÒÁÍËÁ {\tt b} ÓÌÅÄÕÅÔ ÚÁ +ÎÅËÏÔÏÒÏÊ ÒÁÍËÏÊ {\tt a}. +%%This causes boxes to line up horizontally by giving additional equations that +%%are invoked each time some box {\tt a} is followed by some other box~{\tt b}. +%%These equations are first invoked on the next line when box~{\tt a} is followed +%%by box~{\tt ni}. +üÔÉÍ ÄÏÓÔÉÇÁÅÔÓÑ +$$ \hbox{\tt a.se=ni.sw; a.ne=ni.nw} $$ +%%This yields +%%$$ \hbox{\tt a.se=ni.sw; a.ne=ni.nw} $$ +óÌÅÄÕÀÝÁÑ ÐÁÒÁ ÒÁÍÏË --- ÜÔÏ ~{\tt ni} É~{\tt di}. +%%The next pair of boxes is box~{\tt ni} and box~{\tt di}. +îÁ ÜÔÏÔ ÒÁÚ ÎÅÑ×ÎÏ ÇÅÎÅÒÉÒÕÅÍÙÅ ÕÒÁ×ÎÅÎÉÑ --- +$$ \hbox{\tt ni.se=di.sw; ni.ne=di.nw} $$ +%%This time the implicitly generated equations are +%%$$ \hbox{\tt ni.se=di.sw; ni.ne=di.nw} $$ +üÔÏÔ ÐÒÏÃÅÓÓ ÐÒÏÄÏÌÖÁÅÔÓÑ ÄÏ ÔÅÈ ÐÏÒ, ÐÏËÁ ÎÏ×ÙÊ {\tt +boxjoin}\index{boxjoin?\texttt{boxjoin}} ÎÅ ÂÕÄÅÔ ÚÁÄÁÎ. +%%This process continues until a new {\tt +%%boxjoin}\index{boxjoin?\texttt{boxjoin}} is given. +÷ ÎÁÛÅÍ ÓÌÕÞÁÅ ÎÏ×ÏÊ ÄÅËÌÁÒÁÃÉÅÊ ÂÕÄÅÔ +$$ \hbox{\tt boxjoin(a.sw=b.nw; a.se=b.ne)} $$ +--- ÏÎÁ ÓÏÅÄÉÎÑÅÔ ÒÁÍËÉ ÄÒÕÇ ÐÏÄ ÄÒÕÇÏÍ. +%%In this case the new declaration is +%%$$ \hbox{\tt boxjoin(a.sw=b.nw; a.se=b.ne)} $$ +%%which causes boxes to be stacked below each other. + +ðÏÓÌÅ ×ÙÚÏ×Á {\tt boxit} ÄÌÑ ÐÅÒ×ÙÈ ×ÏÓØÍÉ ÒÁÍÏË ÏÔ {\tt a} ÄÏ {\tt +dk}, ×ÙÓÏÔÙ ÒÁÍÏË ÐÒÉÎÕÖÄÁÀÔÓÑ Ë ×ÚÁÉÍÎÏÍÕ ÓÏÏÔ×ÅÔÓÔ×ÉÀ, ÎÏ ÛÉÒÏÔÙ +ÏÓÔÁÀÔÓÑ ÎÅÉÚ×ÅÓÔÎÙÍÉ. +%%After calling {\tt boxit} for the first eight boxes {\tt a} through {\tt +%%dk}, the box heights are constrained to match but the widths are still +%%unknown. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÍÁËÒÏÓ {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}} +ÎÕÖÄÁÅÔÓÑ × ÐÒÉÓ×ÁÉ×ÁÎÉÉ ÔÉÐÏ×ÙÈ ÚÎÁÞÅÎÉÊ ÐÅÒÅÍÅÎÎÙÍ \tdescr{ÉÍÑ ÒÁÍËÉ}{\tt.dx} +É \tdescr{ÉÍÑ ÒÁÍËÉ}{\tt.dy}. +%%Thus the {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}} +%%macro needs to assign default values to the \tdescr{box name}{\tt.dx} +%%and \tdescr{box name}{\tt.dy} variables. +ðÅÒ×ÙÍ ÄÅÌÏÍ {\tt di.dx} É {\tt di.dy} ÐÏÌÕÞÁÀÔ ÚÎÁÞÅÎÉÑ ÐÏ-ÕÍÏÌÞÁÎÉÀ, ÔÁË +ÞÔÏ ×ÓÅ ÒÁÍËÉ ÐÒÉÎÕÖÄÁÀÔÓÑ ÂÙÔØ ÄÏÓÔÁÔÏÞÎÏ ÂÏÌØÛÉÍÉ ÄÌÑ ×ÍÅÝÅÎÉÑ +ÓÏÄÅÒÖÉÍÏÇÏ~{\tt di}. +%%First, {\tt di.dx} and {\tt +%%di.dy} get default values so that all the boxes are forced to be large +%%enough to contain the contents of box~{\tt di}. + +íÁËÒÏÓ, ËÏÔÏÒÙÊ × ÄÅÊÓÔ×ÉÔÅÌØÎÏÓÔÉ ÐÒÉÓ×ÁÉ×ÁÅÔ ÔÉÐÏ×ÙÅ ÚÎÁÞÅÎÉÑ +ÐÅÒÅÍÅÎÎÙÍ {\tt dx} É {\tt dy}, ÚÏ×ÅÔÓÑ {\tt +fixsize}\index{fixsize?\texttt{fixsize}}\label{Dfixsiz}. +%%The macro that actually assigns default values to {\tt dx} and {\tt dy} +%%variables is called {\tt +%%fixsize}\index{fixsize?\texttt{fixsize}}\label{Dfixsiz}. +ïÎ ÂÅÒÅÔ ÓÐÉÓÏË ÉÍÅÎ ÒÁÍÏË É ÒÁÓÓÍÁÔÒÉ×ÁÅÔ ÉÈ ÐÏ-ÏÄÎÏÍÕ ÚÁ ÒÁÚ, +ÇÁÒÁÎÔÉÒÕÑ, ÞÔÏ ËÁÖÄÁÑ ÒÁÍËÁ ÂÕÄÅÔ ÉÍÅÔØ ÚÁÄÁÎÎÙÅ ÒÁÚÍÅÒ É ÆÏÒÍÕ. +%%It takes a +%%list of box names and considers them one at a time, making sure that +%%each box has a fixed size and shape. +úÁÔÅÍ ÍÁËÒÏÓ Ó ÉÍÅÎÅÍ {\tt +fixpos}\index{fixpos?\texttt{fixpos}}\label{Dfixpos} ÂÅÒÅÔ ÜÔÏÔ ÖÅ +ÓÁÍÙÊ ÓÐÉÓÏË ÉÍÅÎ ÒÁÍÏË É ÐÒÉÓ×ÁÉ×ÁÅÔ ÔÉÐÏ×ÙÅ ÚÎÁÞÅÎÉÑ ÐÅÒÅÍÅÎÎÙÍ \tdescr{ÉÍÑ +ÒÁÍËÉ}{\tt.off}, ËÁË ÎÅÏÂÈÏÄÉÍÏ ÄÌÑ ÆÉËÓÁÃÉÉ ÐÏÚÉÃÉÉ ËÁÖÄÏÊ ÒÁÍËÉ. +%%A macro called {\tt +%%fixpos}\index{fixpos?\texttt{fixpos}}\label{Dfixpos} then takes this +%%same list of box names and assigns default values to the \tdescr{box +%%name}{\tt.off} variables as needed to fix the position of each box. +éÓÐÏÌØÚÏ×ÁÎÉÅ {\tt fixsize} ÄÌÑ ÆÉËÓÁÃÉÉ ÒÁÚÍÅÒÏ× ËÁÖÄÏÊ ÒÁÍËÉ ÄÏ +ÐÒÉÓ×ÁÉ×ÁÎÉÑ ÐÏÚÉÃÉÉ ÌÀÂÏÊ ÉÚ ÎÉÈ ÍÏÖÅÔ ÏÂÙÞÎÏ ÓÏËÒÁÔÉÔØ ÞÉÓÌÏ +ÔÒÅÂÕÅÍÙÈ ÐÏÚÉÃÉÊ ÐÏ-ÕÍÏÌÞÁÎÉÀ ÄÏ ÏÄÎÏÊ. +%%By using {\tt fixsize} to fix the dimensions of each box before assigning +%%default positions to any of them, the number of needing default +%%positions can usually be cut to at most one. + +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÏÈ×ÁÔÙ×ÁÀÝÉÊ ÐÕÔØ ÄÌÑ ÒÁÍËÉ ÎÅ ÍÏÖÅÔ ÂÙÔØ ×ÙÞÉÓÌÅÎ +ÄÏ ÔÅÈ ÐÏÒ, ÐÏËÁ ÒÁÚÍÅÒ, ÆÏÒÍÁ É ÐÏÚÉÃÉÑ ÒÁÍËÉ ÎÅÏÐÒÅÄÅÌÅÎÙ, ÍÁËÒÏÓ +{\tt bpath}\index{bpath?\texttt{bpath}} ÐÒÉÍÅÎÑÅÔ {\tt fixsize} É {\tt +fixpos} Ë Ó×ÏÉÍ ÁÒÇÕÍÅÎÔÁÍ. +%%Since the bounding path for a box cannot be computed until the size, +%%shape, and position of the box is determined, the {\tt +%%bpath}\index{bpath?\texttt{bpath}} macro applies {\tt fixsize} and {\tt +%%fixpos} to its argument. +äÒÕÇÉÅ ÍÁËÒÏÓÙ, ÞÔÏ ÄÅÌÁÀÔ ÔÁËÖÅ, ×ËÌÀÞÁÀÔ\index{pic?\texttt{pic}}\label{Dpic} +$$ {\tt pic}\, \descr{ÉÍÑ ÒÁÍËÉ}, $$ +ÇÄÅ \tdescr{ÉÍÑ ÒÁÍËÉ} --- ÜÔÏ ÓÕÆÆÉËÓ, ×ÏÚÍÏÖÎÏ, × ÓËÏÂËÁÈ. +%%Other macros that do this +%%include\index{pic?\texttt{pic}}\label{Dpic} +%%$$ {\tt pic}\, \descr{box name} $$ +%%where the \tdescr{box name} is a suffix, possibly in parentheses. +ïÎ ×ÏÚ×ÒÁÝÁÅÔ ÓÏÄÅÒÖÁÎÉÅ ÉÍÅÎÏ×ÁÎÎÏÊ ÒÁÍËÉ ËÁË ËÁÒÔÉÎËÉ, ÐÏÚÉÃÉÏÎÉÒÏ×ÁÎÎÏÊ +ÔÁË, ÞÔÏ +$$ {\tt draw\ pic} \descr{ÉÍÑ ÒÁÍËÉ} $$ +ÉÚÏÂÒÁÖÁÅÔ ÓÏÄÅÒÖÉÍÏÅ ÒÁÍËÉ ÂÅÚ ÏÈ×ÁÔÙ×ÁÀÝÅÇÏ ÐÒÑÍÏÕÇÏÌØÎÉËÁ. +%%This returns +%%the contents of the named box as a picture positioned so that +%%$$ {\tt draw\ pic} \descr{box name} $$ +%%draws the box contents without the bounding rectangle. +üÔÁ ÏÐÅÒÁÃÉÑ ÍÏÖÅÔ ÔÁËÖÅ ÂÙÔØ ÕÓÏ×ÅÒÛÅÎÓÔ×Ï×ÁÎÁ ÍÁËÒÏÓÏÍ {\tt +drawunboxed}\index{drawunboxed?\texttt{drawunboxed}}\label{Ddrunbx}, +ÂÅÒÕÝÉÍ ÒÁÚÄÅÌÅÎÎÙÊ ÚÁÐÑÔÙÍÉ ÓÐÉÓÏË ÉÍÅÎ ÒÁÍÏË. +%%This operation can also be accomplished by the {\tt +%%drawunboxed}\index{drawunboxed?\texttt{drawunboxed}}\label{Ddrunbx} +%%macro that takes a comma-separated list of box names. +åÓÔØ ÅÝÅ ÍÁËÒÏÓ {\tt drawboxes}\index{drawboxes?\texttt{drawboxes}}\label{Ddrbxes}, +ÒÉÓÕÀÝÉÊ ÔÏÌØËÏ ÏÈ×ÁÔÙ×ÁÀÝÉÅ ÐÒÑÍÏÕÇÏÌØÎÉËÉ. +%%There is also a +%%{\tt drawboxes}\index{drawboxes?\texttt{drawboxes}}\label{Ddrbxes} macro +%%that draws just the bounding rectangles. + +äÒÕÇÏÊ ÓÐÏÓÏ ÎÁÒÉÓÏ×ÁÔØ ÐÕÓÔÙÅ ÐÒÑÍÏÕÇÏÌØÎÉËÉ --- ÜÔÏ ÐÒÏÓÔÏ\label{Deboxit} +$$ {\tt boxit} \descr{ÉÍÑ ÒÁÍËÉ} \hbox{\tt ()} $$ +ÂÅÚ ÒÉÓÕÎËÁ-ÁÒÇÕÍÅÎÔÁ, ËÁË ÜÔÏ ÄÅÌÁÌÏÓØ ÎÅÓËÏÌØËÏ ÒÁÚ ÎÁ ÒÉÓ.~\ref{fig49}. +%%Another way to draw empty rectangles is by just saying\label{Deboxit} +%%$$ {\tt boxit} \descr{box name} \hbox{\tt ()} $$ +%%with no picture argument as is done several times in Figure~\ref{fig49}. +üÔÏ ÐÏÈÏÖÅ ÎÁ ×ÙÚÏ× {\tt boxit} Ó ÐÕÓÔÙÍ ÁÒÇÕÍÅÎÔÏÍ. +%%This is like calling {\tt boxit} with an empty picture. +ëÒÏÍÅ ÔÏÇÏ, ÁÒÇÕÍÅÎÔ ÍÏÖÅÔ ÂÙÔØ ÓÔÒÏËÏ×ÙÍ\label{Dsboxit} ×ÙÒÁÖÅÎÉÅÍ +×ÍÅÓÔÏ ×ÙÒÁÖÅÎÉÑ-ÒÉÓÕÎËÁ É × ÜÔÏÍ ÓÌÕÞÁÅ ÓÔÒÏËÁ ÉÚÏÂÒÁÖÁÅÔÓÑ +ÛÒÉÆÔÏÍ ÐÏ-ÕÍÏÌÞÁÎÉÀ. +%%Alternatively the argument can be a string\label{Dsboxit} expression +%%instead of a picture +%%expression in which case the string is typeset in the default font. + +\subsection{ëÒÕÇÌÙÅ É Ï×ÁÌØÎÙÅ ÒÁÍËÉ} +%%\subsection{Circular and Oval Boxes} + +ëÒÕÇÏ×ÙÅ É Ï×ÁÌØÎÙÅ ÒÁÍËÉ ×Ï ÍÎÏÇÏÍ ÐÏÈÏÖÉ ÎÁ ÐÒÑÍÏÕÇÏÌØÎÙÅ, ÏÔÌÉÞÁÑÓØ +ÔÏÌØËÏ ÆÏÒÍÏÊ ÏÈ×ÁÔÙ×ÁÀÝÅÇÏ ÐÕÔÉ. +%%Circular and oval boxes are a lot like rectangular boxes except for the shape +%%of the bounding path. +ôÁËÉÅ ÒÁÍËÉ ÕÓÔÁÎÁ×ÌÉ×ÁÀÔÓÑ ÍÁËÒÏÓÏÍ +{\tt circleit}\index{circleit?\texttt{circleit}}\label{Dcircit}: +$$ {\tt circleit} \descr{ÉÍÑ ÒÁÍËÉ} + \hbox{\tt(} \descr{ÓÏÄÅÒÖÁÎÉÅ ÒÁÍËÉ} \hbox{\tt)}, +$$ +ÇÄÅ \tdescr{ÉÍÑ ÒÁÍËÉ} --- ÜÔÏ ÓÕÆÆÉËÓ, Á \tdescr{ÓÏÄÅÒÖÁÎÉÅ ÒÁÍËÉ} --- ÜÔÏ ÌÉÂÏ +×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ, ÌÉÂÏ ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ, ÌÉÂÏ \tdescr{ÐÕÓÔÏ}. +%%Such boxes are set up by the +%%{\tt circleit}\index{circleit?\texttt{circleit}}\label{Dcircit} macro: +%%$$ {\tt circleit} \descr{box name} +%% \hbox{\tt(} \descr{box contents} \hbox{\tt)} +%%$$ +%%where \tdescr{box name} is a suffix and \tdescr{box contents} is either a +%%picture expression, a string expression, or \tdescr{empty}. + +íÁËÒÏÓ {\tt circleit} ÏÐÒÅÄÅÌÑÅÔ ÐÅÒÅÍÅÎÎÙÅ-ÐÁÒÙ ÔÁËÖÅ, ËÁË {\tt boxit}, ÎÏ ÂÅÚ +ÕÇÌÏ×ÙÈ ÔÏÞÅË \tdescr{ÉÍÑ ÒÁÍËÉ}{\tt.ne}, \tdescr{ÉÍÑ ÒÁÍËÉ}{\tt.sw} É Ô.~Ä. +%%The {\tt circleit} macro defines pair variables just as {\tt boxit} does, except +%%that there are no corner points \tdescr{box name}{\tt.ne}, +%%\tdescr{box name}{\tt.sw}, etc. +÷ÙÚÏ× +$$ \hbox{\tt circleit.a(}\ldots \hbox{\tt )} $$ +ÚÁÄÁÅÔ ÏÔÎÏÛÅÎÉÑ ÍÅÖÄÕ ÔÏÞËÁÍÉ {\tt a.c}, {\tt a.s}, {\tt a.e}, {\tt +a.n}, {\tt a.w} É ÒÁÓÓÔÏÑÎÉÑ {\tt a.dx} É {\tt a.dy}. +%%A call to +%%$$ \hbox{\tt circleit.a(}\ldots \hbox{\tt )} $$ +%%gives relationships among points {\tt a.c}, {\tt a.s}, {\tt a.e}, {\tt +%%a.n}, {\tt a.w} and distances {\tt a.dx} and {\tt a.dy}. +÷ÍÅÓÔÅ Ó {\tt a.c} É {\tt a.off} ÜÔÉ ÐÅÒÅÍÅÎÎÙÅ ÏÐÒÅÄÅÌÑÀÔ, ËÁË ËÁÒÔÉÎËÁ +ÃÅÎÔÒÉÒÕÅÔÓÑ × Ï×ÁÌÅ, ÞÔÏ ÍÏÖÎÏ Õ×ÉÄÅÔØ ÎÁ ÒÉÓ.~\ref{fig50}. +%%Together with +%%{\tt a.c} and {\tt a.off}, these variables describe how the picture is +%%centered in an oval as can be seen from the Figure~\ref{fig50}. + +\begin{figure}[htp] +$$ \includegraphics{manfig-ru-50} $$ +\caption[ëÁË {\tt circleit}-ÒÉÓÕÎÏË ÓÏÏÔÎÏÓÉÔÓÑ Ó ÁÓÓÏÃÉÉÒÏ×ÁÎÎÙÍÉ ÐÅÒÅÍÅÎÎÙÍÉ] + {ïÔÎÏÛÅÎÉÑ ÍÅÖÄÕ ÚÁÄÁÎÎÙÍ {\tt circleit} ÒÉÓÕÎËÏÍ É Ó×ÑÚÁÎÎÙÍÉ + Ó ÜÔÉÍ ÐÅÒÅÍÅÎÎÙÍÉ. òÉÓÕÎÏË ÉÚÏÂÒÁÖÅÎ ÓÅÒÙÍ ÐÒÑÍÏÕÇÏÌØÎÉËÏÍ.} +%%\caption[How a {\tt circleit} picture relates to the associated variables] +%% {The relationship between the picture given to {\tt circleit} and the +%% associated variables. The picture is indicated by a gray rectangle.} +\label{fig50} +\end{figure} + +íÁËÒÏÓÙ {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}}, {\tt +drawunboxed}\index{drawunboxed?\texttt{drawunboxed}}, {\tt +drawboxes}\index{drawboxes?\texttt{drawboxes}}, {\tt +pic}\index{pic?\texttt{pic}} É {\tt +bpath}\index{bpath?\texttt{bpath}} ÒÁÂÏÔÁÀÔ ÄÌÑ ÒÁÍÏË {\tt circleit} +ÔÁËÖÅ ËÁË É ÄÌÑ ÒÁÍÏË {\tt boxit}. +%%The {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}}, {\tt +%%drawunboxed}\index{drawunboxed?\texttt{drawunboxed}}, {\tt +%%drawboxes}\index{drawboxes?\texttt{drawboxes}}, {\tt +%%pic}\index{pic?\texttt{pic}}, and {\tt +%%bpath}\index{bpath?\texttt{bpath}} macros work for {\tt circleit} boxes +%%just as they do for {\tt boxit} boxes. + +ôÉÐÏ×ÏÊ ÏÈ×ÁÔÙ×ÁÀÝÉÊ ÐÕÔØ ÄÌÑ ÒÁÍËÉ {\tt circleit} ÄÏÓÔÁÔÏÞÎÏ ×ÅÌÉË ÄÌÑ +ÏËÒÕÖÅÎÉÑ ÓÏÄÅÒÖÉÍÏÇÏ ÒÁÍËÉ Ó ÍÁÌÅÎØËÉÍÉ ÐÒÅÄÏÈÒÁÎÑÀÝÉÍÉ ÏÔÓÔÕÐÁÍÉ, +ÕÐÒÁ×ÌÑÅÍÙÍÉ ×ÎÕÔÒÅÎÎÅÊ ÐÅÒÅÍÅÎÎÏÊ\index{×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} +{\tt circmargin}\label{Dcmargin}. +%%By default, the boundary path +%%for a {\tt circleit} box is a circle large enough to surround the box +%%contents with a small safety margin controlled by the internal +%%variable\index{internal variables}\index{variables!internal} {\tt +%%circmargin}\label{Dcmargin}. +òÉÓ.~\ref{fig51} ÐÒÅÄÏÓÔÁ×ÌÑÅÔ ÂÁÚÏ×ÙÊ ÐÒÉÍÅÒ ÉÓÐÏÌØÚÏ×ÁÎÉÑ +{\tt bpath} Ó ÒÁÍËÁÍÉ {\tt circleit}. +%%Figure~\ref{fig51} gives a basic example +%%of the use of {\tt bpath} with {\tt circleit} boxes. + +\begin{figure}[htbp] +$$\begin{verbatim} +vardef drawshadowed(text t) = + fixsize(t); + forsuffixes s=t: + fill bpath.s shifted (1pt,-1pt); + unfill bpath.s; + drawboxed(s); + endfor +enddef; + +beginfig(51) +circleit.a(btex Box 1 etex); +circleit.b(btex Box 2 etex); +b.n = a.s - (0,20pt); +drawshadowed(a,b); +drawarrow a.s -- b.n; +endfig; +\end{verbatim} +\qquad \mathcenter{\includegraphics{manfig-ru-51}} $$ +\caption[ëÏÄ MetaPost É ÒÉÓÕÎÏË-ÒÅÚÕÌØÔÁÔ.] {ëÏÄ MetaPost É + ÒÉÓÕÎÏË-ÒÅÚÕÌØÔÁÔ. úÁÍÅÔØÔÅ, ÞÔÏ ÍÁËÒÏÓ {\tt drawshadowed}, + ÉÓÐÏÌØÚÕÅÍÙÊ ÚÄÅÓØ, ÎÅ ×ÈÏÄÉÔ × ÍÁËÒÏÐÁËÅÔ {\tt boxes.mp}.} +%%\caption[MetaPost code and the resulting figure.] {MetaPost code and +%% the resulting figure. Note that the {\tt drawshadowed} macro +%% used here is not part of the {\tt boxes.mp} macro package.} +\label{fig51} +\index{drawshadowed?\texttt{drawshadowed}} +\end{figure} + +ðÏÌÎÙÊ ÐÒÉÍÅÒ ÒÁÍÏË {\tt circleit} ÐÒÉ×ÏÄÉÔÓÑ ÎÁ ÒÉÓ.~\ref{fig52}. +%%A full example of {\tt circleit} boxes appears in Figure~\ref{fig52}. +ðÕÔÉ Ï×ÁÌØÎÏÊ ÇÒÁÎÉÃÙ ×ÏËÒÕÇ ``Start'' É ``Stop'' ÓÏÏÔ×ÅÔÓÔ×ÕÀÔ ÕÒÁ×ÎÅÎÉÑÍ +$$ \hbox{\tt aa.dx=aa.dy;} \quad \hbox{\rm É}\quad \hbox{\tt ee.dx=ee.dy} $$ +ÐÏÓÌÅ +$$ \hbox{\verb|circleit.ee(btex\strut Stop etex)|} + \quad\hbox{\rm É}\quad + \hbox{\verb|circleit.ee(btex\strut Stop etex)|}. +$$ +%%The oval boundary paths around ``Start'' and ``Stop'' are due to the equations +%%$$ \hbox{\tt aa.dx=aa.dy;} \quad {\rm and}\quad \hbox{\tt ee.dx=ee.dy} $$ +%%after +%%$$ \hbox{\verb|circleit.ee(btex\strut Stop etex)|} +%% \quad{\rm and}\quad +%% \hbox{\verb|circleit.ee(btex\strut Stop etex)|}. +%%$$ +ïÂÝÅÅ ÐÒÁ×ÉÌÏ × ÔÏÍ, ÞÔÏ {\tt bpath.}$c$ ×ÙÈÏÄÉÔ ËÒÕÇÌÙÍ, ÅÓÌÉ ×ÓÅ +$c${\tt.dx}, $c${\tt.dy} É $c\hbox{\tt.dx}-c\hbox{\tt.dy}$ ÎÅÉÚ×ÅÓÔÎÙ. +%%The general rule is that {\tt bpath.}$c$ comes out circular if +%%$c${\tt.dx}, $c${\tt.dy}, and $c\hbox{\tt.dx}-c\hbox{\tt.dy}$ are all +%%unknown. +éÎÁÞÅ ÍÁËÒÏÓÙ ×ÙÂÉÒÁÀÔ ÄÏÓÔÁÔÏÞÎÏ ÂÏÌØÛÏÊ Ï×ÁÌ ÄÌÑ ×ÍÅÝÅÎÉÑ ÄÁÎÎÏÊ +ËÁÒÔÉÎËÉ Ó ÐÒÅÄÏÈÒÁÎÑÀÝÉÍÉ ÏÔÓÔÕÐÁÍÉ {\tt +circmargin}\index{circmargin?\texttt{circmargin}}. +%%Otherwise, the macros select an oval big enough to contain the +%%given picture with the safety margin {\tt +%%circmargin}\index{circmargin?\texttt{circmargin}}. + + +\begin{figure}[htp] +$$\hbox{$\begin{verbatim} +vardef cuta(suffix a,b) expr p = + drawarrow p cutbefore bpath.a cutafter bpath.b; + point .5*length p of p +enddef; + +vardef self@# expr p = + cuta(@#,@#) @#.c{curl0}..@#.c+p..{curl0}@#.c enddef; + +beginfig(52); +verbatimtex \def\stk#1#2{$\displaystyle{\matrix{#1\cr#2\cr}}$} etex +circleit.aa(btex\strut Start etex); aa.dx=aa.dy; +circleit.bb(btex \stk B{(a|b)^*a} etex); +circleit.cc(btex \stk C{b^*} etex); +circleit.dd(btex \stk D{(a|b)^*ab} etex); +circleit.ee(btex\strut Stop etex); ee.dx=ee.dy; +numeric hsep; +bb.c-aa.c = dd.c-bb.c = ee.c-dd.c = (hsep,0); +cc.c-bb.c = (0,.8hsep); +xpart(ee.e - aa.w) = 3.8in; +drawboxed(aa,bb,cc,dd,ee); +label.ulft(btex$b$etex, cuta(aa,cc) aa.c{dir50}..cc.c); +label.top(btex$b$etex, self.cc(0,30pt)); +label.rt(btex$a$etex, cuta(cc,bb) cc.c..bb.c); +label.top(btex$a$etex, cuta(aa,bb) aa.c..bb.c); +label.llft(btex$a$etex, self.bb(-20pt,-35pt)); +label.top(btex$b$etex, cuta(bb,dd) bb.c..dd.c); +label.top(btex$b$etex, cuta(dd,ee) dd.c..ee.c); +label.lrt(btex$a$etex, cuta(dd,bb) dd.c..{dir140}bb.c); +label.bot(btex$a$etex, cuta(ee,bb) ee.c..tension1.3 ..{dir115}bb.c); +label.urt(btex$b$etex, cuta(ee,cc) ee.c{(cc.c-ee.c)rotated-15}..cc.c); +endfig; +\end{verbatim} +$} +\atop \vcenter{\vskip8pt\hbox{\includegraphics{manfig-ru-52}}} +$$ +\caption{ëÏÄ MetaPost É ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ÒÉÓÕÎÏË} +%%\caption{MetaPost code and the corresponding figure} +\label{fig52} +\end{figure} + + +\section{æÁÊÌÏ×ÙÅ ÞÔÅÎÉÅ É ÚÁÐÉÓØ} +%%\section{Reading and Writing Files} + +äÏÓÔÕÐ Ë ÆÁÊÌÁÍ --- ÜÔÏ ÏÄÎÏ ÉÚ ÎÏ×ÙÈ Ó×ÏÊÓÔ×, ××ÅÄÅÎÎÏÅ × ×ÅÒÓÉÀ~0.60 +ÑÚÙËÁ MetaPost. +%%File access was one of the new language features introduced in version~0.60 +%%of the MetaPost language. +îÏ×ÙÊ ÏÐÅÒÁÔÏÒ +$$ {\tt readfrom}\ \descr{ÉÍÑ ÆÁÊÌÁ} $$\index{readfrom?\texttt{readfrom}}\label{Dreadfrom}% +×ÏÚ×ÒÁÝÁÅÔ ÏÞÅÒÅÄÎÕÀ ÓÔÒÏËÕ ÉÚ ÉÍÅÎÏ×ÁÎÎÏÇÏ ×ÈÏÄÎÏÇÏ ÆÁÊÌÁ\index{ÆÁÊÌÙ!ÞÔÅÎÉÅ}. +%%A new operator +%%$$ {\tt readfrom}\ \descr{file name} $$\index{readfrom?\texttt{readfrom}}\label{Dreadfrom}% +%%returns a string giving the next line of input from the named +%%file\index{files!reading}. +\tdescr{éÍÑ ÆÁÊÌÁ} ÍÏÖÅÔ ÂÙÔØ ÌÀÂÙÍ ÐÅÒ×ÉÞÎÙÍ ×ÙÒÁÖÅÎÉÅÍ ÔÉÐÁ ÓÔÒÏËÁ. +%%The \tdescr{file name} can be any primary expression of type string. +åÓÌÉ ÆÁÊÌ ÚÁËÏÎÞÉÌÓÑ ÉÌÉ ÎÅ ÍÏÖÅÔ ÞÉÔÁÔØÓÑ, ÔÏ ÒÅÚÕÌØÔÁÔ ÞÔÅÎÉÑ --- ÜÔÏ ÓÔÒÏËÁ +ÉÚ ÏÄÎÏÇÏ ÎÕÌÅ×ÏÇÏ ÓÉÍ×ÏÌÁ. +%%If the file has ended or cannot be read, the +%%result is a string consisting of a single null character. +íÁËÒÏÐÁËÅÔ {\tt plain} ××ÏÄÉÔ ÉÍÑ {\tt EOF}\index{EOF?\texttt{EOF}}\label{Deof} +ÄÌÑ ÔÁËÏÊ ÓÔÒÏËÉ. +%%The preloaded {\tt plain} macro package introduces the name +%%{\tt EOF}\index{EOF?\texttt{EOF}}\label{Deof} for this string. +ðÏÓÌÅ ×ÏÚ×ÒÁÝÅÎÉÑ {\tt EOF} ÏÔ {\tt readfrom}, ÓÌÅÄÕÀÝÉÅ ÞÔÅÎÉÑ ÜÔÏÇÏ ÖÅ +ÆÁÊÌÁ ÐÒÉ×ÅÄÕÔ Ë ÅÇÏ ÐÏ×ÔÏÒÎÏÍÕ ÞÔÅÎÉÀ ÓÎÁÞÁÌÁ. +%%After +%%{\tt readfrom} has returned {\tt EOF}, additional reads from the same file +%%cause the file to be reread from the start. + +÷ÓÅ ÆÁÊÌÙ, ÏÔËÒÙÔÙÅ \ttt{readfrom}, ÞÔÏ ÅÝÅ ÎÅ ÓÞÉÔÁÎÙ ÐÏÌÎÏÓÔØÀ, +ÚÁËÒÙ×ÁÀÔÓÑ\index{ÆÁÊÌÙ!ÚÁËÒÙÔÉÅ} Á×ÔÏÍÁÔÉÞÅÓËÉ, ËÏÇÄÁ ÐÒÏÇÒÁÍÍÁ ÚÁËÁÎÞÉ×ÁÅÔ +×ÙÐÏÌÎÅÎÉÅ, ÈÏÔÑ ÓÕÝÅÓÔ×ÕÅÔ ËÏÍÁÎÄÁ +$${\tt closefrom}\ \descr{ÉÍÑ ÆÁÊÌÁ}$$% +\index{closefrom?\texttt{closefrom}}\label{Dclosefrom}% +ÄÌÑ Ñ×ÎÏÇÏ ÚÁËÒÙÔÉÑ ÆÁÊÌÏ×, ÏÔËÒÙÔÙÈ {\tt readfrom}. +%%All files opened by \ttt{readfrom} that have not completely been read +%%yet are closed\index{files!closing} automatically when the program +%%terminates, but there exists a command +%%$${\tt closefrom}\ \descr{file name}$$% +%%\index{closefrom?\texttt{closefrom}}\label{Dclosefrom}% +%%to close files opened by {\tt readfrom} explicitly. +òÁÚÕÍÎÏ Ñ×ÎÏ ÚÁËÒÙ×ÁÔØ ÆÁÊÌÙ, ËÏÔÏÒÙÅ ÎÅ ÎÕÖÎÏ ÓÞÉÔÙ×ÁÔØ ÐÏÌÎÏÓÔØÀ, Ô.~Å. ÄÏ +ÐÏÌÕÞÅÎÉÑ {\tt EOF}, ÐÏÔÏÍÕ ÞÔÏ × ÐÒÏÔÉ×ÎÏÍ ÓÌÕÞÁÅ ÔÁËÉÅ ÆÁÊÌÙ ÐÒÏÄÏÌÖÁÔ +ÉÓÐÏÌØÚÏ×ÁÔØ ×ÎÕÔÒÅÎÎÉÅ ÒÅÓÕÒÓÙ É ×ÏÚÍÏÖÎÏ ÏÂÕÓÌÏ×ÑÔ ÏÛÉÂËÕ +\ttt{capacity exceeded!}\footnote{ÅÍËÏÓÔØ ÐÒÅ×ÙÛÅÎÁ!} +%%It is wise to +%%manually close files you do not need to read completely (i.e. until {\tt +%% EOF} is returned) because otherwise such files will continue to use +%%internal resources and perhaps cause a \ttt{capacity exceeded!} error. + +ðÒÏÔÉ×ÏÐÏÌÏÖÎÏÓÔØÀ {\tt readfrom} Ñ×ÌÑÅÔÓÑ ËÏÍÁÎÄÁ +$$ {\tt write}\ \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\ {\tt to}\ \descr{ÉÍÑ ÆÁÊÌÁ} $$% +\index{write to?\texttt{write to}}\label{Dwrite}% +%%The opposite of {\tt readfrom} is the command +%%$$ {\tt write}\ \descr{string expression}\ {\tt to}\ \descr{file name} $$% +%%\index{write to?\texttt{write to}}\label{Dwrite}% +ïÎÁ ÐÉÛÅÔ\index{ÆÁÊÌÙ!ÚÁÐÉÓØ} ÓÔÒÏËÕ ÔÅËÓÔÁ × ÕËÁÚÁÎÎÙÊ ÆÁÊÌ ×Ù×ÏÄÁ, +ÏÔËÒÙ×ÁÑ ÓÎÁÞÁÌÁ ÆÁÊÌ, ÅÓÌÉ ÜÔÏ ÎÕÖÎÏ. +%%This writes\index{files!writing} a line of text to the specified output file, +%%opening the file first if necessary. +÷ÓÅ ÔÁËÉÅ ÆÁÊÌÙ ÚÁËÒÙ×ÁÀÔÓÑ\index{ÆÁÊÌÙ!ÚÁËÒÙÔÉÅ} Á×ÔÏÍÁÔÉÞÅÓËÉ, ËÏÇÄÁ ÐÒÏÇÒÁÍÍÁ +ÚÁ×ÅÒÛÁÅÔÓÑ. +%%All such files are +%%closed\index{files!closing} automatically when the program terminates. +ïÎÉ ÍÏÇÕÔ ÂÙÔØ ÔÁËÖÅ ÚÁËÒÙÔÙ Ñ×ÎÏ ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ {\tt EOF}\index{EOF?\texttt{EOF}} +ËÁË \tdescr{ÓÔÒÏËÏ×ÏÇÏ ×ÙÒÁÖÅÎÉÑ}. +%%They +%%can also be closed explicitly by using {\tt EOF}\index{EOF?\texttt{EOF}} +%%as the \tdescr{string expression}. +åÄÉÎÓÔ×ÅÎÎÙÊ ÓÐÏÓÏ ÕÚÎÁÔØ ÂÙÌÁ ÌÉ ËÏÍÁÎÄÁ {\tt write} ÕÓÐÅÛÎÏÊ × ÚÁËÒÙÔÉÉ +ÆÁÊÌÁ É ÉÓÐÏÌØÚÏ×ÁÎÉÉ {\tt readfrom} ÄÌÑ ÅÇÏ ÐÒÏÓÍÏÔÒÁ. +%%The only way to tell if a {\tt write} +%%command has succeeded is to close the file and use {\tt readfrom} to look +%%at it. + +\section{ðÏÌÅÚÎÙÅ ÓÒÅÄÓÔ×Á} +%%\section{Utility Routines} + +\index{ÐÏÌÅÚÎÙÅ ÓÒÅÄÓÔ×Á} +%%\index{utility routines} +\index{mplib?\texttt{mplib}} +\index{metapost/base?\texttt{metapost/base}} + +üÔÏÔ ÒÁÚÄÅÌ ÏÐÉÓÙ×ÁÅÔ ÎÅËÏÔÏÒÙÅ ÐÏÌÅÚÎÙÅ ÓÒÅÄÓÔ×Á, ×ËÌÀÞÅÎÎÙÅ × ËÁÔÁÌÏÇ +\texttt{mplib} ÉÅÒÁÒÈÉÉ ÒÁÚÒÁÂÏÔËÉ ÉÓÈÏÄÎÉËÏ×. +%%This section describes some of the utility routines included in the +%%\texttt{mplib} directory of the development source hierarchy. +âÕÄÕÝÉÅ ×ÅÒÓÉÉ ÜÔÏÊ ÄÏËÕÍÅÎÔÁÃÉÉ ÄÏÌÖÎÙ ÓÏÄÅÒÖÁÔØ ÂÏÌØÛÅ ÉÎÆÏÒÍÁÃÉÉ, ÐÏËÁ ÖÅ, +ÐÏÖÁÌÕÊÓÔÁ, ÞÉÔÁÊÔÅ ÆÁÊÌÙ ÉÓÈÏÄÎÉËÏ× --- ÂÏÌØÛÉÎÓÔ×Ï ÉÚ ÎÉÈ ÉÍÅÀÔ +ÏÂßÑÓÎÉÔÅÌØÎÙÅ ËÏÍÍÅÎÔÁÒÉÉ × ÎÁÞÁÌÅ. +%%Future +%%versions of this documentation may include more; meanwhile, please read +%%the source files, most have explanatory comments at the top. +éÓÈÏÄÎÉËÉ ÔÁËÖÅ ×ËÌÀÞÁÀÔ × ÄÉÓÔÒÉÂÕÔÉ×Ù ËÁË MetaPost, ÔÁË É × Â\'ÏÌØÛÉÅ \TeX, ËÁË +ÐÒÁ×ÉÌÏ, × ËÁÔÁÌÏÇ \texttt{texmf/metapost/base}. +%%They are +%%also included in the MetaPost and larger \TeX\ distributions, typically +%%in a \texttt{texmf/metapost/base} directory. + + +\subsection{\texttt{TEX.mp}} + +\label{dTEX} +\index{TEX.mp?\texttt{TEX.mp}} +\index{ÍÅÔËÉ Ó ÐÅÒÅÍÅÎÎÙÍ ÔÅËÓÔÏÍ} +%%\index{labels, with variable text} +\index{ÓÔÒÏËÏ×ÙÅ ×ÙÒÁÖÅÎÉÑ, ËÁË ÍÅÔËÉ} +%%\index{string expressions, as labels} + +\texttt{TEX.mp} ÐÒÅÄÏÓÔÁ×ÌÑÅÔ ÓÐÏÓÏ ÐÅÞÁÔÁÔØ ÔÅËÓÔ ÓÔÒÏËÏ×ÙÈ ×ÙÒÁÖÅÎÉÊ +MetaPost. +%%\texttt{TEX.mp} provides a way to typeset the text of a MetaPost string +%%expression. +ðÒÅÄÐÏÌÏÖÉÍ, ÎÁÐÒÉÍÅÒ, ÞÔÏ ×ÁÍ ÎÕÖÎÙ ÍÅÔËÉ × ÆÏÒÍÅ $n_0$, +$n_1$, \ldots, $n_{10}$ ÐÏ ÏÓÉ $x$. +%%Suppose, for example, you need labels of the form $n_0$, +%%$n_1$, \ldots, $n_{10}$ across the $x$ axis. +÷Ù ÍÏÖÅÔÅ ÓÄÅÌÁÔØ ÉÈ Ó (ÏÔÎÏÓÉÔÅÌØÎÙÍ) ÕÄÏÂÓÔ×ÏÍ Ó \texttt{TEX.mp}: +%%You can do this (relatively) conveniently with \texttt{TEX.mp}, as follows: +$$\begin{verbatim} +input TEX; +beginfig(100) + last := 10; + for i := 0 upto last: + label(TEX("$n_{" & decimal(i) & "}$"), (5mm*i,0)); + endfor + ... +endfig; +\end{verbatim} +$$ +÷ ÏÔÌÉÞÉÉ ÏÔ ÜÔÏÇÏ, ÂÁÚÏ×ÁÑ ËÏÍÁÎÄÁ \texttt{btex} (ÓÍ. ÓÔÒ.\ \pageref{Dbtex}) +ÐÅÞÁÔÁÅÔ ÔÅËÓÔ ÂÕË×ÁÌØÎÏ. +%%In contrast, the basic \texttt{btex} command (see p.\ \pageref{Dbtex}) +%%typesets verbatim text. +ðÏÌÕÞÁÅÔÓÑ, ÞÔÏ \texttt{btex~s~etex} ÐÅÞÁÔÁÅÔ ÌÉÔÅÒÁÌØÎÙÊ ÓÉÍ×ÏÌ `s', Á +\texttt{TEX(s)} ÐÅÞÁÔÁÅÔ ÚÎÁÞÅÎÉÅ ÔÅËÓÔÏ×ÏÊ ÐÅÒÅÍÅÎÎÏÊ MetaPost~$s$. +%%That is, \texttt{btex~s~etex} typesets the +%%literal character `s'; \texttt{TEX(s)} typesets the value of the +%%MetaPost text variable~$s$. + +\index{LaTeX?\LaTeX!ÎÁÂÏÒ ÍÅÔÏË Ó} ÷ ×ÅÒÓÉÀ 0.9 +\texttt{TEX.mp} ÄÏÂÁ×ÌÅÎÙ Ä×Á ÄÏÐÏÌÎÉÔÅÌØÎÙÈ ÓÒÅÄÓÔ×Á, ÐÏÚ×ÏÌÑÀÝÉÅ +ÉÓÐÏÌØÚÏ×ÁÔØ \LaTeX\ ÄÌÑ ÐÅÞÁÔÉ ÍÅÔÏË: \texttt{TEXPRE} É \texttt{TEXPOST}. +%%\index{LaTeX?\LaTeX!typesetting labels with} In version 0.9, +%%\texttt{TEX.mp} acquired two additional routines to facilitate using +%%\LaTeX\ to typeset labels: \texttt{TEXPRE} and \texttt{TEXPOST}. +éÈ ÚÎÁÞÅÎÉÑ ÚÁÐÏÍÉÎÁÀÔÓÑ É ×ËÌÀÞÁÀÔÓÑ ÓÏÏÔ×ÅÔÓÔ×ÅÎÎÏ ÐÅÒÅÄ É ÐÏÓÌÅ +ËÁÖÄÏÇÏ ×ÙÚÏ×Á \texttt{TEX}. +%%Their +%%values are remembered, and included before and after (respectively) each +%%call to \texttt{TEX}. +âÅÚ ÎÉÈ ËÁÖÄÙÊ ×ÙÚÏ× \texttt{TEX} ÐÅÞÁÔÁÅÔ ÓÏ×ÅÒÛÅÎÎÏ ÎÅÚÁ×ÉÓÉÍÏ. +%%Otherwise, each \texttt{TEX} call is effectively +%%typeset independently. +÷ÙÚÏ×Ù \texttt{TEX} ÔÁËÖÅ ÎÅ ×ÚÁÉÍÏÄÅÊÓÔ×ÕÀÔ Ó ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ +{\tt verbatimtex}\index{verbatimtex?\texttt{verbatimtex}} (ÓÔÒ.\ \pageref{Dverbatimtex}). +%%\texttt{TEX} calls also do not interfere with +%%uses of {\tt verbatimtex}\index{verbatimtex?\texttt{verbatimtex}} (p.\ \pageref{Dverbatimtex}). + +÷ÏÔ ÔÏÔ ÖÅ ÓÁÍÙÊ ÐÒÉÍÅÒ, ÞÔÏ É ×ÙÛÅ, ÎÏ Ó ÉÓÐÏÌØÚÏ×ÁÎÉÅÍ ËÏÍÁÎÄ +\LaTeX\ \verb|\(| É \verb|\)|: +%%Here's the same example as above, using the \LaTeX\ commands \verb|\(| +%%and \verb|\)|: + +$$\begin{verbatim} +input TEX; +TEXPRE("%&latex" & char(10) & "\documentclass{article}\begin{document}"); +TEXPOST("\end{document}"); +beginfig(100) + last := 10; + for i := 0 upto last: + label(TEX("\( n_{" & decimal(i) & "} \)"), (5mm*i,0)); + endfor + ... +endfig; +\end{verbatim} +$$ +ïÂßÑÓÎÅÎÉÑ: +%%Explanation: +\begin{itemize} + +\item +\texttt{\%\&latex} ÐÒÉ×ÏÄÉÔ Ë ×ÙÚÏ×Õ \LaTeX\ ×ÍÅÓÔÏ \TeX\ (ÓÍ. ÔÁËÖÅ ÎÉÖÅ). +%%The \texttt{\%\&latex} causes \LaTeX\ to be invoked instead of \TeX. +%%(See below, also.) +ïÓÎÏ×ÁÎÎÙÅ ÎÁ Web2C É MiKTeX ÄÉÓÔÒÉÂÕÔÉ×Ù \TeX, ËÁË ÍÉÎÉÍÕÍ, +ÐÏÎÉÍÁÀÔ \texttt{\%\&} ÓÐÅÃÉÆÉËÁÃÉÀ; ÓÍ., ÎÁÐÒÉÍÅÒ, ÄÏËÕÍÅÎÔÁÃÉÀ Web2C +ÄÌÑ ÄÅÔÁÌÅÊ, \url{http://tug.org/web2c}. +%%Web2C- and MiKTeX-based \TeX\ implementations, at +%%least, understand this \texttt{\%\&} specification; see, e.g., the Web2C +%%documentation for details, \url{http://tug.org/web2c}. +(éÎÆÏÒÍÁÃÉÑ Ï ÔÏÍ, ËÁË ÄÅÌÁÔØ ÜÔÏ ÖÅ × ÄÒÕÇÉÈ ÓÉÓÔÅÍÁÈ ÂÕÄÅÔ ×ÅÓØÍÁ ÐÒÉ×ÅÔÓÔ×Ï×ÁÔØÓÑ.) +%%(Information on +%%how to do the same with other systems would be most welcome.) + +\item +\texttt{char(10)} ÐÏÍÅÝÁÅÔ ÍÁÒËÅÒ ÎÏ×ÏÊ ÓÔÒÏËÉ (ÄÅÓÑÔÉÞÎÙÊ ËÏÄ ÓÉÍ×ÏÌÁ ASCII --- 10) +× ×Ù×ÏÄ. +%%The \texttt{char(10)} puts a newline (ASCII character code 10, decimal) +%%in the output. + +\item +\verb|\documentclass...| --- ÏÂÙÞÎÙÊ ÓÐÏÓÏ ÎÁÞÁÔØ ÄÏËÕÍÅÎÔ \LaTeX. +%%The \verb|\documentclass...| is the usual way to start a \LaTeX\ +%%document. + +\item +éÚ-ÚÁ ÐÏ×ÅÄÅÎÉÑ \texttt{mpto} \verb|TEXPOST("\end{document}")| ÎÅ Ñ×ÌÑÅÔÓÑ +ÓÔÒÏÇÏ ÎÅÏÂÈÏÄÉÍÙÍ, ÎÏ ÎÁÄÅÖÎÅÅ ÅÇÏ ×ËÌÀÞÁÔØ. +%%The \verb|TEXPOST("\end{document}")| is not strictly necessary, due to +%%the behavior of \texttt{mpto}, but it is safer to include it. + +\end{itemize} + +ë ÓÏÖÁÌÅÎÉÀ, ÉÎÓÔÒÕËÃÉÉ \TeX\ \verb|\special| ÉÓÞÅÚÁÀÔ × ÜÔÏÍ ÐÒÏÃÅÓÓÅ. +%%Unfortunately, \TeX\ \verb|\special| instructions vanish in this +%%process. +ðÏÜÔÏÍÕ ÎÅÌØÚÑ ÉÓÐÏÌØÚÏ×ÁÔØ ÐÁËÅÔÙ, ÐÏÄÏÂÎÙÅ \texttt{xcolor} +É \texttt{hyperref}. +%%So it is not possible to use packages such as \texttt{xcolor} +%%and \texttt{hyperref}. + +÷ ÓÌÕÞÁÅ, ÅÓÌÉ ×Ù ÌÀÂÏÐÙÔÎÙ, ÔÏ ÓÒÅÄÓÔ×Á \texttt{TEX.mp} ÒÅÁÌÉÚÕÀÔÓÑ ÏÞÅÎØ ÐÒÏÓÔÏ: +ÏÎÉ ÐÉÛÕÔ ËÏÍÁÎÄÙ \texttt{btex} ×Ï ×ÒÅÍÅÎÎÙÊ ÆÁÊÌ É ÚÁÔÅÍ ÉÓÐÏÌØÚÕÀÔ +\texttt{scantokens} (ÓÔÒ.\ \pageref{Dscantokens}) ÄÌÑ ÅÇÏ ÏÂÒÁÂÏÔËÉ. +%%In case you're curious, these routines are implemented very simply: they +%%write \texttt{btex} commands to a temporary file and then use +%%\texttt{scantokens} (p.\ \pageref{Dscantokens}) to process it. +íÅÈÁÎÉÚÍ \texttt{makempx} (ÓÔÒ.\ \pageref{Dmakempx}) ×ÙÐÏÌÎÑÅÔ ×ÓÀ ÒÁÂÏÔÕ +ÐÏ ÉÓÐÏÌØÚÏ×ÁÎÉÀ \TeX. +%%The +%%\texttt{makempx} mechanism (p.\ \pageref{Dmakempx}) does all the work of +%%running \TeX. + +íÁÇÉÞÅÓËÉÅ \verb|%&| × ÐÅÒ×ÏÊ ÓÔÒÏËÅ --- ÜÔÏ ÎÅ ÅÄÉÎÓÔ×ÅÎÎÙÊ ÐÕÔØ ÕËÁÚÁÔØ +ÎÁ ×ÙÚÏ× ÐÒÏÇÒÁÍÍÙ, ÏÔÌÉÞÎÏÊ ÏÔ (plain) \TeX. +%%The \verb|%&| magic on the first line is not the only way to specify +%%invoking a different program than (plain) \TeX. +úÄÅÓØ ÐÒÏÑ×ÌÑÅÔÓÑ ÐÒÅÉÍÕÝÅÓÔ×Ï ÍÁËÓÉÍÕÍÁ ÇÉÂËÏÓÔÉ: ÒÁÚÎÙÅ ËÏÎÓÔÒÕËÃÉÉ \texttt{TEX} +ÍÏÇÕÔ ÉÓÐÏÌØÚÏ×ÁÔØ ÒÁÚÎÙÅ ÐÒÏÃÅÓÓÏÒÙ \TeX. +%%It has the advantage of +%%maximum flexibility: different \texttt{TEX} constructs can use different +%%\TeX\ processors. +÷ÏÚÍÏÖÎÙ ÎÅ ÍÅÎÅÅ Ä×ÕÈ ÄÒÕÇÉÈ ÓÐÏÓÏÂÏ×: +%%But at least two other methods are possible: + +\begin{itemize} +\item õÓÔÁÎÏ×ËÁ ÐÅÒÅÍÅÎÎÙÊ ÓÒÅÄÙ \texttt{TEX} × \texttt{latex} ÉÌÉ +× ËÁËÏÊ-ÕÇÏÄÎÏ ÐÒÏÃÅÓÓÏÒ, ÖÅÌÁÅÍÙÊ ÄÌÑ ×ÙÚÏ×Á. +%%Set the environment variable \texttt{TEX} to \texttt{latex}---or +%%whatever processor you want to invoke. +(äÌÑ ÒÁÂÏÔÙ Ó ÆÒÁÇÍÅÎÔÁÍÉ \ConTeXt\ ÎÕÖÎÏ ×ÙÚÙ×ÁÔØ \ttt{texexec}.) +%%(To handle \ConTeXt\ fragments, +%%\ttt{texexec} could be used.) +üÔÏÔ ÓÐÏÓÏ ÕÄÏÂÅÎ, ËÏÇÄÁ ÐÉÛÅÔÓÑ ÓÃÅÎÁÒÉÊ ÉÌÉ ÉÄÅÔ ÒÁÂÏÔÁ ÎÁÄ ÐÒÏÅËÔÏÍ, +×ÓÅÇÄÁ ÔÒÅÂÕÀÝÉÍ \texttt{latex}. +%%This might be convenient when writing a +%%script, or working on a project that always requires \texttt{latex}. + +\item ÷ÙÚÏ× MetaPost Ó ÏÐÃÉÅÊ ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÉ \ttt{-tex=latex} (ÉÌÉ ÄÒÕÇÉÍ +ÐÒÏÃÅÓÓÏÒÏÍ, ËÏÎÅÞÎÏ). +%%Invoke MetaPost with the command-line option \ttt{-tex=latex} (or +%%whatever processor, of course). +üÔÏ ÍÏÖÅÔ ÂÙÔØ ÐÏÌÅÚÎÏ × Makefile ÉÌÉ ÐÒÉ ÅÄÉÎÓÔ×ÅÎÎÏÍ ÉÓÐÏÌÎÅÎÉÉ. +%%This might be useful from a Makefile, +%%or just a one-off run. +\end{itemize} + +\subsection{\texttt{mproof.tex}} + +\index{mproof.tex?\texttt{mproof.tex}} + +\texttt{mproof.tex} --- ÜÔÏ ÓÒÅÄÓÔ×Ï (plain) \TeX, Á ÎÅ MetaPost. +%%\texttt{mproof.tex} is a (plain) \TeX\ routine, not MetaPost at all. +ïÎÏ ÐÅÞÁÔÁÅÔ ÇÒÁÎËÉ ×Ù×ÏÄÁ MetaPost. +%%It writes a proof sheet for MetaPost output. +÷ÙÚÙ×ÁÊÔÅ ÅÇÏ ÐÒÉÍÅÒÎÏ ÔÁË: +%%Call it like this: +$$\hbox{\tt tex mproof {\sl ÉÍÑ-×ÙÈÏÄÎÏÇÏ-ÆÁÊÌÁ-MetaPost}}$$ +%%$$\hbox{\tt tex mproof {\sl MetaPost-output-filename}}$$ +úÁÔÅÍ ÒÁÂÏÔÁÊÔÅ Ó ÒÅÚÕÌØÔÉÒÕÀÝÉÍ ÆÁÊÌÏÍ \texttt{dvi} ÏÂÙÞÎÙÍ ÏÂÒÁÚÏÍ. +%%Then process the resulting \texttt{dvi} file as usual. + +\section{ïÔÌÁÄËÁ} +%%\section{Debugging} + +MetaPost ÕÎÁÓÌÅÄÏ×ÁÌ ÍÎÏÇÉÅ ×ÏÚÍÏÖÎÏÓÔÉ \MF\index{metafont?\MF} ÄÌÑ +ÉÎÔÅÒÁËÔÉ×ÎÏÊ ÏÔÌÁÄËÉ, ÚÎÁÞÉÔÅÌØÎÁÑ ÞÁÓÔØ ËÏÔÏÒÙÈ ÍÏÖÅÔ ÌÉÛØ ×ËÒÁÔÃÅ ÂÙÔØ ÕÐÏÍÑÎÕÔÁ +ÚÄÅÓØ. +%%MetaPost inherits from \MF\index{metafont?\MF} numerous facilities for +%%interactive debugging, most of which can only be mentioned briefly here. +âÏÌØÛÅ ÉÎÆÏÒÍÁÃÉÉ ÐÏ ÓÏÏÂÝÅÎÉÑÍ Ï ÏÛÉÂËÁÈ, ÏÔÌÁÄËÅ, ÇÅÎÅÒÁÃÉÉ +ÔÒÁÓÓÉÒÕÀÝÅÊ ÉÎÆÏÒÍÁÃÉÉ ÍÏÖÎÏ ÎÁÊÔÉ × {\sl The\ \MF book} \cite{kn:c}. +%%Further information on error messages, debugging, and generating tracing +%%information can be found in {\sl The\ \MF book} \cite{kn:c}. + +ðÒÅÄÐÏÌÏÖÉÍ, ÞÔÏ ×ÁÛ ×ÈÏÄÎÏÊ ÆÁÊÌ ÓÏÄÅÒÖÉÔ × ÓÔÒÏËÅ 17 +$$ \hbox{\tt draw z1-{}-z2;} $$ +ÂÅÚ ÐÒÅÄ×ÁÒÉÔÅÌØÎÏÇÏ ÏÐÒÅÄÅÌÅÎÉÑ ÚÎÁÞÅÎÉÊ {\tt z1} É {\tt z2}. +%%Suppose your input file says +%%$$ \hbox{\tt draw z1--z2;} $$ +%%on line 17 without first giving known values to {\tt z1} and {\tt z2}. +òÉÓ.~\ref{errmsg} ÐÏËÁÚÙ×ÁÅÔ ÔÏ, ÞÔÏ ÉÎÔÅÒÐÒÅÔÁÔÏÒ MetaPost ÐÅÞÁÔÁÅÔ ÎÁ +×ÁÛÅÍ ÔÅÒÍÉÎÁÌÅ, ËÏÇÄÁ ÎÁÈÏÄÉÔ ÏÛÉÂËÕ. +%%Figure~\ref{errmsg} shows what the MetaPost interpreter prints on your +%%terminal when it finds the error. +óÏÂÓÔ×ÅÎÎÏ ÓÏÏÂÝÅÎÉÅ Ï ÏÛÉÂËÅ --- ÜÔÏ ÓÔÒÏËÁ, ÎÁÞÉÎÁÀÝÁÑÓÑ Ó ``{\tt !}'', +ÓÌÅÄÕÀÝÉÅ ÛÅÓÔØ ÓÔÒÏË ÄÁÀÔ ËÏÎÔÅËÓÔ, ÔÏÞÎÏ ÐÏËÁÚÙ×ÁÀÝÉÊ, ÞÔÏ ÞÉÔÁÌÏÓØ Ó ××ÏÄÁ, +ËÏÇÄÁ ÂÙÌÁ ÏÂÎÁÒÕÖÅÎÁ ÏÛÉÂËÁ, Á ``{\tt ?}'' ÎÁ ÐÏÓÌÅÄÎÅÊ ÓÔÒÏËÅ --- ÜÔÏ +ÐÒÉÇÌÁÛÅÎÉÅ ÄÌÑ ×ÁÛÅÇÏ ÏÔ×ÅÔÁ. +%%The actual error message is the line +%%beginning with ``{\tt !}''; the next six lines give the context that +%%shows exactly what input was being read when the error was found; and +%%the ``{\tt ?}'' on last line is a prompt for your response. +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÓÏÏÂÝÅÎÉÅ Ï ÏÛÉÂËÅ ÇÏ×ÏÒÉÔ Ï ÎÅÏÐÒÅÄÅÌÅÎÎÏÊ ËÏÏÒÄÉÎÁÔÅ $x$, +ÜÔÏ ÚÎÁÞÅÎÉÅ ÐÅÞÁÔÁÅÔÓÑ × ÐÅÒ×ÏÊ ÓÔÒÏËÅ ÐÏÓÌÅ `{\tt >{}>}''. +%%Since the +%%error message talks about an undefined $x$~coordinate, this value is +%%printed on the first line after the ``{\tt >>}''. +÷ ÜÔÏÍ ÓÌÕÞÁÅ ËÏÏÒÄÉÎÁÔÁ $x$ ÐÁÒÙ {\tt z1} --- ÜÔÏ ÎÅÉÚ×ÅÓÔÎÁÑ +ÐÅÒÅÍÅÎÎÁÑ {\tt x1}, ÐÏÜÔÏÍÕ ÉÎÔÅÒÐÒÅÔÁÔÏÒ ÐÅÞÁÔÁÅÔ ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ +{\tt x1} ÔÏÞÎÏ ÔÁËÖÅ, ËÁË ÅÓÌÉ ÂÙ × ÜÔÏÍ ÍÅÓÔÅ ÂÙÌÏ +ÓËÁÚÁÎÏ\index{show?\texttt{show}} ``{\tt show x1}''. +%%In this case the +%%$x$~coordinate of {\tt z1} is just the unknown variable {\tt x1}, so the +%%interpreter prints the variable name {\tt x1} just as it would if it +%%were told to\index{show?\texttt{show}} ``{\tt show x1}'' at this point. + +\begin{figure}[htp] +$$\begin{verbatim} +>> x1 +! Undefined x coordinate has been replaced by 0. +<to be read again> + { +--->{ + curl1}..{curl1} +l.17 draw z1-- + z2; +? +\end{verbatim} +$$ +\caption{ðÒÉÍÅÒ ÓÏÏÂÝÅÎÉÑ Ï ÏÛÉÂËÅ.} +%%\caption{An example of an error message.} +\label{errmsg} +\end{figure} + +ìÉÓÔÉÎÇ ËÏÎÔÅËÓÔÁ ÍÏÖÅÔ ÐÏËÁÚÁÔØÓÑ ÓÌÅÇËÁ ÐÕÔÁÎÙÍ × ÐÅÒ×ÙÊ ÒÁÚ, ÎÏ ÏÎ +ÐÏ-ÐÒÏÓÔÕ ×ÙÄÁÅÔ ÎÅÓËÏÌØËÏ ÓÔÒÏË ÔÅËÓÔÁ, ÐÏËÁÚÙ×ÁÑ, ËÁË ÍÎÏÇÏ ÉÚ +ËÁÖÄÏÊ ÓÔÒÏËÉ ÂÙÌÏ ÕÖÅ ÓÞÉÔÁÎÏ. +%%The context listing may seem a little confusing at first, but it really just +%%gives a few lines of text showing how much of each line has been read so far. +ëÁÖÄÁÑ ÓÔÒÏËÁ ××ÏÄÁ ÐÅÞÁÔÁÅÔÓÑ × Ä×Å ÓÔÒÏËÉ, ÐÏÄÏÂÎÙÅ ÓÌÅÄÕÀÝÉÍ: +%%Each line of input is printed on two lines like this: +\begin{eqnarray*} + \descr{ÄÅÓËÒÉÐÔÏÒ}\ \hbox{õÖÅ ÓÞÉÔÁÎÎÙÊ ÔÅËÓÔ} \\ + && \hbox{ôÅËÓÔ ÄÌÑ ÓÞÉÔÙ×ÁÎÉÑ} +%%\descr{descriptor}\ \hbox{Text read so far} \\ +%% && \hbox{Text yet to be read} +\end{eqnarray*} +\tdescr{äÅÓËÒÉÐÔÏÒ} ÉÄÅÎÔÉÆÉÃÉÒÕÅÔ ÉÓÈÏÄÎÉË. +%%The \tdescr{descriptor} identifies the input source. +üÔÏ ÌÉÂÏ ÎÏÍÅÒ ÓÔÒÏËÉ ÔÉÐÁ ``{\tt l.17}'' ÄÌÑ ÓÔÒÏËÉ 17 ÔÅËÕÝÅÇÏ ÆÁÊÌÁ, ÌÉÂÏ +ÉÍÑ ÍÁËÒÏÓÁ ÐÅÒÅÄ ``{\tt ->}'', ÌÉÂÏ ÏÂßÑÓÎÑÀÝÁÑ ÆÒÁÚÁ × ÕÇÌÏ×ÙÈ ÓËÏÂËÁÈ. +%%It is either a +%%line number like ``{\tt l.17}'' for line 17 of the current file; or it +%%can be a macro name followed by ``{\tt ->}''; or it is a descriptive +%%phrase in angle brackets. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÚÎÁÞÅÎÉÅ ÌÉÓÔÉÎÇÁ ËÏÎÔÅËÓÔÁ ÎÁ ÒÉÓ.~\ref{errmsg}: ÉÎÔÅÒÐÒÅÔÁÔÏÒ +ÔÏÌØËÏ ÞÔÏ ÓÞÉÔÁÌ ÓÔÒÏËÕ 17 ×ÈÏÄÎÏÇÏ ÆÁÊÌÁ ÄÏ ``{\tt -{}-}'', ÒÁÓËÒÙÔÉÅ ÍÁËÒÏÓÁ +{\tt -{}-} ËÁË ÒÁÚ ÎÁÞÁÌÏÓØ É ÎÁÞÁÌØÎÙÊ ``\verb|{|'' ×ÏÚ×ÒÁÝÅÎ ÎÁÚÁÄ, ÐÏÚ×ÏÌÑÑ +××ÏÄ ÐÏÌØÚÏ×ÁÔÅÌÑ ÄÏ ÒÁÚÂÏÒÁ ÜÔÏÇÏ ÚÎÁËÁ. +%%Thus, the meaning of the context listing in +%%Figure~\ref{errmsg} is that the interpreter has just read line 17 of the +%%input file up to ``{\tt --},'' the expansion of the {\tt --} macro has +%%just started, and the initial ``\verb|{|'' has been reinserted to allow +%%for user input before scanning this token. + +óÒÅÄÉ ×ÏÚÍÏÖÎÙÈ ÏÔ×ÅÔÏ× ÎÁ ÐÒÉÇÌÁÛÅÎÉÅ {\tt ?} ÅÓÔØ ÔÁËÉÅ: +%%Among the possible responses to a {\tt ?} prompt are the following: +\begin{description} +\item[x] ÐÒÅËÒÁÝÁÅÔ ÉÓÐÏÌÎÅÎÉÅ --- ×Ù ÍÏÖÅÔÅ ÉÓÐÒÁ×ÉÔØ ×ÁÛ ×ÈÏÄÎÏÊ ÆÁÊÌ É ÐÅÒÅÚÁÐÕÓÔÉÔØ MetaPost. +%%\item[x] terminates the run so that you can fix your input file and start over. +\item[h] ÐÅÞÁÔÁÅÔ ÐÏÄÓËÁÚËÕ, ÚÁ ËÏÔÏÒÏÊ ÉÄÅÔ ÄÒÕÇÏÅ {\tt ?}-ÐÒÉÇÌÁÛÅÎÉÅ. +%%\item[h] prints a help message followed by another {\tt ?} prompt. +\item[\tdescr{return}] ÐÒÉ×ÏÄÉÔ ÉÎÔÅÒÐÒÅÔÁÔÏÒ Ë ÐÒÏÄÏÌÖÅÎÉÀ ÒÁÂÏÔÙ ÔÁË ÈÏÒÏÛÏ, ËÁË +ÏÎ ÓÍÏÖÅÔ. +%%\item[\tdescr{return}] causes the interpreter to proceed as best it can. +\item[?] ÐÅÞÁÔÁÅÔ ÓÐÉÓÏË ×ÏÚÍÏÖÎÙÈ ÏÐÃÉÊ, ÚÁ ËÏÔÏÒÙÍÉ ÓÌÅÄÕÅÔ {\tt ?}-ÐÒÉÇÌÁÛÅÎÉÅ. +%%\item[?] prints a listing of the options available, followed by another +%% {\tt ?} prompt. +\end{description} + +óÏÏÂÝÅÎÉÑ Ï ÏÛÉÂËÁÈ É ÏÔ×ÅÔÙ ÎÁ ËÏÍÁÎÄÙ {\tt show} ÔÁËÖÅ ÐÅÞÁÔÁÀÔÓÑ É × +ÆÁÊÌ-ÄÕÂÌÉËÁÔ\index{ÆÁÊÌÙ!ÄÕÂÌÉËÁÔ}, ÞØÅ ÉÍÑ ÐÏÌÕÞÁÅÔÓÑ ÉÚ ÉÍÅÎÉ +ÇÌÁ×ÎÏÇÏ ×ÈÏÄÎÏÇÏ ÆÁÊÌÁ ÉÚÍÅÎÅÎÉÅÍ ``{\tt .mp}'' ÎÁ ``{\tt .log}''. +%%Error messages and responses to {\tt show} commands are also written +%%into the transcript\index{files!transcript} file whose name is obtained +%%from the name of the main input file by changing ``{\tt .mp}'' to ``{\tt +%%.log}''. +ëÏÇÄÁ ×ÎÕÔÒÅÎÎÑÑ ÐÅÒÅÍÅÎÎÁÑ\index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} {\tt +tracingonline}\index{tracingonline?\texttt{tracingonline}} ÉÍÅÅÔ ÉÓÈÏÄÎÏÅ +ÚÎÁÞÅÎÉÅ ÎÏÌØ, ÔÏ ÎÅËÏÔÏÒÙÅ ËÏÍÁÎÄÙ {\tt show} ÐÅÞÁÔÁÀÔ Ó×ÏÉ ÒÅÚÕÌØÔÁÔÙ ×Ï +×ÓÅÈ ÄÅÔÁÌÑÈ ÔÏÌØËÏ × ÆÁÊÌ-ÄÕÂÌÉËÁÔ. +%%When the internal variable\index{internal +%%variables}\index{variables!internal} {\tt +%%tracingonline}\index{tracingonline?\texttt{tracingonline}} is at its +%%default value of zero, some {\tt show} commands print their results in +%%full detail only in the transcript file. + +ôÏÌØËÏ ÏÄÉÎ ÔÉÐ ËÏÍÁÎÄÙ {\tt show}\index{show?\texttt{show}} ÏÂÓÕÖÄÁÌÓÑ ÄÏ +ÓÉÈ ÐÏÒ: {\tt show} Ó ÒÁÚÄÅÌÅÎÎÙÍ ÚÁÐÑÔÙÍÉ ÓÐÉÓËÏÍ ×ÙÒÁÖÅÎÉÊ ÐÅÞÁÔÁÅÔ +ÓÉÍ×ÏÌØÎÏÅ ÐÒÅÄÓÔÁ×ÌÅÎÉÅ ÜÔÉÈ ×ÙÒÁÖÅÎÉÊ. +%%Only one type of {\tt show}\index{show?\texttt{show}} command has been +%%discussed so far: {\tt show} followed by a comma-separated list of +%%expressions prints symbolic representations of the expressions. + +ëÏÍÁÎÄÁ {\tt showtoken}\index{showtoken?\texttt{showtoken}}\label{Dshtok} +ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÁ ÄÌÑ ÐÏËÁÚÁ ÐÁÒÁÍÅÔÒÏ× É ÔÅËÓÔÁ ÚÁÍÅÎÙ ÍÁËÒÏÓÁ. +%%The {\tt showtoken}\index{showtoken?\texttt{showtoken}}\label{Dshtok} +%%command can be used to show the +%%parameters and replacement text of a macro. +ïÎÁ ÂÅÒÅÔ ÒÁÚÄÅÌÅÎÎÙÊ ÚÁÐÑÔÙÍÉ ÓÐÉÓÏË ÚÎÁËÏ× É ÉÄÅÎÔÉÆÉÃÉÒÕÅÔ ËÁÖÄÙÊ ÉÚ ÎÉÈ. +%%It takes a comma-separated list of tokens and identifies each one. +åÓÌÉ ÚÎÁË --- ÜÔÏ ÐÒÉÍÉÔÉ×, ÎÁÐÒÉÍÅÒ, +``\verb|showtoken +|'', ÔÏ ÏÎ ÐÏ-ÐÒÏÓÔÕ ÉÄÅÎÔÉÆÉÃÉÒÕÅÔÓÑ ÓÏÂÏÊ: +$$ \hbox{\verb|> +=+|} $$ +%%If the token is a primitive as in +%%``\verb|showtoken +|'' it is just identified as being itself: +%%$$ \hbox{\verb|> +=+|} $$ +ðÒÉÍÅÎÅÎÉÅ {\tt showtoken} Ë ÐÅÒÅÍÅÎÎÏÊ ÉÌÉ {\tt vardef}-ÍÁËÒÏÓÕ ÐÒÉ×ÅÄÅÔ Ë +$$ \hbox{\tt > } \descr{ÚÎÁË}\hbox{\tt =variable} $$ +%%Applying {\tt showtoken} to a variable or a {\tt vardef} macro yields +%%$$ \hbox{\tt > } \descr{token}\hbox{\tt =variable} $$ + +äÌÑ ÐÏÌÕÞÅÎÉÑ ÄÏÐÏÌÎÉÔÅÌØÎÏÊ ÉÎÆÏÒÍÁÃÉÉ Ï ÐÅÒÅÍÅÎÎÏÊ ÉÓÐÏÌØÚÕÊÔÅ +{\tt showvariable}\index{showvariable?\texttt{showvariable}}\label{Dshvar} +×ÍÅÓÔÏ {\tt showtoken}. +%%To get more information about a variable, use +%%{\tt showvariable}\index{showvariable?\texttt{showvariable}}\label{Dshvar} +%%instead of {\tt showtoken}. +áÒÇÕÍÅÎÔ Ë {\tt showvariable} --- ÜÔÏ ÒÁÚÄÅÌÅÎÎÙÊ ÚÁÐÑÔÙÍÉ ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ +ÚÎÁËÏ×, Á ÅÅ ÒÅÚÕÌØÔÁÔ --- ÜÔÏ ÏÐÉÓÁÎÉÅ ×ÓÅÈ ÐÅÒÅÍÅÎÎÙÈ, ÞØÉ ÉÍÅÎÁ ÎÁÞÉÎÁÀÔÓÑ Ó +ÏÄÎÏÇÏ ÉÚ ÚÎÁËÏ× ÉÚ ÓÐÉÓËÁ. +%%The +%%argument to {\tt showvariable} is a comma-separated list of symbolic tokens +%%and the result is a description of all the variables whose names begin with +%%one of the listed tokens. +üÔÏ ÒÁÂÏÔÁÅÔ ÄÁÖÅ ÄÌÑ vardef-ÍÁËÒÏÓÏ×. +%%This even works for {\tt vardef} macros. +îÁÐÒÉÍÅÒ, {\tt showvariable z} ÐÅÞÁÔÁÅÔ +$$ \hbox{\verb|z@#=macro:->begingroup(x(SUFFIX2),y(SUFFIX2))endgroup|} $$ +%%For example, {\tt showvariable z} yields +%%$$ \hbox{\verb|z@#=macro:->begingroup(x(SUFFIX2),y(SUFFIX2))endgroup|} $$ + +åÓÔØ ÅÝÅ ËÏÍÁÎÄÁ {\tt +showdependencies}\index{showdependencies?\texttt{showdependencies}}\label{Dshdep}, +ÎÅ ÉÍÅÀÝÁÑ ÁÒÇÕÍÅÎÔÏ× É ÐÅÞÁÔÁÀÝÁÑ ÓÐÉÓÏË ×ÓÅÈ {\em ÚÁ×ÉÓÉÍÙÈ} ÐÅÒÅÍÅÎÎÙÈ É ÔÏ, ËÁË +ÌÉÎÅÊÎÙÅ ÕÒÁ×ÎÅÎÉÑ ÚÁÄÁÎÎÙÅ ÒÁÎÅÅ ÄÅÌÁÀÔ ÉÈ ÚÁ×ÉÓÉÍÙÍÉ Ó ÄÒÕÇÉÍÉ ÐÅÒÅÍÅÎÎÙÍÉ. +%%There is also a {\tt +%%showdependencies}\index{showdependencies?\texttt{showdependencies}}\label{Dshdep} +%%command that takes no arguments and prints a list of all {\em dependent} +%%variables and how the linear equations given so far make them depend on +%%other variables. +ôÁËÉÍ ÏÂÒÁÚÏÍ, ÐÏÓÌÅ +$$ \hbox{\tt z2-z1=(5,10); z1+z2=(a,b);} $$ +{\tt showdependencies} ÎÁÐÅÞÁÔÁÅÔ ÔÏ, ÞÔÏ ÐÏËÁÚÁÎÏ ÎÁ ÒÉÓ.~\ref{shdep}. +%%Thus after +%%$$ \hbox{\tt z2-z1=(5,10); z1+z2=(a,b);} $$ +%%{\tt showdependencies} prints what is shown in Figure~\ref{shdep}. +üÔÏ ÍÏÖÅÔ ÂÙÔØ ÐÏÌÅÚÎÙÍ ÐÒÉ ÏÔ×ÅÔÅ ÎÁ ×ÏÐÒÏÓ ÔÉÐÁ ``þÔÏ ÚÎÁÞÉÔ, ÞÔÏ +`{\tt !\ Undefined x coordinate}?'\footnote{ëÏÏÒÄÉÎÁÔÁ x --- +ÎÅÏÐÒÅÄÅÌÅÎÁ} --- Ñ ÄÕÍÁÀ, ÞÔÏ ÐÒÉ×ÅÄÅÎÎÙÅ ÒÁÎÅÅ ÕÒÁ×ÎÅÎÉÑ ÏÐÒÅÄÅÌÑÀÔ +{\tt x1}.'' +%%This could +%%be useful in answering a question like ``What does it mean +%%`{\tt !\ Undefined x coordinate}?' +%%I thought the equations given so far would determine {\tt x1}.'' + +\begin{figure}[htp] +$$\begin{verbatim} +x2=0.5a+2.5 +y2=0.5b+5 +x1=0.5a-2.5 +y1=0.5b-5 +\end{verbatim} +$$ +\caption{òÅÚÕÌØÔÁÔ {\tt z2-z1=(5,10); z1+z2=(a,b); showdependencies;}} +%%\caption{The result of {\tt z2-z1=(5,10); z1+z2=(a,b); showdependencies;}} +\label{shdep} +\end{figure} + +åÓÌÉ ×ÓÅ ÜÔÏ ÎÅ ÐÒÉ×ÏÄÉÔ Ë ÕÓÐÅÈÕ, ÔÏ ÅÓÔØ ÅÝÅ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÊ ÍÁËÒÏÓ +{\tt tracingall}\index{tracingall?\texttt{tracingall}}\label{Dtall}, +ÐÒÉ×ÏÄÑÝÉÊ ÉÎÔÅÒÐÒÅÔÁÔÏÒ Ë ÐÅÞÁÔÉ ÄÅÔÁÌØÎÏÇÏ ÏÔÞÅÔÁ ÏÂÏ ×ÓÅÍ, ÞÔÏ ÏÎ +ÄÅÌÁÅÔ. +%%When all else fails, the predefined macro {\tt +%%tracingall}\index{tracingall?\texttt{tracingall}}\label{Dtall} causes +%%the interpreter to print a detailed listing of everything it is doing. +÷ÓÌÅÄÓÔ×ÉÅ ÔÏÇÏ, ÞÔÏ ÔÒÁÓÓÉÒÕÀÝÁÑ ÉÎÆÏÒÍÁÃÉÑ ÞÁÓÔÏ ÉÍÅÅÔ ×ÅÓØÍÁ ÂÏÌØÛÏÊ +ÒÁÚÍÅÒ, ×ÏÚÍÏÖÎÏ ÂÕÄÅÔ ÌÕÞÛÅ ÉÓÐÏÌØÚÏ×ÁÔØ ÍÁËÒÏÓ {\tt +loggingall}\index{loggingall?\texttt{loggingall}}\label{Dlogall}, +ÐÒÏÉÚ×ÏÄÑÝÉÊ ÔÕ ÖÅ ÓÁÍÕÀ ÉÎÆÏÒÍÁÃÉÀ, ÎÏ ÔÏÌØËÏ ÄÌÑ ÚÁÐÉÓÉ × +ÆÁÊÌ-ÄÕÂÌÉËÁÔ\index{ÆÁÊÌÙ!ÄÕÂÌÉËÁÔ}. +%%Since the tracing information is often quite voluminous, it may be +%%better to use the {\tt +%%loggingall}\index{loggingall?\texttt{loggingall}}\label{Dlogall} macro +%%that produces the same information but only writes it in the +%%transcript\index{files!transcript} file. +åÓÔØ ÅÝÅ ÍÁËÒÏÓ {\tt +tracingnone}\index{tracingnone?\texttt{tracingnone}}\label{Dtnone}, +ÏÔËÌÀÞÁÀÝÉÊ ×ÓÅ ÒÁÓÐÅÞÁÔËÉ ÐÏ ÔÒÁÓÓÉÒÏ×ËÅ. +%%There is also a {\tt +%%tracingnone}\index{tracingnone?\texttt{tracingnone}}\label{Dtnone} macro +%%that turns off all the tracing output. + +÷Ù×ÏÄ ÔÒÁÓÓÉÒÏ×ËÉ ËÏÎÔÒÏÌÉÒÕÅÔÓÑ ÍÎÏÖÅÓÔ×ÏÍ ×ÎÕÔÒÅÎÎÉÈ +ÐÅÒÅÍÅÎÎÙÈ\index{×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ}, +ÐÒÉ×ÏÄÉÍÙÈ ÄÁÌÅÅ. +%%Tracing output is controlled by the set of internal +%%variables\index{internal variables}\index{variables!internal} summarized +%%below. +ëÏÇÄÁ ÌÀÂÏÊ ÉÚ ÜÔÉÈ ÐÅÒÅÍÅÎÎÙÈ ÚÁÄÁÀÔ ÐÏÌÏÖÉÔÅÌØÎÏÅ ÚÎÁÞÅÎÉÅ, ÔÏ ÜÔÉÍ +ÕÓÔÁÎÁ×ÌÉ×ÁÅÔÓÑ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÁÑ ÆÏÒÍÁ ÔÒÁÓÓÉÒÏ×ËÉ. +%%When any one of these variables is given a positive value, the +%%corresponding form of tracing is turned on. +úÄÅÓØ ÐÒÉ×ÅÄÅÎÏ ÍÎÏÖÅÓÔ×Ï ÐÅÒÅÍÅÎÎÙÈ ÔÒÁÓÓÉÒÏ×ËÉ É ÔÏ, ÞÔÏ ÓÌÕÞÁÅÔÓÑ, ËÏÇÄÁ +ËÁÖÄÁÑ ÉÚ ÎÉÈ ÓÔÁÎÏ×ÉÔÓÑ ÐÏÌÏÖÉÔÅÌØÎÏÊ. +%%Here is the set of tracing +%%variables and what happens when each of them is positive: +\begin{description} +\item[{\tt tracingcapsules}]\index{tracingcapsules?\texttt{tracingcapsules}}\label{Dtcapsules}% +ÐÏËÁÚÙ×ÁÅÔ ÚÎÁÞÅÎÉÑ ×ÒÅÍÅÎÎÙÈ ËÏÌÉÞÅÓÔ× (ËÁÐÓÕÌ), ËÏÇÄÁ ÏÎÉ ÓÔÁÎÏ×ÑÔÓÑ ÉÚ×ÅÓÔÎÙÍÉ. +%%\item[{\tt tracingcapsules}]\index{tracingcapsules?\texttt{tracingcapsules}}\label{Dtcapsules}% +%%shows the values of temporary quantities (capsules) when they become known. +% +\item[{\tt tracingchoices}]\index{tracingchoices?\texttt{tracingchoices}}\label{Dtchoices}% +ÐÏËÁÚÙ×ÁÅÔ ËÏÎÔÒÏÌØÎÙÅ ÔÏÞËÉ âÅÚØÅ\index{ÕÐÒÁ×ÌÑÀÝÉÅ ÔÏÞËÉ} ÎÁ ËÁÖÄÏÍ ÐÕÔÉ, ÇÄÅ ÏÎÉ +×ÙÂÉÒÁÀÔÓÑ. % +%%\item[{\tt tracingchoices}]\index{tracingchoices?\texttt{tracingchoices}}\label{Dtchoices}% +%%shows the B\'ezier control\index{control points} points of each new path +%%when they are chosen. % +\item[{\tt tracingcommands}]\index{tracingcommands?\texttt{tracingcommands}}\label{Dtcommands}% +ÐÏËÁÚÙ×ÁÅÔ ËÏÍÁÎÄÙ ÐÅÒÅÄ ÉÈ ×ÙÐÏÌÎÅÎÉÅÍ. õÓÔÁÎÏ×ËÁ × ${}>1$ ÔÁËÖÅ ÐÏËÁÖÅÔ ÐÒÏ×ÅÒËÉ +{\tt if}\index{if?\texttt{if}} É ÃÉËÌÙ ÄÏ ÉÈ ÒÁÓËÒÙÔÉÑ; +ÕÓÔÁÎÏ×ËÁ × ${}>2$ ÐÏËÁÖÅÔ ÁÌÇÅÂÒÁÉÞÅÓËÉÅ ÏÐÅÒÁÃÉÉ ÄÏ ÉÈ ×ÙÐÏÌÎÅÎÉÑ. +%%\item[{\tt tracingcommands}]\index{tracingcommands?\texttt{tracingcommands}}\label{Dtcommands}% +%%shows the commands before they are performed. A setting ${}>1$ also shows +%%{\tt if}\index{if?\texttt{if}} tests and loops before they are expanded; +%%a setting ${}>2$ shows algebraic operations before they are performed. +% +\item[{\tt tracingequations}]\index{tracingequations?\texttt{tracingequations}}\label{Dtequations}% +ÐÏËÁÚÙ×ÁÅÔ ËÁÖÄÕÀ ÐÅÒÅÍÅÎÎÕÀ, ËÏÇÄÁ ÏÎÁ ÓÔÁÎÏ×ÉÔÓÑ ÉÚ×ÅÓÔÎÏÊ. +%%\item[{\tt %%tracingequations}]\index{tracingequations?\texttt{tracingequations}}\label{Dtequations}% +%%shows each variable when it becomes known. +% +\item[{\tt tracinglostchars}]\index{tracinglostchars?\texttt{tracinglostchars}}\label{Dtlostchars}% +ÐÒÅÄÕÐÒÅÖÄÁÅÔ Ï ÓÉÍ×ÏÌÁÈ, ÏÔÓÕÔÓÔ×ÕÀÝÉÈ × ËÁÒÔÉÎËÅ, ÉÚ-ÚÁ ÉÈ ÏÔÓÕÔÓÔ×ÉÑ × ÛÒÉÆÔÅ, ÉÓÐÏÌØÚÕÅÍÏÍ +ÄÌÑ ÐÅÞÁÔÉ ÍÅÔÏË. +%%\item[{\tt tracinglostchars}]\index{tracinglostchars?\texttt{tracinglostchars}}\label{Dtlostchars}% +%%warns about characters omitted from a picture because they are not in the font +%%being used to typeset labels. +% +\item[{\tt tracingmacros}]\index{tracingmacros?\texttt{tracingmacros}}\label{Dtmacros}% +ÐÅÞÁÔÁÅÔ ÍÁËÒÏÓÙ ÄÏ ÉÈ ÒÁÓËÒÙÔÉÑ. +%%\item[{\tt tracingmacros}]\index{tracingmacros?\texttt{tracingmacros}}\label{Dtmacros}% +%%shows macros before they are expanded. +% +\item[{\tt tracingoutput}]\index{tracingoutput?\texttt{tracingoutput}}\label{Dtoutput}% +ÐÅÞÁÔÁÅÔ ËÁÒÔÉÎËÉ ÐÒÉ ÉÈ ÏÔÐÒÁ×ËÅ × PostScript-ÆÁÊÌÙ. +%%\item[{\tt tracingoutput}]\index{tracingoutput?\texttt{tracingoutput}}\label{Dtoutput}% +%%shows pictures as they are being shipped out as PostScript files. +% +\item[{\tt tracingrestores}]\index{tracingrestores?\texttt{tracingrestores}}\label{Dtrestores}% +ÐÏËÁÚÙ×ÁÅÔ ÓÉÍ×ÏÌÙ É ×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ ÐÒÉ ÉÈ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÉ × ËÏÎÃÅ ÇÒÕÐÐÙ. +%%\item[{\tt tracingrestores}]\index{tracingrestores?\texttt{tracingrestores}}\label{Dtrestores}% +%%shows symbols and internal variables as they are being restored at the end +%%of a group. +% +\item[{\tt tracingspecs}]\index{tracingspecs?\texttt{tracingspecs}}\label{Dtspecs}% +ÐÏËÁÚÙ×ÁÅÔ ×ÙÄÅÌÅÎÉÑ, ÇÅÎÅÒÉÒÕÅÍÙÅ ÐÒÉ ÒÉÓÏ×ÁÎÉÉ ÍÎÏÇÏÕÇÏÌØÎÙÍ ÐÅÒÏÍ\index{ÐÅÒØÑ!ÍÎÏÇÏÕÇÏÌØÎÙÅ}. +%%\item[{\tt tracingspecs}]\index{tracingspecs?\texttt{tracingspecs}}\label{Dtspecs}% +%%shows the outlines generated when drawing with a +%%polygonal pen\index{pens!polygonal}. +% +\item[{\tt tracingstats}]\index{tracingstats?\texttt{tracingstats}}\label{Dtstats} +× ËÏÎÃÅ ÒÁÂÏÔÙ ÐÅÞÁÔÁÅÔ × ÆÁÊÌ-ÄÕÂÌÉËÁÔ Ï ÔÏÍ, ËÁË ÍÎÏÇÏ ÏÇÒÁÎÉÞÅÎÎÙÈ ÒÅÓÕÒÓÏ× +ÉÎÔÅÒÐÒÅÔÁÔÏÒÁ MetaPost ÂÙÌÏ ÉÓÐÏÌØÚÏ×ÁÎÏ. +%%\item[{\tt tracingstats}]\index{tracingstats?\texttt{tracingstats}}\label{Dtstats} +%%shows in the transcript file at the end of the job how many of the +%%MetaPost interpreter's limited resources were used. +\end{description} + +\section*{ðÒÉÚÎÁÔÅÌØÎÏÓÔØ} +%%\section*{Acknowledgement} + +ñ ÒÁÄ ÐÏÂÌÁÇÏÄÁÒÉÔØ äÏÎÁÌØÄÁ ëÎÕÔÁ ÚÁ ×ÏÚÍÏÖÎÏÓÔØ ÐÒÏÄÅÌÁÔØ ÜÔÕ ÒÁÂÏÔÕ --- +ÚÁ ÒÁÚ×ÉÔÉÅ \MF\ É ÐÏÍÅÝÅÎÉÑ ÅÇÏ × ÏÔËÒÙÔÙÊ ÄÏÓÔÕÐ. +%%I would like to thank Don Knuth for making this work possible by +%%developing \MF\ and placing it in the public domain. +ñ ÔÁËÖÅ × ÄÏÌÇÕ ÐÅÒÅÄ ÎÉÍ ÚÁ ÐÏÌÅÚÎÙÅ ÐÒÅÄÌÏÖÅÎÉÑ, ÏÓÏÂÅÎÎÏ × +Ó×ÑÚÉ Ó ÏÂÒÁÂÏÔËÏÊ ×ËÌÀÞÁÅÍÏÇÏ ÍÁÔÅÒÉÁÌÁ \TeX. +%%I am also indebted +%%to him for helpful suggestions, particularly with regard to the +%%treatment of included \TeX\ material. + + +\appendix +\section{óÐÒÁ×ÏÞÎÏÅ ÒÕËÏ×ÏÄÓÔ×Ï} +%%\section{Reference Manual} + +\let\svtopfrac=\topfraction % prepare to restore values at end of this appendix +\let\svtxtfrac=\textfraction % grouping would fail because \setcounter is global +\newcounter{svtopnum} +\newcounter{svtotnum} +\setcounter{svtopnum}{\value{topnumber}} +\setcounter{svtotnum}{\value{totalnumber}} + +\renewcommand\topfraction{1.0} % set values to allow *lots* of figures and tables +\renewcommand\textfraction{0.0} +\setcounter{topnumber}{10} +\setcounter{totalnumber}{10} + +ôÁÂÌÉÃÙ \ref{ivartab}--\ref{pseudotab} ÓÕÍÍÉÒÕÀÔ ×ÓÔÒÏÅÎÎÙÅ ×ÏÚÍÏÖÎÏÓÔÉ +Plain MetaPost É ×ÏÚÍÏÖÎÏÓÔÉ, ÏÐÒÅÄÅÌÅÎÎÙÅ × ÆÁÊÌÅ Ó ÍÁËÒÏÓÁÍÉ {\tt +boxes.mp}\index{boxes.mp?\texttt{boxes.mp}}. +%%Tables \ref{ivartab}--\ref{pseudotab} summarize the built-in features of +%%Plain MetaPost and the features defined in the {\tt +%%boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} macro file. +ëÁË ÏÂßÑÓÎÑÌÏÓØ × ÒÁÚÄÅÌÅ ~\ref{boxessec}, ÆÁÊÌ Ó ÍÁËÒÏÓÁÍÉ {\tt boxes.mp} +ÎÅ ×ËÌÀÞÁÅÔÓÑ Á×ÔÏÍÁÔÉÞÅÓËÉ É ÍÁËÒÏÓÙ ÉÚ ÎÅÇÏ ÎÅÄÏÓÔÕÐÎÙ ÄÏ ÔÅÈ ÐÏÒ, ÐÏËÁ +×Ù ÎÅ ÚÁÐÒÏÓÉÔÅ ÉÈ ËÏÍÁÎÄÏÊ\index{input?\texttt{input}} +$$ \hbox{\tt input boxes} $$ +%%As explained in +%%Section~\ref{boxessec}, the {\tt boxes.mp} macro file is not +%%automatically preloaded and the macros defined there are not accessible +%%until you ask for them via the command\index{input?\texttt{input}} +%%$$ \hbox{\tt input boxes} $$ + +÷ÏÚÍÏÖÎÏÓÔÉ, ÚÁ×ÉÓÑÝÉÅ ÏÔ {\tt boxes.mp} ÏÔÍÅÞÅÎÙ ÓÉÍ×ÏÌÁÍÉ \bx. +%%Features that depend on {\tt boxes.mp} are marked by \bx\ symbols. +÷ÏÚÍÏÖÎÏÓÔÉ ÉÚ ÍÁËÒÏÐÁËÅÔÁ Plain\index{ÍÁËÒÏÓÙ Plain} ÏÔÍÅÞÅÎÙ ÓÉÍ×ÏÌÁÍÉ +\pl, Á ÐÒÉÍÉÔÉ×Ù MetaPost ÐÒÉ×ÏÄÑÔÓÑ ÂÅÚ \bx\ ÉÌÉ \pl. +%%Features from the Plain\index{Plain macros} macro package are marked by +%%\pl\ symbols, and MetaPost primitives are not marked by \bx\ or \pl. +òÁÚÎÉÃÁ ÍÅÖÄÕ ÐÒÉÍÉÔÉ×ÁÍÉ É ÍÁËÒÏÓÁÍÉ ÉÚ plain ÍÏÖÅÔ ÉÇÎÏÒÉÒÏ×ÁÔØÓÑ +ÓÌÕÞÁÊÎÙÍ ÐÏÌØÚÏ×ÁÔÅÌÅÍ, ÎÏ ×ÁÖÎÏ ÐÏÍÎÉÔØ, ÞÔÏ ×ÏÚÍÏÖÎÏÓÔÉ Ó ÍÅÔËÏÊ \bx\ +ÍÏÇÕÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÙ ÔÏÌØËÏ ÐÏÓÌÅ ÞÔÅÎÉÑ ÆÁÊÌÁ {\tt +boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} Ó ÍÁËÒÏÓÁÍÉ. +%%The distinction between primitives and plain macros can be ignored by +%%the casual user, but it is important to remember that features marked by +%%a \bx\ can only be used after reading in the {\tt +%%boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} macro file. + +ôÁÂÌÉÃÙ × ÜÔÏÍ ÐÒÉÌÏÖÅÎÉÉ ÐÒÉ×ÏÄÑÔ ÉÍÑ ËÁÖÄÏÊ ×ÏÚÍÏÖÎÏÓÔÉ, ÎÏÍÅÒ ÓÔÒÁÎÉÃÙ, +ÇÄÅ ÏÎÁ ÏÂßÑÓÎÑÅÔÓÑ, É ËÒÁÔËÏÅ ÏÐÉÓÁÎÉÅ. +%%The tables in this appendix give the name of each feature, the page +%%number where it is explained, and a short description. +îÅÂÏÌØÛÏÅ ÞÉÓÌÏ Ó×ÏÊÓÔ× ÎÉÇÄÅ ÎÅ ÏÂßÑÓÎÑÌÏÓØ É ÏÎÉ ÎÅ ÉÍÅÀÔ ÎÏÍÅÒÏ× ÓÔÒÁÎÉÃ. +%%A few features +%%are not explained elsewhere and have no page number listed. +üÔÉ ×ÏÚÍÏÖÎÏÓÔÉ ÓÕÝÅÓÔ×ÕÀÔ, × ÏÓÎÏ×ÎÏÍ, ÄÌÑ ÓÏ×ÍÅÓÔÉÍÏÓÔÉ Ó +\MF\index{metafont?\MF} É ÐÒÅÄÐÏÌÁÇÁÀÔÓÑ ÓÁÍÏÏÂßÑÓÎÑÀÝÉÍÉ. +%%These +%%features exist primarily for compatibility with \MF\index{metafont?\MF} +%%and are intended to be self-explanatory. +îÅËÏÔÏÒÙÅ ÏÐÒÅÄÅÌÅÎÎÙÅ ×ÏÚÍÏÖÎÏÓÔÉ \MF\ ÐÏÌÎÏÓÔØÀ ÏÔÓÕÔÓÔ×ÕÀÔ ÉÚ-ÚÁ +ÏÇÒÁÎÉÞÅÎÎÏÇÏ ÉÎÔÅÒÅÓÁ Ë ÎÉÍ ÐÏÌØÚÏ×ÁÔÅÌÅÊ MetaPost É/ÉÌÉ ÉÚ-ÚÁ ÔÒÅÂÕÅÍÙÈ +ÄÌÉÎÎÙÈ ÏÂßÑÓÎÅÎÉÊ. +%%Certain other features from +%%\MF\ are omitted entirely because they are of limited interest to the +%%MetaPost users and/or would require long explanations. +÷ÓÅ ÏÎÉ ÄÏËÕÍÅÎÔÉÒÏ×ÁÎÙ × {\sl The \MF book} \cite{kn:c} ËÁË ÏÂßÑÓÎÅÎÏ × +ÐÒÉÌÏÖÅÎÉÉ~\ref{MPvsMF}. +%%All of these are +%%documented in {\sl The \MF book} \cite{kn:c} as explained in +%%Appendix~\ref{MPvsMF}. + +ôÁÂÌÉÃÁ~\ref{ivartab} ÐÅÒÅÞÉÓÌÑÅÔ ×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ Ó ÞÉÓÌÏ×ÙÍÉ ÚÎÁÞÅÎÉÑÍÉ. +%%Table~\ref{ivartab} lists internal variables that take on numeric values. +ôÁÂÌÉÃÁ~\ref{pvartab} ÐÅÒÅÞÉÓÌÑÅÔ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÅ ÐÅÒÅÍÅÎÎÙÅ ÄÒÕÇÉÈ ÔÉÐÏ×. +%%Table~\ref{pvartab} lists predefined variables of other types. +ôÁÂÌÉÃÁ~\ref{consttab} ÐÅÒÅÞÉÓÌÑÅÔ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÅ ËÏÎÓÔÁÎÔÙ. +%%Table~\ref{consttab} lists predefined constants. +îÅËÏÔÏÒÙÅ ÉÚ ÎÉÈ ÒÅÁÌÉÚÏ×ÁÎÙ ËÁË ÐÅÒÅÍÅÎÎÙÅ, ÞØÉ ÚÎÁÞÅÎÉÑ ÐÒÅÄÐÏÌÁÇÁÅÔÓÑ ÎÅ +ÍÅÎÑÔØ. +%%Some of these are implemented +%%as variables whose values are intended to be left unchanged. + +ôÁÂÌÉÃÁ~\ref{optab} ÐÒÉ×ÏÄÉÔ ÏÐÅÒÁÔÏÒÙ MetaPost É ÐÅÒÅÞÉÓÌÑÅÔ +×ÏÚÍÏÖÎÙÅ ÔÉÐÙ ÄÌÑ ÁÒÇÕÍÅÎÔÏ× É ÒÅÚÕÌØÔÁÔÁ ËÁÖÄÏÇÏ ÉÚ ÎÉÈ. +%%Table~\ref{optab} summarizes MetaPost operators and lists +%%the possible argument and result types for each one. +ðÕÎËÔ ``--'' ÄÌÑ ÌÅ×ÏÇÏ ÁÒÇÕÍÅÎÔÁ ÚÁÄÁÅÔ ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ, Á ``--'' ÄÌÑ +ÏÂÏÉÈ ÚÁÄÁÅÔ ÏÐÅÒÁÔÏÒ ÂÅÚ ÁÒÇÕÍÅÎÔÏ×. +%%A ``--'' entry for +%%the left argument indicates a unary operator; ``--'' entries for both +%%arguments indicate a nullary operator. +ïÐÅÒÁÔÏÒÙ Ó ÐÁÒÁÍÅÔÒÁÍÉ-ÓÕÆÆÉËÓÁÍÉ ÎÅ ÐÒÉ×ÏÄÑÔÓÑ × ÜÔÏÊ ÔÁÂÌÉÃÅ, ÐÏÔÏÍÕ ÞÔÏ ÏÎÉ +ÏÂÒÁÂÁÔÙ×ÁÀÔÓÑ ËÁË ``ÐÏÈÏÖÉÅ ÎÁ ÆÕÎËÃÉÉ ÍÁËÒÏÓÙ''. +%%Operators that take suffix +%%parameters are not listed in this table because they are treated as +%%``function-like macros''. + +ä×Å ÐÏÓÌÅÄÎÉÅ ÔÁÂÌÉÃÙ --- ÜÔÏ ÔÁÂÌÉÃÁ~\ref{cmdtab} ÄÌÑ ËÏÍÁÎÄ É +ÔÁÂÌÉÃÁ~\ref{pseudotab} ÄÌÑ ÍÁËÒÏÓÏ×, ×ÅÄÕÝÉÈ ÓÅÂÑ ËÁË ÆÕÎËÃÉÉ ÉÌÉ +ÐÒÏÃÅÄÕÒÙ. +%%The last two tables are Table~\ref{cmdtab} for commands and +%%Table~\ref{pseudotab} macros that behave like functions or procedures. +ôÁËÉÅ ÍÁËÒÏÓÙ ÂÅÒÕÔ ÓÐÉÓËÉ ÁÒÇÕÍÅÎÔÏ× × ÓËÏÂËÁÈ É/ÉÌÉ ÐÁÒÁÍÅÔÒÙ-ÓÕÆÆÉËÓÙ É +×ÏÚ×ÒÁÝÁÀÔ ÌÉÂÏ ÚÎÁÞÅÎÉÅ ÐÒÉ×ÅÄÅÎÎÏÇÏ × ÔÁÂÌÉÃÅ ÔÉÐÁ, ÌÉÂÏ ÎÉÞÅÇÏ. +%%Such macros take parenthesized argument lists and/or suffix parameters, +%%returning either a value whose type is listed in the table, or nothing. +ðÏÓÌÅÄÎÉÊ ÓÌÕÞÁÊ ÄÌÑ ÍÁËÒÏÓÏ×, ×ÅÄÕÝÉÈ ÓÅÂÑ ËÁË ÐÒÏÃÅÄÕÒÙ. +%%The latter case is for macros that behave like procedures. +éÈ ×ÏÚ×ÒÁÝÁÅÍÙÅ ÚÎÁÞÅÎÉÑ ÐÒÉ×ÏÄÉÔÓÑ ËÁË ``--''. +%%Their return values are listed as ``--''. + +ëÁÒÔÉÎËÉ × ÜÔÏÍ ÐÒÉÌÏÖÅÎÉÉ ÐÒÅÄÓÔÁ×ÌÑÀÔ ÓÉÎÔÁËÓÉÓ ÑÚÙËÁ MetaPost, ÎÁÞÉÎÁÑ +Ó ×ÙÒÁÖÅÎÉÊ ÎÁ ÒÉÓÕÎËÁÈ \ref{syexpr1}--\ref{sypseudo}. +%%The figures in this appendix present the syntax of the MetaPost language +%%starting with expressions in Figures \ref{syexpr1}--\ref{sypseudo}. +èÏÔÑ ÐÒÁ×ÉÌÁ ÉÎÏÇÄÁ ÕËÁÚÙ×ÁÀÔ ÔÉÐÙ ÄÌÑ ×ÙÒÁÖÅÎÉÊ, ÐÅÒ×ÉÞÎÏÓÔÅÊ, ×ÔÏÒÉÞÎÏÓÔÅÊ É +ÔÒÅÔÉÞÎÏÓÔÅÊ, ÎÏ ÏÔÄÅÌØÎÙÊ ÓÉÎÔÁËÓÉÓ ÄÌÑ \tdescr{ÞÉÓÌÏ×ÏÇÏ ×ÙÒÁÖÅÎÉÑ}, +\tdescr{×ÙÒÁÖÅÎÉÑ-ÐÁÒÙ} É Ô.~Ð. ÎÅ ÐÒÉ×ÏÄÉÔÓÑ. +%%Although the productions sometimes specify types for expressions, primaries, +%%secondaries, and tertiaries, no attempt is made to give separate syntaxes +%%for \tdescr{numeric expression}, \tdescr{pair expression}, etc. +ó×ÏÅÊ ÐÒÏÓÔÏÔÅ ÐÒÁ×ÉÌÁ ÎÁ ÒÉÓ.~\ref{sytypexpr} ÏÂÑÚÁÎÙ ÜÔÉÍ ÏÔÓÕÔÓÔ×ÉÅÍ +ÉÎÆÏÒÍÁÃÉÉ Ï ÔÉÐÁÈ. +%%The simplicity of the productions in Figure~\ref{sytypexpr} is due to this +%%lack of type information. +éÎÆÏÒÍÁÃÉÑ Ï ÔÉÐÁÈ ÍÏÖÅÔ ÂÙÔØ ÎÁÊÄÅÎÁ × ÔÁÂÌÉÃÁÈ \ref{ivartab}--\ref{pseudotab}. +%%Type information can be found in Tables \ref{ivartab}--\ref{pseudotab}. + +òÉÓÕÎËÉ \ref{syprog} É \ref{sycmds} ÓÏÄÅÒÖÁÔ ÓÉÎÔÁËÓÉÓ ÐÒÏÇÒÁÍÍ MetaPost, +×ËÌÀÞÁÑ ËÏÍÁÎÄÙ É ÉÈ ÏÂÏÂÝÅÎÉÑ. +%%Figures \ref{syprog} and \ref{sycmds} give the syntax for MetaPost programs, +%%including statements and commands. +ïÎÉ ÎÅ ÕÐÏÍÉÎÁÀÔ ÃÉËÌÏ×\index{ÃÉËÌÙ} É ÐÒÏ×ÅÒÏË {\tt if}\index{if?\texttt{if}}, +ÐÏÔÏÍÕ ÞÔÏ ÜÔÉ ËÏÎÓÔÒÕËÃÉÉ ÎÅ ×ÅÄÕÔ ÓÅÂÑ ËÁË ËÏÍÁÎÄÙ. +%%They do not mention loops\index{loops} +%%and {\tt if}\index{if?\texttt{if}} +%%tests because these constructions do not behave like statements. +óÉÎÔÁËÓÉÓ ÎÁ ÒÉÓÕÎËÁÈ \ref{syexpr1}--\ref{sycondloop} ÐÒÉÍÅÎÉÍ Ë ÒÅÚÕÌØÔÁÔÁÍ +ÒÁÓËÒÙÔÉÑ ×ÓÅÈ ÕÓÌÏ×ÎÙÈ ËÏÎÓÔÒÕËÃÉÊ É ÃÉËÌÏ×. +%%The syntax +%%given in Figures \ref{syexpr1}--\ref{sycondloop} applies to the result of +%%expanding all conditionals and loops. +õÓÌÏ×ÎÙÅ ËÏÎÓÔÒÕËÃÉÉ É ÃÉËÌÙ ÉÍÅÀÔ ÓÉÎÔÁËÓÉÓ, ÎÏ ÏÎÉ ÒÁÂÏÔÁÀÔ ÐÒÁËÔÉÞÅÓËÉ +Ó ÐÒÏÉÚ×ÏÌØÎÙÍÉ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔÑÍÉ ÚÎÁËÏ×. +%%Conditionals and loops do have a +%%syntax, but they deal with almost arbitrary sequences of tokens. +òÉÓ.~\ref{sycondloop} ÏÐÒÅÄÅÌÑÅÔ ÕÓÌÏ×ÎÙÅ ËÏÎÓÔÒÕËÃÉÉ ÞÅÒÅÚ +\tdescr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ}, Á ÃÉËÌÙ ÞÅÒÅÚ \tdescr{ÔÅÌÏ ÃÉËÌÁ}, ÇÄÅ +\tdescr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ} --- ÜÔÏ ÌÀÂÁÑ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÚÎÁËÏ×, +ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÁÑ ÏÔÎÏÓÉÔÅÌØÎÏ {\tt if} É {\tt fi}, Á \tdescr{ÔÅÌÏ ÃÉËÌÁ} --- +ÜÔÏ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÚÎÁËÏ×, ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÁÑ ÏÔÎÏÓÉÔÅÌØÎÏ {\tt for}, +{\tt forsuffixes}, {\tt forever} É {\tt endfor}. +%%Figure~\ref{sycondloop} specifies conditionals in terms of +%%\tdescr{balanced tokens} and loops in terms of \tdescr{loop text}, where +%%\tdescr{balanced tokens} is any sequence of tokens balanced with respect +%%to {\tt if} and {\tt fi}, and \tdescr{loop text} is a sequence of tokens +%%balanced with respect to {\tt for}, {\tt forsuffixes}, {\tt forever}, +%%and {\tt endfor}. + +\begin{table}[htp] +\caption{÷ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ Ó ÞÉÓÌÏ×ÙÍÉ ÚÎÁÞÅÎÉÑÍÉ} +%%\caption{Internal variables with numeric values} +$$\begin{tabular}{|l|r|l|} +\hline +\multicolumn1{|c}{éÍÑ}& \multicolumn1{|c}{óÔÒ.}& \multicolumn1{|c|}{ïÐÉÓÁÎÉÅ}\\ +%%\multicolumn1{|c}{Name}& \multicolumn1{|c}{Page}& \multicolumn1{|c|}{Explanation}\\ +\hline +\hline +\pl\tt ahangle& \pageref{Dahangle}& + ÕÇÏÌ ÄÌÑ ÎÁËÏÎÅÞÎÉËÁ ÓÔÒÅÌËÉ × ÇÒÁÄÕÓÁÈ (ÓÔÁÎÄÁÒÔÎÏ 45)\\\hline +%% angle for arrowheads in degrees (default: 45)\\\hline +\pl\tt ahlength& \pageref{Dahlength}& + ÒÁÚÍÅÒ ÎÁËÏÎÅÞÎÉËÁ ÓÔÒÅÌËÉ (ÓÔÄ. 4{\tt bp})\\\hline +%% size of arrowheads (default: 4{\tt bp})\\\hline +\pl\tt bboxmargin& \pageref{Dbbmargin}& + ÏÓÏÂÙÊ ÐÒÏÍÅÖÕÔÏË, ÄÏÐÕÓËÁÅÍÙÊ {\tt bbox} (ÓÔÄ. 2{\tt bp})\\\hline +%% extra space allowed by {\tt bbox} (default 2{\tt bp})\\\hline +\tt charcode& \pageref{Dcharcode}& + ÎÏÍÅÒ ÔÅËÕÝÅÊ ËÁÒÔÉÎËÉ\\\hline +%% the number of the current figure\\\hline +\bx\tt circmargin& \pageref{Dcmargin}& + ÐÕÓÔÏÔÁ ×ÏËÒÕÇ ÓÏÄÅÒÖÉÍÏÇÏ ËÒÕÇÏ×ÏÊ ÉÌÉ Ï×ÁÌØÎÏÊ ÒÁÍËÉ\\\hline +%% clearance around contents of a circular or oval box\\\hline +\tt day& --& + ÔÅËÕÝÉÊ ÄÅÎØ ÍÅÓÑÃÁ\\\hline +%% the current day of the month\\\hline +\tt defaultcolormodel& --& + ÎÁÞÁÌØÎÁÑ Ã×ÅÔÏ×ÁÑ ÍÏÄÅÌØ (ÓÔÄ. 5, rgb)\\\hline +%% the initial color model (default: 5, rgb)\\\hline +\bx\tt defaultdx& \pageref{Ddefaultdx}& + ÏÂÙÞÎÙÊ ÇÏÒÉÚ. ÏÔÓÔÕÐ ×ÏËÒÕÇ ÓÏÄÅÒÖÉÍÏÇÏ ÒÁÍËÉ (ÓÔÄ. 3{\tt bp})\\\hline +%% usual horizontal space around box contents (default 3{\tt bp})\\\hline +\bx\tt defaultdy& \pageref{Ddefaultdy}& + ÏÂÙÞÎÙÊ ×ÅÒÔ. ÏÔÓÔÕÐ ×ÏËÒÕÇ ÓÏÄÅÒÖÉÍÏÇÏ ÒÁÍËÉ (ÓÔÄ. 3{\tt bp})\\\hline +%% usual vertical space around box contents (default 3{\tt bp})\\\hline +\pl\tt defaultpen& \pageref{Ddefaultpen}& + ÞÉÓÌÏ, ÉÓÐÏÌØÚÕÅÍÏÅ {\tt pickup} ÄÌÑ ×ÙÂÏÒÁ ÓÔÄ. ÐÅÒÁ\\\hline +%% numeric index used by {\tt pickup} to select default pen\\\hline +\pl\tt defaultscale& \pageref{Ddfscale}& + ÍÁÓÛÔÁÂÉÒÕÀÝÉÊ ÍÎÏÖÉÔÅÌØ ÛÒÉÆÔÁ ÄÌÑ ÓÔÒÏË-ÍÅÔÏË (ÓÔÄ. 1)\\\hline +%% font scale factor for label strings (default 1)\\\hline +\pl\tt labeloffset& \pageref{Dlaboff}& + ÒÁÓÓÔÏÑÎÉÅ ÏÔÓÔÕÐÁ ÄÌÑ ÍÅÔÏË (ÓÔÄ. 3{\tt bp})\\\hline +%% offset distance for labels (default 3{\tt bp})\\\hline +\tt linecap& \pageref{Dlinecap}& + 0 ÄÌÑ butt, 1 ÄÌÑ round, 2 ÄÌÑ square\\\hline +%% 0 for butt, 1 for round, 2 for square\\\hline +\tt linejoin& \pageref{Dlinejoin}& + 0 ÄÌÑ mitered, 1 ÄÌÑ round, 2 ÄÌÑ beveled\\\hline +%% 0 for mitered, 1 for round, 2 for beveled\\\hline +\tt miterlimit& \pageref{Dmiterlim}& + ËÏÎÔÒÏÌÉÒÕÅÔ ÄÌÉÎÕ ÏÓÔÒÉÑ ËÁË × PostScript\\\hline +%% controls miter length as in PostScript\\\hline +\tt month& --& + ÔÅËÕÝÉÊ ÍÅÓÑà (ÎÁÐÒÉÍÅÒ, 3 $\equiv$ íÁÒÔ)\\\hline +%% the current month (e.g, 3 $\equiv$ March)\\\hline +\tt mpprocset& --& + \vtop{\hbox{ÕÓÔÁÎÏ×ÉÔÅ ×~1, ÅÓÌÉ ÈÏÔÉÔÅ ×ËÌÀÞÉÔØ ÓÌÏ×ÁÒØ +ÓÏËÒÁÝÅÎÉÊ}\hbox{PostScript × ×Ù×ÏÄ}}\\\hline +%% \vtop{\hbox{set this to~1 if you want to include a PostScript +%%dictionary}\hbox{of abbreviations in the output}}\\\hline +\tt pausing& --& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ÓÔÒÏËÉ ÎÁ ÔÅÒÍÉÎÁÌÅ ÄÏ ÉÈ ÞÔÅÎÉÑ\\\hline +%% ${}>0$ to display lines on the terminal before they are read\\\hline +\tt prologues& \pageref{Dprologues}& + ${}>0$ --- ×Ù×ÏÄÉÔØ PostScript Ó ×ÓÔÒÏÅÎÎÙÍÉ ÛÒÉÆÔÁÍÉ\\\hline +%% ${}>0$ to output conforming PostScript using built-in fonts\\\hline +\tt restoreclipcolor& --& + ×ÏÓÓÔÁÎÏ×ÌÅÎÉÅ ÓÏÓÔÏÑÎÉÑ ÇÒÁÆÉËÉ ÐÏÓÌÅ ×ÙÒÅÚËÉ (ÓÔÄ. 1)\\\hline +%% restore the graphics state after clip operations (default: 1)\\\hline +\tt showstopping& --& + ${}>0$ --- ÏÓÔÁÎÁ×ÌÉ×ÁÔØ ÐÏÓÌÅ ËÁÖÄÏÊ ËÏÍÁÎÄÙ {\tt show}\\\hline +%% ${}>0$ to stop after each {\tt show} command\\\hline +\tt time& --& + ÞÉÓÌÏ ÍÉÎÕÔ ÐÏÓÌÅ ÐÏÌÕÎÏÞÉ × ÎÁÞÁÌÅ ÜÔÏÊ ÒÁÂÏÔÙ\\\hline +%% the number of minutes past midnight when this job started\\\hline +\tt tracingcapsules& \pageref{Dtcapsules}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ É ËÁÐÓÕÌÙ\\\hline +%% ${}>0$ to show capsules too\\\hline +\tt tracingchoices& \pageref{Dtchoices}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ËÏÎÔÒÏÌØÎÙÅ ÔÏÞËÉ ÄÌÑ ÐÕÔÅÊ\\\hline +%% ${}>0$ to show the control points chosen for paths\\\hline +\tt tracingcommands& \pageref{Dtcommands}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ËÏÍÁÎÄÙ ÐÒÉ ÉÈ ×ÙÐÏÌÎÅÎÉÉ\\\hline +%% ${}>0$ to show commands and operations as they are performed\\\hline +\tt tracingequations& \pageref{Dtequations}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ËÁÖÄÕÀ ÓÔÁ×ÛÕÀ ÉÚ×ÅÓÔÎÏÊ ÐÅÒÅÍÅÎÎÕÀ\\\hline +%% ${}>0$ to show each variable when it becomes known\\\hline +\tt tracinglostchars& \pageref{Dtlostchars}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ÓÉÍ×ÏÌÙ ÎÅ ÉÚ {\tt infont}\\\hline +%% ${}>0$ to show characters that aren't {\tt infont}\\\hline +\tt tracingmacros& \pageref{Dtmacros}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ÍÁËÒÏÓÙ ÄÏ ÉÈ ÒÁÓËÒÙÔÉÑ\\\hline +%% ${}>0$ to show macros before they are expanded\\\hline +\tt tracingonline& \pageref{Dtonline}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ÄÌÉÎÎÙÅ ÄÉÁÇÎÏÓÔÉËÉ ÎÁ ÔÅÒÍÉÎÁÌÅ\\\hline +%% ${}>0$ to show long diagnostics on the terminal\\\hline +\tt tracingoutput& \pageref{Dtoutput}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ÃÉÆÒÏ×ÙÅ ËÒÁÑ ÐÒÉ ×Ù×ÏÄÅ\\\hline +%% ${}>0$ to show digitized edges as they are output\\\hline +\tt tracingrestores& \pageref{Dtrestores}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ÐÅÒÅÍÅÎÎÙÅ ÐÒÉ ÉÈ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÉ\\\hline +%% ${}>0$ to show when a variable or internal is restored\\\hline +\tt tracingspecs& \pageref{Dtspecs}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ÄÅÌÅÎÉÑ ÐÕÔÉ (ÉÓÐ-ÓÑ ÍÎÏÇÏÕÇÏÌØÎÏÅ ÐÅÒÏ)\\\hline +%% ${}>0$ to show path subdivision when using a polygonal a pen\\\hline +\tt tracingstats& \pageref{Dtstats}& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ÉÓÐÏÌØÚÏ×ÁÎÉÅ ÐÁÍÑÔÉ × ËÏÎÃÅ ÒÁÂÏÔÙ\\\hline +%% ${}>0$ to show memory usage at end of job\\\hline +\tt tracingtitles& --& + ${}>0$ --- ÐÏËÁÚÙ×ÁÔØ ÚÁÇÏÌÏ×ËÉ ÐÒÉ ÉÈ ÐÏÑ×ÌÅÎÉÉ\\\hline +%% ${}>0$ to show titles online when they appear\\\hline +\tt troffmode& \pageref{Dtroffmode}& + ÂÕÄÅÔ~1, ÅÓÌÉ ÅÓÔØ ÏÐÃÉÑ {\tt -troff} ÉÌÉ {\tt -T}\\\hline +%% set to~1 if a {\tt -troff} or {\tt -T} option was given\\\hline +\tt truecorners& \pageref{Dtruecorn}& + ${}>0$ --- ÄÅÌÁÔØ {\tt llcorner} É Ô.~Ä., ÉÇÎÏÒÉÒÏ×ÁÔØ {\tt setbounds}\\\hline +%% ${}>0$ to make {\tt llcorner} etc. ignore {\tt setbounds}\\\hline +\tt warningcheck& \pageref{Dwarncheck}& + ÓÏÏÂÝÅÎÉÅ Ï ÏÛÉÂËÅ ÐÒÉ ÂÏÌØÛÏÍ ÚÎÁÞÅÎÉÉ ÐÅÒÅÍÅÎÎÏÊ\\\hline +%% controls error message when variable value is large\\\hline +\tt year& --& + ÔÅËÕÝÉÊ ÇÏÄ (ÎÁÐÒÉÍÅÒ, 1992)\\\hline +%% the current year (e.g., 1992)\\\hline +\end{tabular} +$$ +\label{ivartab}% +\index{day?\texttt{day}}\index{month?\texttt{month}}\index{pausing?\texttt{pausing}}\index{showstopping?\texttt{showstopping}}% +\index{time?\texttt{time}}\index{tracingtitles?\texttt{tracingtitles}}\index{year?\texttt{year}} +\end{table} + + +\begin{table}[htp] +\caption{äÒÕÇÉÅ ÐÒÅÄÏÐÒÅÄÅÌÅÎÎÙÅ ÐÅÒÅÍÅÎÎÙÅ} +%%\caption{Other Predefined Variables} +$$\begin{tabular}{|l|l|r|l|} +\hline +\multicolumn1{|c}{éÍÑ}& \multicolumn1{|c}{ôÉÐ}& \multicolumn1{|c}{óÔÒ.}& + \multicolumn1{|c|}{ïÂßÑÓÎÅÎÉÅ}\\ +%%\multicolumn1{|c}{Name}& \multicolumn1{|c}{Type}& \multicolumn1{|c}{Page}& +%% \multicolumn1{|c|}{Explanation}\\ +\hline +\hline +\pl\tt background& color& \pageref{Dbground}& + ã×ÅÔ ÄÌÑ {\tt unfill} É {\tt undraw} (ÏÂÙÞÎÏ ÂÅÌÙÊ)\\\hline +%% Color for {\tt unfill} and {\tt undraw} (usually white)\\\hline +\pl\tt currentpen& pen& \pageref{Dcurpen}& + ôÅËÕÝÅÅ ÐÅÒÏ (ÄÌÑ ËÏÍÁÎÄÙ {\tt draw})\\\hline +%% Last pen picked up (for use by the {\tt draw} command)\\\hline +\pl\tt currentpicture& picture& \pageref{Dcurpic}& + òÅÚÕÌØÔÁÔ ËÏÍÁÎÄ {\tt draw} É {\tt fill}\\\hline +%% Accumulate results of {\tt draw} and {\tt fill} commands\\\hline +\pl\tt cuttings& path& \pageref{Dcuttings}& + ðÏÄÐÕÔØ, ÏÔÒÅÚÁÎÎÙÊ ÐÏÓÌÅÄÎÅÊ {\tt cutbefore} ÉÌÉ {\tt cutafter}\\\hline +%% subpath cut off by last {\tt cutbefore} or {\tt cutafter}\\\hline +\pl\tt defaultfont& string& \pageref{Ddffont}& + ûÒÉÆÔ ÄÌÑ ËÏÍÁÎÄ ÐÅÞÁÔÉ ÓÔÒÏË\\\hline +%% Font used by label commands for typesetting strings\\\hline +\pl\tt extra\_beginfig& string& \pageref{Dxbfig}& + äÏÐÏÌÎÉÔÅÌØÎÙÅ ËÏÍÁÎÄÙ ÄÌÑ {\tt beginfig}\\\hline +%% Commands for {\tt beginfig} to scan\\\hline +\pl\tt extra\_endfig& string& \pageref{Dxefig}& + äÏÐÏÌÎÉÔÅÌØÎÙÅ ËÏÍÁÎÄÙ ÄÌÑ {\tt endfig}\\\hline +%% Commands for {\tt endfig} to scan\\\hline +\end{tabular} +$$ +\label{pvartab} +\end{table} + + +\begin{table}[htp] +\caption{ðÒÅÄÏÐÒÅÄÅÌÅÎÎÙÅ ËÏÎÓÔÁÎÔÙ} +%%\caption{Predefined Constants} +$$\begin{tabular}{|l|l|r|l|} +\hline +\multicolumn1{|c}{éÍÑ}& \multicolumn1{|c}{ôÉÐ}& \multicolumn1{|c}{óÔÒ.}& + \multicolumn1{|c|}{ïÂßÑÓÎÅÎÉÅ}\\ +%%\multicolumn1{|c}{Name}& \multicolumn1{|c}{Type}& \multicolumn1{|c}{Page}& +%% \multicolumn1{|c|}{Explanation}\\ +\hline +\hline +\pl\tt beveled& numeric& \pageref{Dbvled}& + úÎÁÞÅÎÉÅ {\tt linejoin} ÄÌÑ ÓÒÅÚÁÎÎÙÈ ÓÏÅÄÉÎÅÎÉÊ [2]\\\hline +%%\pl\tt beveled& numeric& \pageref{Dbvled}& +%% {\tt linejoin} value for beveled joins [2]\\\hline +\pl\tt black& color& \pageref{Dblack}& + üË×É×ÁÌÅÎÔÎÏ {\tt (0,0,0)}\\\hline +%%\pl\tt black& color& \pageref{Dblack}& +%% Equivalent to {\tt (0,0,0)}\\\hline +\pl\tt blue& color& \pageref{Dblue}& + üË×É×ÁÌÅÎÔÎÏ {\tt (0,0,1)}\\\hline +%%\pl\tt blue& color& \pageref{Dblue}& +%% Equivalent to {\tt (0,0,1)}\\\hline +\pl\tt bp& numeric& \pageref{Dbp}& + ïÄÉÎ ÐÕÎËÔ PostScript × {\tt bp}-ÅÄÉÎÉÃÁÈ [1]\\\hline +%%\pl\tt bp& numeric& \pageref{Dbp}& +%% One PostScript point in {\tt bp} units [1]\\\hline +\pl\tt butt& numeric& \pageref{Dbutt}& + úÎÁÞÅÎÉÅ {\tt linecap} ÄÌÑ butt-ËÏÎÃÁ [0]\\\hline +%%\pl\tt butt& numeric& \pageref{Dbutt}& +%% {\tt linecap} value for butt end caps [0]\\\hline +\pl\tt cc& numeric& --& + ïÄÎÁ ÅÄÉÎÉÃÁ ÃÉÃÅÒÏ × {\tt bp}-ÅÄÉÎÉÃÁÈ [12.79213]\\\hline +%%\pl\tt cc& numeric& --& +%% One cicero in {\tt bp} units [12.79213]\\\hline +\pl\tt cm& numeric& \pageref{Dcm}& + ïÄÉÎ ÓÁÎÔÉÍÅÔÒ × {\tt bp}-ÅÄÉÎÉÃÁÈ [28.34645]\\\hline +%%\pl\tt cm& numeric& \pageref{Dcm}& +%% One centimeter in {\tt bp} units [28.34645]\\\hline +\pl\tt dd& numeric& --& + ïÄÉÎ ÄÉÄÏÔ × {\tt bp}-ÅÄÉÎÉÃÁÈ [1.06601]\\\hline +%%\pl\tt dd& numeric& --& +%% One didot point in {\tt bp} units [1.06601]\\\hline +\pl\tt ditto& string& --& + óÔÒÏËÁ {\tt \qq} ÄÌÉÎÙ 1\\\hline +%%\pl\tt ditto& string& --& +%% The {\tt \qq} character as a string of length 1\\\hline +\pl\tt down& pair& \pageref{Ddown}& + ÷ÅËÔÏÒ ×ÎÉÚ $(0,-1)$\\\hline +%%\pl\tt down& pair& \pageref{Ddown}& +%% Downward direction vector $(0,-1)$\\\hline +\pl\tt epsilon& numeric& --& + îÁÉÍÅÎØÛÅÅ ÐÏÌÏÖÉÔÅÌØÎÏÅ ÞÉÓÌÏ MetaPost [$1\over65536$]\\\hline +%%\pl\tt epsilon& numeric& --& +%% Smallest positive MetaPost number [$1\over65536$]\\\hline +\pl\tt evenly& picture& \pageref{Devenly}& + ïÂÒÁÚÅà ÐÕÎËÔÉÒÁ ÉÚ ÔÉÒÅ É ÒÁ×ÎÙÈ ÐÒÏÍÅÖÕÔËÏ×\\\hline +%%\pl\tt evenly& picture& \pageref{Devenly}& +%% Dash pattern for equal length dashes\\\hline +\pl\tt EOF& string& \pageref{Deof}& + ïÄÉÎÏÞÎÙÊ ÎÕÌÅ×ÏÊ ÓÉÍ×ÏÌ\\\hline +%%\pl\tt EOF& string& \pageref{Deof}& +%% Single null character\\\hline +\tt false& boolean& \pageref{Dfalse}& + ìÏÇÉÞÅÓËÏÅ ÚÎÁÞÅÎÉÅ {\it false\/}\\\hline +%%\tt false& boolean& \pageref{Dfalse}& +%% The boolean value {\it false\/}\\\hline +\pl\tt fullcircle& path& \pageref{Dfcirc}& + ïËÒÕÖÎÏÓÔØ ÄÉÁÍÅÔÒÁ 1 Ó ÃÅÎÔÒÏÍ × $(0,0)$\\\hline +%%\pl\tt fullcircle& path& \pageref{Dfcirc}& +%% Circle of diameter 1 centered on $(0,0)$\\\hline +\pl\tt green& color& \pageref{Dgreen}& + üË×É×ÁÌÅÎÔÎÏ {\tt (0,1,0)}\\\hline +%%\pl\tt green& color& \pageref{Dgreen}& +%% Equivalent to {\tt (0,1,0)}\\\hline +\pl\tt halfcircle& path& \pageref{Dhcirc}& + ÷ÅÒÈÎÑÑ ÐÏÌÕÏËÒÕÖÎÏÓÔØ ÄÉÁÍÅÔÒÁ 1\\\hline +%%\pl\tt halfcircle& path& \pageref{Dhcirc}& +%% Upper half of a circle of diameter 1\\\hline +\pl\tt identity& transform& \pageref{Dident}& + ôÏÖÄÅÓÔ×ÅÎÎÁÑ ÔÒÁÎÓÆÏÒÍÁÃÉÑ\\\hline +%%\pl\tt identity& transform& \pageref{Dident}& +%% Identity transformation\\\hline +\pl\tt in& numeric& \pageref{Din}& + ïÄÉÎ ÄÀÊÍ × {\tt bp}-ÅÄÉÎÉÃÁÈ [72]\\\hline +%%\pl\tt in& numeric& \pageref{Din}& +%% One inch in {\tt bp} units [72]\\\hline +\pl\tt infinity& numeric& \pageref{Dinf}& + îÁÉÂÏÌØÛÅÅ ÐÏÌÏÖÉÔÅÌØÎÏÅ ÚÎÁÞÅÎÉÅ [4095.99998]\\\hline +%%\pl\tt infinity& numeric& \pageref{Dinf}& +%% Large positive value [4095.99998]\\\hline +\pl\tt left& pair& \pageref{Dleft}& + îÁÐÒÁ×ÌÅÎÉÅ ×ÌÅ×Ï $(-1,0)$\\\hline +%%\pl\tt left& pair& \pageref{Dleft}& +%% Leftward direction $(-1,0)$\\\hline +\pl\tt mitered& numeric& \pageref{Dmitred}& + úÎÁÞÅÎÉÅ {\tt linejoin} ÄÌÑ ``ÏÓÔÒÙÈ'' ÓÏÅÄÉÎÅÎÉÊ [0]\\\hline +%%\pl\tt mitered& numeric& \pageref{Dmitred}& +%% {\tt linejoin} value for mitered joins [0]\\\hline +\pl\tt mm& numeric& \pageref{Dmm}& + ïÄÉÎ ÍÉÌÌÉÍÅÔÒ × {\tt bp}-ÅÄÉÎÉÃÁÈ [2.83464]\\\hline +%%\pl\tt mm& numeric& \pageref{Dmm}& +%% One millimeter in {\tt bp} units [2.83464]\\\hline +\tt mpversion& string& \pageref{Dmpversion}& + îÏÍÅÒ ×ÅÒÓÉÉ MetaPost\\\hline +%%\tt mpversion& string& \pageref{Dmpversion}& +%% MetaPost version number\\\hline +\tt nullpen& pen& \pageref{Dnlpen}& + ðÕÓÔÏÅ ÐÅÒÏ\\\hline +%%\tt nullpen& pen& \pageref{Dnlpen}& +%% Empty pen\\\hline +\tt nullpicture& picture& \pageref{Dnlpic}& + ðÕÓÔÁÑ ËÁÒÔÉÎËÁ\\\hline +%%\tt nullpicture& picture& \pageref{Dnlpic}& +%% Empty picture\\\hline +\pl\tt origin& pair& --& + ðÁÒÁ $(0,0)$\\\hline +%%\pl\tt origin& pair& --& +%% The pair $(0,0)$\\\hline +\pl\tt pc& numeric& --& + ïÄÎÁ ÐÉËÁ × {\tt bp}-ÅÄÉÎÉÃÁÈ [11.95517]\\\hline +%%\pl\tt pc& numeric& --& +%% One pica in {\tt bp} units [11.95517]\\\hline +\tt pencircle& pen& \pageref{Dpncirc}& + ëÒÕÇÏ×ÏÅ ÐÅÒÏ ÄÉÁÍÅÔÒÁ 1\\\hline +%%\tt pencircle& pen& \pageref{Dpncirc}& +%% Circular pen of diameter 1\\\hline +\pl\tt pensquare& pen& \pageref{Dpnsqr}& + ë×ÁÄÒÁÔÎÏÅ ÐÅÒÏ ×ÙÓÏÔÙ É ÛÉÒÉÎÙ 1\\\hline +%%\pl\tt pensquare& pen& \pageref{Dpnsqr}& +%% square pen of height 1 and width 1\\\hline +\pl\tt pt& numeric& \pageref{Dpt}& + ïÄÉÎ ÐÒÉÎÔÅÒÎÙÊ ÐÕÎËÔ × {\tt bp}-ÅÄÉÎÉÃÁÈ [0.99626]\\\hline +%%\pl\tt pt& numeric& \pageref{Dpt}& +%% One printer's point in {\tt bp} units [0.99626]\\\hline +\pl\tt quartercircle& path& --& + ðÅÒ×ÙÊ Ë×ÁÄÒÁÎÔ ÏËÒÕÖÎÏÓÔÉ ÄÉÁÍÅÔÒÁ 1\\\hline +%%\pl\tt quartercircle& path& --& +%% First quadrant of a circle of diameter 1\\\hline +\pl\tt red& color& \pageref{Dred}& + üË×É×ÁÌÅÎÔÎÏ {\tt (1,0,0)}\\\hline +%%\pl\tt red& color& \pageref{Dred}& +%% Equivalent to {\tt (1,0,0)}\\\hline +\pl\tt right& pair& \pageref{Dright}& + îÁÐÒÁ×ÌÅÎÉÅ ×ÐÒÁ×Ï $(1,0)$\\\hline +%%\pl\tt right& pair& \pageref{Dright}& +%% Rightward direction $(1,0)$\\\hline +\pl\tt rounded& numeric& \pageref{Drnded}& + úÎÁÞÅÎÉÅ ÄÌÑ {\tt linecap} É {\tt linejoin} ÄÌÑ ËÒÕÇÌÙÈ\\ +\tt & & & + ÓÏÅÄÉÎÅÎÉÊ É ËÏÎÃÏ× [1]\\\hline +%%\pl\tt rounded& numeric& \pageref{Drnded}& +%% {\tt linecap} and {\tt linejoin} value for round joins\\ +%%\tt & & & +%% and end caps [1]\\\hline +\pl\tt squared& numeric& \pageref{Dsqred}& + úÎÁÞÅÎÉÅ {\tt linecap} ÄÌÑ Ë×ÁÄÒÁÔÎÙÈ ËÏÎÃÏ× [2]\\\hline +%%\pl\tt squared& numeric& \pageref{Dsqred}& +%% {\tt linecap} value for square end caps [2]\\\hline +\tt true& boolean& \pageref{Dtrue}& + ìÏÇÉÞÅÓËÁÑ ×ÅÌÉÞÉÎÁ {\tt true}\\\hline +%%\tt true& boolean& \pageref{Dtrue}& +%% The boolean value {\tt true}\\\hline +\pl\tt unitsquare& path& --& + ðÕÔØ {\tt (0,0)-{}-(1,0)-{}-(1,1)-{}-(0,1)-{}-cycle}\\\hline +%%\pl\tt unitsquare& path& --& +%% The path {\tt (0,0)--(1,0)--(1,1)--(0,1)--cycle}\\\hline +\pl\tt up& pair& \pageref{Dup}& + îÁÐÒÁ×ÌÅÎÉÅ ××ÅÒÈ $(0,1)$\\\hline +%%\pl\tt up& pair& \pageref{Dup}& +%% Upward direction $(0,1)$\\\hline +\pl\tt white& color& \pageref{Dwhite}& + üË×É×ÁÌÅÎÔÎÏ {\tt (1,1,1)}\\\hline +%%\pl\tt white& color& \pageref{Dwhite}& +%% Equivalent to {\tt (1,1,1)}\\\hline +\pl\tt withdots& picture& \pageref{Dwdots}& + ïÂÒÁÚÅà ÐÕÎËÔÉÒÁ ÉÚ ÔÏÞÅË\\\hline +%%\pl\tt withdots& picture& \pageref{Dwdots}& +%% Dash pattern that produces dotted lines\\\hline +\end{tabular} +$$ +\label{consttab}% +\index{cc?\texttt{cc}}\index{dd?\texttt{dd}}\index{ditto?\texttt{ditto}}\index{epsilon?\texttt{epsilon}}% +\index{origin?\texttt{origin}}\index{pc?\texttt{pc}}\index{quartercircle?\texttt{quartercircle}}% +\index{unitsquare?\texttt{unitsquare}} +\end{table} + + +\clearpage +\LTXtable{\textwidth}{mpman-optab-ru} + +\begin{table}[htp] +\caption{ëÏÍÁÎÄÙ} +%%\caption{Commands} +$$\begin{tabular}{|l|r|l|} +\hline +\multicolumn1{|c}{éÍÑ}& \multicolumn1{|c}{óÔÒ.}& \multicolumn1{|c|}{ïÂßÑÓÎÅÎÉÅ}\\ +%%\multicolumn1{|c}{Name}& \multicolumn1{|c}{Page}& \multicolumn1{|c|}{Explanation}\\ +\hline +\hline +\tt \verb|addto|& \pageref{sydraw}& + îÉÚËÏÕÒÏ×ÎÅ×ÁÑ ËÏÍÁÎÄÁ ÄÌÑ ÒÉÓÏ×ÁÎÉÑ É ÚÁÐÏÌÎÅÎÉÑ\\\hline +%% Low-level command for drawing and filling\\\hline +\tt \verb|clip|& \pageref{Dclip}& + ðÒÉÍÅÎÑÅÔ ÐÕÔØ ×ÙÒÅÚËÉ Ë ËÁÒÔÉÎËÅ\\\hline +%% Applies a clipping path to a picture\\\hline +\tt \verb|closefrom|& \pageref{Dclosefrom}& + úÁËÒÙ×ÁÅÔ ÆÁÊÌ, ÏÔËÒÙÔÙÊ {\tt readfrom}\\\hline +%% Close a file opened by {\tt readfrom}\\\hline +\pl\tt \verb|cutdraw|& \pageref{Dctdraw}& + òÉÓÏ×ÁÔØ Ó butt-ËÏÎÃÏÍ\\\hline +%% Draw with butt end caps\\\hline +\tt \verb|dashed|& \pageref{Ddashed}& + ðÒÉÍÅÎÑÔØ ÏÂÒÁÚÅà ÐÕÎËÔÉÒÁ × ËÏÍÁÎÄÅ ÒÉÓÏ×ÁÎÉÑ\\\hline +%% Apply dash pattern to drawing command\\\hline +\pl\tt \verb|draw|& \pageref{curves}& + òÉÓÏ×ÁÔØ ÌÉÎÉÀ ÉÌÉ ËÁÒÔÉÎËÕ\\\hline +%% Draw a line or a picture\\\hline +\pl\tt \verb|drawarrow|& \pageref{Ddrwarr}& + òÉÓÏ×ÁÔØ ÌÉÎÉÀ ÓÏ ÓÔÒÅÌËÏÊ ÎÁ ËÏÎÃÅ\\\hline +%% Draw a line with an arrowhead at the end\\\hline +\pl\tt \verb|drawdblarrow|& \pageref{Ddrwdar}& + òÉÓÏ×ÁÔØ ÌÉÎÉÀ ÓÏ ÓÔÒÅÌËÁÍÉ × ÏÂÏÉÈ ËÏÎÃÁÈ\\\hline +%% Draw a line with arrowheads at both ends\\\hline +\tt \verb|filenametemplate|& \pageref{Dfilenametemplate}& + õÓÔÁÎÏ×ÉÔØ ÛÁÂÌÏÎ ÉÍÅÎÉ ×ÙÈÏÄÎÏÇÏ ÆÁÊÌÁ\\\hline +%% Set output file name pattern\\\hline +\pl\tt \verb|fill|& \pageref{Dfill}& + úÁÐÏÌÎÉÔØ ÃÉËÌÉÞÅÓËÉÊ ÐÕÔØ\\\hline +%% Fill inside a cyclic path\\\hline +\pl\tt \verb|filldraw|& \pageref{Dfildrw}& + òÉÓÏ×ÁÔØ ÃÉËÌÉÞÅÓËÉÊ ÐÕÔØ É ÚÁÐÏÌÎÉÔØ ÅÇÏ ×ÎÕÔÒÉ\\\hline +%% Draw a cyclic path and fill inside it\\\hline +\tt \verb|interim|& \pageref{Dinterm}& + óÄÅÌÁÔØ ÌÏËÁÌØÎÏÅ ÉÚÍÅÎÅÎÉÅ ×ÎÕÔÒÅÎÎÅÊ ÐÅÒÅÍÅÎÎÏÊ\\\hline +%% Make a local change to an internal variable\\\hline +\tt \verb|let|& --& + îÁÚÎÁÞÉÔØ ÓÉÍ×ÏÌÉÞÅÓËÏÍÕ ÚÎÁËÕ ÚÎÁÞÅÎÉÅ ÄÒÕÇÏÇÏ ÚÎÁËÁ\\\hline +%% Assign one symbolic token the meaning of another\\\hline +\pl\tt \verb|loggingall|& \pageref{Dlogall}& + ÷ËÌÀÞÉÔØ ÔÒÁÓÓÉÒÏ×ËÕ (ÔÏÌØËÏ ÄÌÑ ÆÁÊÌÁ-ÖÕÒÎÁÌÁ)\\\hline +%% Turn on all tracing (log file only)\\\hline +\tt \verb|newinternal|& \pageref{Dnewint}& + ïÂßÑ×ÉÔØ ÎÏ×ÙÅ ×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ\\\hline +%% Declare new internal variables\\\hline +\pl\tt \verb|pickup|& \pageref{Dpickup}& + õËÁÚÁÔØ ÎÏ×ÏÅ ÐÅÒÏ ÄÌÑ ÒÉÓÏ×ÁÎÉÑ ÌÉÎÉÉ\\\hline +%% Specify new pen for line drawing\\\hline +\tt \verb|save|& \pageref{Dsave}& + äÅÌÁÅÔ ÐÅÒÅÍÅÎÎÙÅ ÌÏËÁÌØÎÙÍÉ\\\hline +%% Make variables local\\\hline +\tt \verb|setbounds|& \pageref{Dsetbnd}& + õÓÔÁÎÁ×ÌÉ×ÁÅÔ ÏÈ×ÁÔÙ×ÁÀÝÕÀ ÒÁÍËÕ ÄÌÑ ËÁÒÔÉÎËÉ\\\hline +%% Make a picture lie about its bounding box\\\hline +\tt \verb|shipout|& \pageref{Dship}& + îÉÚËÏÕÒÏ×ÎÅ×ÁÑ ËÏÍÁÎÄÁ ÐÅÞÁÔÉ ÒÉÓÕÎËÁ\\\hline +%% Low-level command to output a figure\\\hline +\tt \verb|show|& \pageref{Dshow}& + ðÅÞÁÔØ ×ÙÒÁÖÅÎÉÊ × ÓÉÍ×ÏÌÉÞÅÓËÏÊ ÆÏÒÍÅ\\\hline +%% print out expressions symbolically\\\hline +\tt \verb|showdependencies|& \pageref{Dshdep}& + ðÅÞÁÔØ ×ÓÅÈ ÎÅÒÅÛÅÎÎÙÈ ÕÒÁ×ÎÅÎÉÊ\\\hline +%% print out all unsolved equations\\\hline +\tt \verb|showtoken|& \pageref{Dshtok}& + ðÅÞÁÔØ ÉÎÆÏÒÍÁÃÉÉ ÐÏ ÚÎÁËÕ\\\hline +%% print an explanation of what a token is\\\hline +\tt \verb|showvariable|& \pageref{Dshvar}& + ðÅÞÁÔØ ÐÅÒÅÍÅÎÎÙÈ × ÓÉÍ×ÏÌØÎÏÊ ÆÏÒÍÅ\\\hline +%% print variables symbolically\\\hline +\tt \verb|special|& \pageref{Dspecl}& + ðÅÞÁÔØ ÓÔÒÏËÉ ÐÒÑÍÏ × PostScript-ÆÁÊÌ ×Ù×ÏÄÁ\\\hline +%% print a string directly in the PostScript output file\\\hline +\pl\tt \verb|tracingall|& \pageref{Dtall}& + ÷ËÌÀÞÉÔØ ÔÒÁÓÓÉÒÏ×ËÕ\\\hline +%% Turn on all tracing\\\hline +\pl\tt \verb|tracingnone|& \pageref{Dtnone}& + ïÔËÌÀÞÉÔØ ÔÒÁÓÓÉÒÏ×ËÕ\\\hline +%% Turn off all tracing\\\hline +\pl\tt \verb|undraw|& \pageref{Dundraw}& + óÔÅÒÅÔØ ÌÉÎÉÀ ÉÌÉ ÒÉÓÕÎÏË\\\hline +%% Erase a line or a picture\\\hline +\pl\tt \verb|unfill|& \pageref{Dunfill}& + óÔÅÒÅÔØ ×ÎÕÔÒÉ ÚÁÍËÎÕÔÏÇÏ ÐÕÔÉ\\\hline +%% Erase inside a cyclic path\\\hline +\pl\tt \verb|unfilldraw|& \pageref{Dunfdrw}& + óÔÅÒÅÔØ ÃÉËÌÉÞÅÓËÉÊ ÐÕÔØ É ×ÓÅ ×ÎÕÔÒÉ ÎÅÇÏ\\\hline +%% Erase a cyclic path and its inside\\\hline +\tt \verb|withcmykcolor|& \pageref{Dwithcmykcolor}& + éÓÐÏÌØÚÕÊ CMYK-Ã×ÅÔ × ËÏÍÁÎÄÅ ÒÉÓÏ×ÁÎÉÑ\\\hline +% Apply CMYK color to drawing command\\\hline + \tt \verb|withcolor|& \pageref{Dwithcolor}& + éÓÐÏÌØÚÕÊ ÏÂÙÞÎÙÊ Ã×ÅÔ × ËÏÍÁÎÄÅ ÒÉÓÏ×ÁÎÉÑ\\\hline +% Apply generic color specification to drawing command\\\hline + \tt \verb|withgreyscale|& \pageref{Dwithgreyscale}& + éÓÐÏÌØÚÕÊ ÏÔÔÅÎÏË ÓÅÒÏÇÏ × ËÏÍÁÎÄÅ ÒÉÓÏ×ÁÎÉÑ\\\hline +% Apply greyscale color to drawing command\\\hline + \tt \verb|withoutcolor|& \pageref{Dwithoutcolor}& + îÅ ÉÓÐÏÌØÚÕÊ ÓÐÅÃÉÆÉËÁÃÉÉ Ã×ÅÔÁ × ËÏÍÁÎÄÅ ÒÉÓÏ×ÁÎÉÑ\\\hline +% Don't apply any color specification to drawing command\\\hline + \tt \verb|withpen|& \pageref{sec.pens}& + éÓÐÏÌØÚÕÊ ÐÅÒÏ × ËÏÍÁÎÄÅ ÒÉÓÏ×ÁÎÉÑ\\\hline +% Apply pen to drawing operation\\\hline + \tt \verb|withpostscript|& \pageref{Dwithpost}& + ëÏÎÅà ËÏÄÁ PostScript\\\hline +% End raw PostScript code\\\hline + \tt \verb|withprescript|& \pageref{Dwithpre}& + îÁÞÁÌÏ ËÏÄÁ PostScript\\\hline +% Begin raw PostScript code\\\hline + \tt \verb|withrgbcolor|& \pageref{Dwithrgbcolor}& + éÓÐÏÌØÚÕÊ RGB-Ã×ÅÔ × ËÏÍÁÎÄÅ ÒÉÓÏ×ÁÎÉÑ\\\hline +% Apply RGB color to drawing command\\\hline +\tt \verb|write to|& \pageref{Dwrite}& + ðÉÓÁÔØ ÓÔÒÏËÕ × ÆÁÊÌ\\\hline +%% Write string to file\\\hline +\end{tabular} +$$ +\index{let?\texttt{let}}% +\label{cmdtab} +\end{table} + + +\begin{table}[htp] +\caption{íÁËÒÏÓÙ, ÐÏÈÏÖÉÅ ÎÁ ÆÕÎËÃÉÉ} +%%\caption{Function-Like Macros} +$$\begin{tabular}{|l|l|l|r|p{5.7cm}|} +%%$$\begin{tabular}{|l|l|l|r|l|} +\hline +\multicolumn1{|c}{éÍÑ}& \multicolumn1{|c}{áÒÇÕÍÅÎÔÙ}& + \multicolumn1{|c}{òÅÚÕ-Ô}& \multicolumn1{|c}{ó.}& + \multicolumn1{|c|}{ïÂßÑÓÎÅÎÉÅ}\\ +%%\multicolumn1{|c}{Name}& \multicolumn1{|c}{Arguments}& +%% \multicolumn1{|c}{Result}& \multicolumn1{|c}{Page}& +%% \multicolumn1{|c|}{Explanation}\\ +\hline +\hline +\bx\tt \verb|boxit|& \small ÓÕÆÆÉËÓ, ËÁÒÔÉÎËÁ& --& \pageref{Dboxit}& +%%\bx\tt \verb|boxit|& suffix, picture& --& \pageref{Dboxit}& + \small úÁÄÁÅÔ ÒÁÍËÕ, ÓÏÄÅÒÖÁÝÕÀ ËÁÒÔÉÎËÕ\\\hline +%% Define a box containing the picture\\\hline +\bx\tt \verb|boxit|& \small ÓÕÆÆÉËÓ, ÓÔÒÏËÁ& --& \pageref{Dsboxit}& +%%\bx\tt \verb|boxit|& suffix, string& --& \pageref{Dsboxit}& + \small ïÐÒÅÄÅÌÑÅÔ ÒÁÍËÕ, ÓÏÄÅÒÖÁÝÕÀ ÔÅËÓÔ\\\hline +%% Define a box containing text\\\hline +\bx\tt \verb|boxit|& \small ÓÕÆÆÉËÓ, \tdescr{ÐÕÓÔÏ}& --& \pageref{Deboxit}& +%%\bx\tt \verb|boxit|& suffix, \tdescr{empty}& --& \pageref{Deboxit}& + \small ïÐÒÅÄÅÌÑÅÔ ÐÕÓÔÕÀ ÒÁÍËÕ\\\hline +%% Define an empty box\\\hline +\bx\tt \verb|boxjoin|& \small ÕÒÁ×ÎÅÎÉÑ& --& \pageref{Dbxjoin}& +%%\bx\tt \verb|boxjoin|& equations& --& \pageref{Dbxjoin}& + \small úÁÄÁÅÔ ÕÒÁ×ÎÅÎÉÑ ÄÌÑ ÓÏÅÄÉÎÑÅÍÙÈ ÒÁÍÏË\\\hline +%% Give equations for connecting boxes\\\hline +\bx\tt \verb|bpath|& \small ÓÕÆÆÉËÓ& path& \pageref{Dbpath}& +%%\bx\tt \verb|bpath|& suffix& path& \pageref{Dbpath}& + \small ïÈ×ÁÔÙ×ÁÀÝÉÊ ËÒÕÇ ÉÌÉ ÐÒÑÍÏÕÇÏÌØÎÉË\\\hline +%% A box's bounding circle or rectangle\\\hline +\pl\tt \verb|buildcycle|& \small ÓÐÉÓÏË ÐÕÔÅÊ& path& \pageref{buildcy}& +%%\pl\tt \verb|buildcycle|& list of paths& path& \pageref{buildcy}& + \small óÔÒÏÉÔØ ÚÁÍËÎÕÔÙÊ ÐÕÔØ\\\hline +%% Build a cyclic path\\\hline +\bx\tt \verb|circleit|& \small ÓÕÆÆÉËÓ, ËÁÒÔÉÎËÁ& --& \pageref{Dcircit}& +%%\bx\tt \verb|circleit|& suffix, picture& --& \pageref{Dcircit}& + \small ðÏÍÅÓÔÉÔØ ËÁÒÔÉÎËÕ × ËÒÕÇÏ×ÕÀ ÒÁÍËÕ\\\hline +%% Put picture in a circular box\\\hline +\bx\tt \verb|circleit|& \small ÓÕÆÆÉËÓ, ËÁÒÔÉÎËÁ& --& \pageref{Dcircit}& +%%\bx\tt \verb|circleit|& suffix, picture& + \small ðÏÍÅÓÔÉÔØ ÓÔÒÏËÕ × ËÒÕÇÏ×ÕÀ ÒÁÍËÕ\\\hline +%% Put a string in a circular box\\\hline +\bx\tt \verb|circleit|& \small ÓÕÆÆÉËÓ, \tdescr{ÐÕÓÔÏ}& --& \pageref{Dcircit}& +%%\bx\tt \verb|circleit|& suffix, \tdescr{empty}& --& \pageref{Dcircit}& + \small ïÐÒÅÄÅÌÉÔØ ÐÕÓÔÕÀ ËÒÕÇÏ×ÕÀ ÒÁÍËÕ\\\hline +%% Define an empty circular box\\\hline +\pl\tt \verb|dashpattern|& \small ÒÁÓÓÔÏÑÎÉÑ ×ËÌ./×ÙËÌ.& picture& \pageref{Ddshpat}& +%%\pl\tt \verb|dashpattern|& on/off distances& picture& \pageref{Ddshpat}& + \small óÏÚÄÁÔØ ÏÂÒÁÚÅà ÐÕÎËÔÉÒÎÙÈ ÌÉÎÉÊ\\\hline +%% Create a pattern for dashed lines\\\hline +\pl\tt \verb|decr|& \small ÞÉÓÌÏ×ÁÑ ÐÅÒÅÍÅÎÎÁÑ& numeric& \pageref{Dincr}& +%%\pl\tt \verb|decr|& numeric variable& numeric& \pageref{Dincr}& + \small õÍÅÎØÛÉÔØ É ×ÏÚ×ÒÁÔÉÔØ ÎÏ×ÏÅ ÚÎÁÞÅÎÉÅ\\\hline +%% Decrement and return new value\\\hline +\pl\tt \verb|dotlabel|& \small ÓÕÆÆÉËÓ, ËÁÒÔÉÎËÁ, ÐÁÒÁ& --& \pageref{Ddotlab}& +%%\pl\tt \verb|dotlabel|& suffix, picture, pair& --& \pageref{Ddotlab}& + \small îÁÒÉÓÏ×ÁÔØ ÔÏÞËÕ É ÒÑÄÏÍ ËÁÒÔÉÎËÕ\\\hline +%% Mark point and draw picture nearby\\\hline +\pl\tt \verb|dotlabel|& \small ÓÕÆÆÉËÓ, ÓÔÒÏËÁ, ÐÁÒÁ& --& \pageref{Ddotlab}& +%%\pl\tt \verb|dotlabel|& suffix, string, pair& --& \pageref{Ddotlab}& + \small ïÔÍÅÔÉÔØ ÔÏÞËÕ É ÐÏÍÅÓÔÉÔØ ÒÑÄÏÍ ÔÅËÓÔ\\\hline +%% Mark point and place text nearby\\\hline +\pl\tt \verb|dotlabels|& \small ÓÕÆÆÉËÓ, ÎÏÍÅÒÁ ÔÏÞÅË& --& \pageref{Ddotlbs}& +%%\pl\tt \verb|dotlabels|& suffix, point numbers& --& \pageref{Ddotlbs}& + \small ïÔÍÅÔÉÔØ ÔÏÞËÉ {\tt z} ÉÈ ÎÏÍÅÒÁÍÉ\\\hline +%% Mark {\tt z} points with their numbers\\\hline +\bx\tt \verb|drawboxed|& \small ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×& --& \pageref{Ddrbxed}& +%%\bx\tt \verb|drawboxed|& list of suffixes& --& \pageref{Ddrbxed}& + \small îÁÒÉÓÏ×ÁÔØ ÉÍÅÎÏ×ÁÎÎÙÅ ÒÁÍËÉ É ÉÈ ÓÏÄÅÒÖÉÍÏÅ\\\hline +%% Draw the named boxes and their\\ +%%& & & & +%% contents\\\hline +\bx\tt \verb|drawboxes|& \small ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×& --& \pageref{Ddrbxes}& +%%\bx\tt \verb|drawboxes|& list of suffixes& --& \pageref{Ddrbxes}& + \small îÁÒÉÓÏ×ÁÔØ ÉÍÅÎÏ×ÁÎÎÙÅ ÒÁÍËÉ\\\hline +%% Draw the named boxes\\\hline +\pl\tt \verb|drawdot|& \small ÐÁÒÁ& --& \pageref{Ddrawdot}& +%%\pl\tt \verb|drawdot|& pair& --& \pageref{Ddrawdot}& + \small ðÏÓÔÁ×ÉÔØ ÔÏÞËÕ × ÄÁÎÎÏÍ ÍÅÓÔÅ\\\hline +%% Draw a dot at the given point\\\hline +\pl\tt \verb|drawoptions|& \small ÏÐÃÉÉ ÒÉÓÏ×ÁÎÉÑ& --& \pageref{Ddropts}& +%%\pl\tt \verb|drawoptions|& drawing options& --& \pageref{Ddropts}& + \small õÓÔÁÎÏ×ÉÔØ ÏÐÃÉÉ ÄÌÑ ËÏÍÁÎÄ ÒÉÓÏ×ÁÎÉÑ\\\hline +%% Set options for drawing commands\\\hline +\bx\tt \verb|drawunboxed|& \small ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×& --& \pageref{Ddrunbx}& +%%\bx\tt \verb|drawunboxed|& list of suffixes& --& \pageref{Ddrunbx}& + \small òÉÓÏ×ÁÔØ ÓÏÄÅÒÖÉÍÏÅ ÉÍÅÎÏ×ÁÎÎÙÈ ÒÁÍÏË\\\hline +%% Draw contents of named boxes\\\hline +\bx\tt \verb|fixpos|& \small ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×& --& \pageref{Dfixpos}& +%%\bx\tt \verb|fixpos|& list of suffixes& --& \pageref{Dfixpos}& + \small îÁÊÔÉ ÒÁÚÍÅÒ É ÐÏÚÉÃÉÀ ÉÍÅÎÏ×ÁÎÎÙÈ ÒÁÍÏË\\\hline +%% Solve for the size and position of the\\ +%%& & & & +%% named boxes\\\hline +\bx\tt \verb|fixsize|& \small ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×& --& \pageref{Dfixsiz}& +%%\bx\tt \verb|fixsize|& list of suffixes& --& \pageref{Dfixsiz}& + \small îÁÊÔÉ ÒÁÚÍÅÒ ÉÍÅÎÏ×ÁÎÎÙÈ ÒÁÍÏË\\\hline +%% Solve for size of named boxes\\\hline +\pl\tt \verb|image|& \small ÓÔÒÏËÁ& picture& \pageref{Dimage}& +%%\pl\tt \verb|image|& string& picture& \pageref{Dimage}& + \small ÷ÏÚ×ÒÁÝÁÅÔ ÒÉÓÕÎÏË ÉÚ ÔÅËÓÔÁ\\\hline +%% Return picture from text\\\hline +\pl\tt \verb|incr|& \small ÞÉÓÌÏ×ÁÑ ÐÅÒÅÍÅÎÎÁÑ& numeric& \pageref{Dincr}& +%%\pl\tt \verb|incr|& numeric variable& numeric& \pageref{Dincr}& + \small õ×ÅÌÉÞÉÔØ É ×ÏÚ×ÒÁÔÉÔØ ÎÏ×ÏÅ ÚÎÁÞÅÎÉÅ\\\hline +%% Increment and return new value\\\hline +\pl\tt \verb|label|& \small ÓÕÆÆÉËÓ, ËÁÒÔÉÎËÁ, ÐÁÒÁ& --& \pageref{Dlabel}& +%%\pl\tt \verb|label|& suffix, picture, pair& --& \pageref{Dlabel}& + \small éÚÏÂÒÁÚÉÔØ ÒÉÓ. ×ÏÚÌÅ ÚÁÄÁÎÎÏÊ ÔÏÞËÉ\\\hline +%% Draw picture near given point\\\hline +\pl\tt \verb|label|& \small ÓÕÆÆÉËÓ, ÓÔÒÏËÁ, ÐÁÒÁ& --& \pageref{Dlabel}& +%%\pl\tt \verb|label|& suffix, string, pair& --& \pageref{Dlabel}& + \small ðÏÍÅÓÔÉÔØ ÔÅËÓÔ ×ÏÚÌÅ ÚÁÄÁÎÎÏÊ ÔÏÞËÉ\\\hline +%% Place text near given point\\\hline +\pl\tt \verb|labels|& \small ÓÕÆÆÉËÓ, ÎÏÍÅÒÁ ÔÏÞÅË& --& \pageref{Dlabels}& +%%\pl\tt \verb|labels|& suffix, point numbers& --& \pageref{Dlabels}& + \small îÁÒÉÓÏ×ÁÔØ ÞÉÓÌÁ ÐÁÒ {\tt z}, ÂÅÚ ÔÏÞÅË\\\hline +%% Draw {\tt z} point numbers; no dots\\\hline +\pl\tt \verb|max|& \small ÓÐÉÓÏË ÞÉÓÅÌ& numeric& --& +%%\pl\tt \verb|max|& list of numerics& numeric& --& + \small îÁÊÔÉ ÍÁËÓÉÍÕÍ\\\hline +%% Find the maximum\\\hline +\pl\tt \verb|max|& \small ÓÐÉÓÏË ÓÔÒÏË& string& --& +%%\pl\tt \verb|max|& list of strings& string& --& + \small îÁÊÔÉ ÓÌÏ×ÁÒÎÏ ÐÏÓÌÅÄÎÀÀ ÓÔÒÏËÕ\\\hline +%% Find the lexicographically last string\\\hline +\pl\tt \verb|min|& \small ÓÐÉÓÏË ÞÉÓÅÌ& numeric& --& +%%\pl\tt \verb|min|& list of numerics& numeric& --& + \small îÁÊÔÉ ÍÉÎÉÍÕÍ\\\hline +%% Find the minimum\\\hline +\pl\tt \verb|min|& \small ÓÐÉÓÏË ÓÔÒÏË& string& --& +%%\pl\tt \verb|min|& list of strings& string& --& + \small îÁÊÔÉ ÓÌÏ×ÁÒÎÏ ÐÅÒ×ÕÀ ÓÔÒÏËÕ\\\hline +%% Find the lexicographically first string\\\hline +\bx\tt \verb|pic|& \small ÓÕÆÆÉËÓ& picture& \pageref{Dpic}& +%%\bx\tt \verb|pic|& suffix& picture& \pageref{Dpic}& + \small óÏÄÅÒÖÉÍÏÅ ÒÁÍËÉ, ÓÄ×ÉÎÕÔÏÅ × ÐÏÚÉÃÉÀ\\\hline +%% Box contents shifted into position\\\hline +\pl\tt \verb|thelabel|& \small ÓÕÆÆÉËÓ, ËÁÒÔÉÎËÁ, ÐÁÒÁ& picture& \pageref{Dthelab}& +%%\pl\tt \verb|thelabel|& suffix, picture, pair& picture& \pageref{Dthelab}& + \small ëÁÒÔÉÎËÁ, \small ÓÄ×ÉÎÕÔÁÑ ËÁË ÄÌÑ ÍÅÔËÉ ÔÏÞËÉ\\\hline +%% Picture shifted as if to label a point\\\hline +\pl\tt \verb|thelabel|& \small ÓÕÆÆÉËÓ, ÓÔÒÏËÁ, ÐÁÒÁ& picture& \pageref{Dthelab}& +%%\pl\tt \verb|thelabel|& suffix, string, pair& picture& \pageref{Dthelab}& + \small ôÅËÓÔ, ÒÁÚÍÅÝÅÎÎÙÊ ËÁË ÄÌÑ ÍÅÔËÉ ÔÏÞËÉ\\\hline +%% text positioned as if to label a point\\\hline +\pl\tt \verb|z|& \small ÓÕÆÆÉËÓ& pair& \pageref{Dzconv}& +%%\pl\tt \verb|z|& suffix& pair& \pageref{Dzconv}& + \small ðÁÒÁ ${\tt x}\descr{ÓÕÆÆÉËÓ},{\tt y}\descr{ÓÕÆÆÉËÓ})$\\\hline +%% The pair ${\tt x}\descr{suffix},{\tt y}\descr{suffix})$\\\hline +\end{tabular} +$$ +\index{min?\texttt{min}}\index{max?\texttt{max}}% +\label{pseudotab} +\end{table} + +\clearpage + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÁÔÏÍ} \rightarrow \descr{ÐÅÒÅÍÅÎÎÁÑ} \;|\; \descr{ÁÒÇÕÍÅÎÔ}$\\ +%%$\tt \descr{atom} \rightarrow \descr{variable} \;|\; \descr{argument}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ ÉÌÉ ÄÒÏÂØ}$\\ +%%$\tt \qquad \;|\; \descr{number or fraction}$\\ +$\tt \qquad \;|\; \descr{×ÎÕÔÒÅÎÎÑÑ ÐÅÒÅÍÅÎÎÁÑ}$\\ +%%$\tt \qquad \;|\; \descr{internal variable}$\\ +$\tt \qquad \;|\; \hbox{\tt (}\descr{×ÙÒÁÖÅÎÉÅ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; \hbox{\tt (}\descr{expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; begingroup \descr{ÓÐÉÓÏË ËÏÍÁÎÄ} \descr{×ÙÒÁÖÅÎÉÅ} endgroup$\\ +%%$\tt \qquad \;|\; begingroup \descr{statement list} \descr{expression} endgroup$\\ +$\tt \qquad \;|\; \descr{ÏÐÅÒÁÔÏÒ 0-ÕÒÏ×ÎÑ}$\\ +%%$\tt \qquad \;|\; \descr{nullary op}$\\ +$\tt \qquad \;|\; btex \descr{ËÏÍÁÎÄÙ ÐÅÞÁÔÉ} etex$\\ +%%$\tt \qquad \;|\; btex \descr{typesetting commands} etex$\\ +$\tt \qquad \;|\; \descr{ÐÓÅ×ÄÏÆÕÎËÃÉÑ}$\\ +%%$\tt \qquad \;|\; \descr{pseudo function}$\\ +$\tt \descr{ÐÅÒ×ÉÞÎÏÓÔØ} \rightarrow \descr{ÁÔÏÍ}$\\ +%%$\tt \descr{primary} \rightarrow \descr{atom}$\\ +$\tt \qquad \;|\; \hbox{\tt (}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,} \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; \hbox{\tt (}\descr{numeric expression}\hbox{\tt ,} \descr{numeric expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; \hbox{\tt (}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,} \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,} \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; \hbox{\tt (}\descr{numeric expression}\hbox{\tt ,} \descr{numeric expression}\hbox{\tt ,} \descr{numeric expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; \descr{of-ÏÐÅÒÁÔÏÒ} \descr{×ÙÒÁÖÅÎÉÅ} of \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{of operator} \descr{expression} of \descr{primary}$\\ +$\tt \qquad \;|\; \descr{ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{unary op} \descr{primary}$\\ +$\tt \qquad \;|\; str \descr{ÓÕÆÆÉËÓ}$\\ +%%$\tt \qquad \;|\; str \descr{suffix}$\\ +$\tt \qquad \;|\; z \descr{ÓÕÆÆÉËÓ}$\\ +%%$\tt \qquad \;|\; z \descr{suffix}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ}\hbox{\tt [}\descr{×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,}\descr{×ÙÒÁÖÅÎÉÅ}\hbox{\tt ]}$\\ +%%$\tt \qquad \;|\; \descr{numeric atom}\hbox{\tt [}\descr{expression}\hbox{\tt ,}\descr{expression}\hbox{\tt ]}$\\ +$\tt \qquad \;|\; \descr{ÏÐÅÒÁÃÉÑ ÓËÁÌÑÒÎÏÇÏ ÕÍÎÏÖÅÎÉÑ} \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{scalar multiplication op} \descr{primary}$\\ +$\tt \descr{×ÔÏÒÉÞÎÏÓÔØ} \rightarrow \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{secondary} \rightarrow \descr{primary}$\\ +$\tt \qquad \;|\; \descr{×ÔÏÒÉÞÎÏÓÔØ} \descr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{secondary} \descr{primary binop} \descr{primary}$\\ +$\tt \qquad \;|\; \descr{×ÔÏÒÉÞÎÏÓÔØ} \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ}$\\ +%%$\tt \qquad \;|\; \descr{secondary} \descr{transformer}$\\ +$\tt \descr{ÔÒÅÔÉÞÎÏÓÔØ} \rightarrow \descr{×ÔÏÒÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{tertiary} \rightarrow \descr{secondary}$\\ +$\tt \qquad \;|\; \descr{ÔÒÅÔÉÞÎÏÓÔØ} \descr{×ÔÏÒÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \descr{×ÔÏÒÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{tertiary} \descr{secondary binop} \descr{secondary}$\\ +$\tt \descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ} \rightarrow \descr{ÔÒÅÔÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{subexpression} \rightarrow \descr{tertiary}$\\ +$\tt \qquad \;|\; \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \descr{ÓÏÅÄÉÎÅÎÉÅ ÐÕÔÅÊ} \descr{ÕÚÅÌ ÐÕÔÉ}$\\ +%%$\tt \qquad \;|\; \descr{path expression} \descr{path join} \descr{path knot}$\\ +$\tt \descr{×ÙÒÁÖÅÎÉÅ} \rightarrow \descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{expression} \rightarrow \descr{subexpression}$\\ +$\tt \qquad \;|\; \descr{×ÙÒÁÖÅÎÉÅ} \descr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \descr{ÔÒÅÔÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{expression} \descr{tertiary binop} \descr{tertiary}$\\ +$\tt \qquad \;|\; \descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ ÐÕÔÉ} \descr{ÕËÁÚÁÔÅÌØ ÎÁÐÒÁ×ÌÅÎÉÑ}$\\ +%%$\tt \qquad \;|\; \descr{path subexpression} \descr{direction specifier}$\\ +$\tt \qquad \;|\; \descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ ÐÕÔÉ} \descr{ÓÏÅÄÉÎÅÎÉÅ ÐÕÔÅÊ} cycle$\\ +%%$\tt \qquad \;|\; \descr{path subexpression} \descr{path join} cycle$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ÕÚÅÌ ÐÕÔÉ} \rightarrow \descr{ÔÒÅÔÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{path knot} \rightarrow \descr{tertiary}$\\ +$\tt \descr{ÓÏÅÄÉÎÅÎÉÅ ÐÕÔÅÊ} \rightarrow -{}-$\\ +%%$\tt \descr{path join} \rightarrow --$\\ +$\tt \qquad \;|\; \descr{ÕËÁÚÁÔÅÌØ ÎÁÐÒÁ×ÌÅÎÉÑ} \descr{ÂÁÚÏ×ÏÅ ÓÏÅÄÉÎÅÎÉÅ ÐÕÔÅÊ} \descr{ÕËÁÚÁÔÅÌØ ÎÁÐÒÁ×ÌÅÎÉÑ}$\\ +%%$\tt \qquad \;|\; \descr{direction specifier} \descr{basic path join} \descr{direction specifier}$\\ +$\tt \descr{ÕËÁÚÁÔÅÌØ ÎÁÐÒÁ×ÌÅÎÉÑ} \rightarrow \descr{ÐÕÓÔÏ}$\\ +%%$\tt \descr{direction specifier} \rightarrow \descr{empty}$\\ +$\tt \qquad \;|\; \{{curl \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\}}$\\ +%%$\tt \qquad \;|\; \char`\{curl \descr{numeric expression}\char`\}$\\ +$\tt \qquad \;|\; \{{\descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\}}$\\ +%%$\tt \qquad \;|\; \char`\{\descr{pair expression}\char`\}$\\ +$\tt \qquad \;|\; \{{\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\}}$\\ +%%$\tt \qquad \;|\; \char`\{\descr{numeric expression}\hbox{\tt ,}\descr{numeric expression}\char`\}$\\ +$\tt \descr{ÂÁÚÏ×ÏÅ ÓÏÅÄÉÎÅÎÉÅ ÐÕÔÅÊ} \rightarrow \hbox{\tt ..} \;|\; \hbox{\tt ...} \;|\; \hbox{\tt ..}\descr{ÎÁÐÒÑÖÅÎÉÅ}\hbox{\tt ..} \;|\; \hbox{\tt ..}\descr{ÕÐÒÁ×ÌÅÎÉÅ}\hbox{\tt ..}$\\ +%%$\tt \descr{basic path join} \rightarrow \hbox{\tt ..} \;|\; \hbox{\tt ...} \;|\; \hbox{\tt ..}\descr{tension}\hbox{\tt ..} \;|\; \hbox{\tt ..}\descr{controls}\hbox{\tt ..}$\\ +$\tt \descr{ÎÁÐÒÑÖÅÎÉÅ} \rightarrow tension \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{tension} \rightarrow tension \descr{numeric primary}$\\ +$\tt \qquad \;|\; tension \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ} and \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; tension \descr{numeric primary} and \descr{numeric primary}$\\ +$\tt \descr{ÕÐÒÁ×ÌÅÎÉÅ} \rightarrow controls \descr{ÐÅÒ×ÉÞÎÏÓÔØ-ÐÁÒÁ}$\\ +%%$\tt \descr{controls} \rightarrow controls \descr{pair primary}$\\ +$\tt \qquad \;|\; controls \descr{ÐÅÒ×ÉÞÎÏÓÔØ-ÐÁÒÁ} and \descr{ÐÅÒ×ÉÞÎÏÓÔØ-ÐÁÒÁ}$\\ +%%$\tt \qquad \;|\; controls \descr{pair primary} and \descr{pair primary}$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ÁÒÇÕÍÅÎÔ} \rightarrow \descr{ÓÉÍ×ÏÌÉÞÅÓËÉ ÚÎÁË}$\\ +%%$\tt \descr{argument} \rightarrow \descr{symbolic token}$\\ +$\tt \descr{ÞÉÓÌÏ ÉÌÉ ÄÒÏÂØ} \rightarrow \descr{ÞÉÓÌÏ}\hbox{\tt /}\descr{ÞÉÓÌÏ}$\\ +%%$\tt \descr{number or fraction} \rightarrow \descr{number}\hbox{\tt /}\descr{number}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ, ÚÁ ËÏÔÏÒÙÍ ÎÅÔ `\hbox{\tt /}\tdescr{ÞÉÓÌÏ}'}$\\ +%%$\tt \qquad \;|\; \descr{number not followed by `\hbox{\tt /}\tdescr{number}'}$\\ +$\tt \descr{ÏÐÅÒÁÃÉÑ ÓËÁÌÑÒÎÏÇÏ ÕÍÎÏÖÅÎÉÑ} \rightarrow + \;|\; -$\\ +%%$\tt \descr{scalar multiplication op} \rightarrow + \;|\; -$\\ +$\tt \qquad \;|\; \descr{`\tdescr{ÞÉÓÌÏ ÉÌÉ ÄÒÏÂØ}', ÚÁ ËÏÔÏÒÙÍ ÎÅÔ `\tdescr{ÏÐÅÒÁÃÉÉ ÓÌÏÖÅÎÉÑ}\tdescr{ÞÉÓÌÏ}'}$ +%%$\tt \qquad \;|\; \descr{`\tdescr{number or fraction}' not followed by `\tdescr{add op}\tdescr{number}'}$ +\end{ctabbing} +\caption{þÁÓÔØ 1 ÓÉÎÔÁËÓÉÓÁ ×ÙÒÁÖÅÎÉÊ} +%%\caption{Part 1 of the syntax for expressions} +\index{×ÙÒÁÖÅÎÉÅ?\tdescr{×ÙÒÁÖÅÎÉÅ}}\index{ÏÐÅÒÁÔÏÒ 0?\tdescr{ÏÐÅÒÁÔÏÒ 0-ÕÒÏ×ÎÑ}}\index{of operator?\tdescr{of-ÏÐÅÒÁÔÏÒ}}% +\index{ÕÚÅÌ ÐÕÔÉ?\tdescr{ÕÚÅÌ ÐÕÔÉ}}\index{ÐÅÒ×ÉÞÎÏÓÔØ?\tdescr{ÐÅÒ×ÉÞÎÏÓÔØ}}\index{ÐÅÒ×ÉÞÎÙÊ binop?\tdescr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}% +\index{×ÔÏÒÉÞÎÏÓÔØ?\tdescr{×ÔÏÒÉÞÎÏÓÔØ}}\index{×ÔÏÒÉÞÎÙÊ binop?\tdescr{×ÔÏÒÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}\index{ÓÕÆÆÉËÓ?\tdescr{ÓÕÆÆÉËÓ}}% +\index{ÔÒÅÔÉÞÎÏÓÔØ?\tdescr{ÔÒÅÔÉÞÎÏÓÔØ}}\index{ÔÒÅÔÉÞÎÙÊ binop?\tdescr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}\index{ÕÎÁÒÎÙÊ op?\tdescr{ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}% +%%\index{expression?\tdescr{expression}}\index{nullary op?\tdescr{nullary op}}\index{of operator?\tdescr{of operator}}% +%%\index{path knot?\tdescr{path knot}}\index{primary?\tdescr{primary}}\index{primary binop?\tdescr{primary binop}}% +%%\index{secondary?\tdescr{secondary}}\index{secondary binop?\tdescr{secondary binop}}\index{suffix?\tdescr{suffix}}% +%%\index{tertiary?\tdescr{tertiary}}\index{tertiary binop?\tdescr{tertiary binop}}\index{unary op?\tdescr{unary op}}% +\label{syexpr1} +\end{figure} + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ} \rightarrow rotated \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{transformer} \rightarrow rotated \descr{numeric primary}$\\ +$\tt \qquad \;|\; scaled \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; scaled \descr{numeric primary}$\\ +$\tt \qquad \;|\; shifted \descr{ÐÅÒ×ÉÞÎÏÓÔØ-ÐÁÒÁ}$\\ +%%$\tt \qquad \;|\; shifted \descr{pair primary}$\\ +$\tt \qquad \;|\; slanted \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; slanted \descr{numeric primary}$\\ +$\tt \qquad \;|\; transformed \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ-ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; transformed \descr{transform primary}$\\ +$\tt \qquad \;|\; xscaled \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; xscaled \descr{numeric primary}$\\ +$\tt \qquad \;|\; yscaled \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \qquad \;|\; yscaled \descr{numeric primary}$\\ +$\tt \qquad \;|\; zscaled \descr{ÐÅÒ×ÉÞÎÏÓÔØ-ÐÁÒÁ}$\\ +%%$\tt \qquad \;|\; zscaled \descr{pair primary}$\\ +$\tt \qquad \;|\; reflectedabout\hbox{\tt (}\descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; reflectedabout\hbox{\tt (}\descr{pair expression}\hbox{\tt ,} \descr{pair expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; rotatedaround\hbox{\tt (}\descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; rotatedaround\hbox{\tt (}\descr{pair expression}\hbox{\tt ,} \descr{numeric expression}\hbox{\tt )}$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ÏÐÅÒÁÔÏÒ 0-ÕÒÏ×ÎÑ} \rightarrow false \;|\; normaldeviate \;|\; nullpen \;|\; nullpicture \;|\; pencircle$\\ +%%$\tt \descr{nullary op} \rightarrow false \;|\; normaldeviate \;|\; nullpen \;|\; nullpicture \;|\; pencircle$\\ +$\tt \qquad \;|\; true \;|\; whatever$\\ +$\tt \descr{ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \rightarrow \descr{ÔÉÐ}$\\ +%%$\tt \descr{unary op} \rightarrow \descr{type}$\\ +$\tt \qquad \;|\; abs \;|\; angle \;|\; arclength \;|\; ASCII \;|\; bbox \;|\; blackpart \;|\; bluepart \;|\; bot \;|\; bounded$\\ +$\tt \qquad \;|\; ceiling \;|\; center \;|\; char \;|\; clipped \;|\; colormodel \;|\; cosd \;|\; cyanpart \;|\; cycle$\\ +$\tt \qquad \;|\; dashpart \;|\; decimal \;|\; dir \;|\; floor \;|\; filled \;|\; fontpart \;|\; fontsize$\\ +$\tt \qquad \;|\; greenpart \;|\; greypart \;|\; hex \;|\; inverse \;|\; known \;|\; length \;|\; lft \;|\; llcorner$\\ +$\tt \qquad \;|\; lrcorner\;|\; magentapart \;|\; makepath \;|\; makepen \;|\; mexp \;|\; mlog \;|\; not \;|\; oct \;|\; odd$\\ +$\tt \qquad \;|\; pathpart \;|\; penpart \;|\; readfrom \;|\; redpart \;|\; reverse \;|\; round \;|\; rt \;|\; sind \;|\; sqrt$\\ +$\tt \qquad \;|\; stroked \;|\; textpart \;|\; textual \;|\; top \;|\; ulcorner$\\ +$\tt \qquad \;|\; uniformdeviate \;|\; unitvector \;|\; unknown \;|\; urcorner \;|\; xpart \;|\; xxpart$\\ +$\tt \qquad \;|\; xypart \;|\; yellowpart \;|\; ypart \;|\; yxpart \;|\; yypart$\\ +$\tt \descr{ÔÉÐ} \rightarrow boolean \;|\; cmykcolor \;|\; color \;|\; numeric \;|\; pair$\\ +%%$\tt \descr{type} \rightarrow boolean \;|\; cmykcolor \;|\; color \;|\; numeric \;|\; pair$\\ +$\tt \qquad \;|\; path \;|\; pen \;|\; picture \;|\; rgbcolor \;|\; string \;|\; transform$\\ +$\tt \descr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \rightarrow \hbox{\tt *} \;|\; \hbox{\tt /} \;|\; \hbox{\tt **} \;|\; and$\\ +%%$\tt \descr{primary binop} \rightarrow \hbox{\tt *} \;|\; \hbox{\tt /} \;|\; \hbox{\tt **} \;|\; and$\\ +$\tt \qquad \;|\; dotprod \;|\; div \;|\; infont \;|\; mod$\\ +$\tt \descr{×ÔÏÒÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \rightarrow + \;|\; - \;|\; ++ \;|\; +-+ \;|\; or$\\ +%%$\tt \descr{secondary binop} \rightarrow + \;|\; - \;|\; ++ \;|\; +-+ \;|\; or$\\ +$\tt \qquad \;|\; intersectionpoint \;|\; intersectiontimes$\\ +$\tt \descr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ} \rightarrow \hbox{\tt \&} \;|\; \hbox{\verb|<|} \;|\; \hbox{\verb|<=|} \;|\; \hbox{\verb|<>|} \;|\; \hbox{\tt =} \;|\; \hbox{\verb|>|} \;|\; \hbox{\verb|>=|}$\\ +%%$\tt \descr{tertiary binop} \rightarrow \hbox{\tt \&} \;|\; \hbox{\verb|<|} \;|\; \hbox{\verb|<=|} \;|\; \hbox{\verb|<>|} \;|\; \hbox{\tt =} \;|\; \hbox{\verb|>|} \;|\; \hbox{\verb|>=|}$\\ +$\tt \qquad \;|\; cutafter \;|\; cutbefore$\\ +$\tt \descr{of-ÏÐÅÒÁÔÏÒ} \rightarrow arctime \;|\; direction \;|\; directiontime \;|\; directionpoint$\\ +%%$\tt \descr{of operator} \rightarrow arctime \;|\; direction \;|\; directiontime \;|\; directionpoint$\\ +$\tt \qquad \;|\; penoffset \;|\; point \;|\; postcontrol \;|\; precontrol \;|\; subpath$\\ +$\tt \qquad \;|\; substring$\\ +$\tt $\\ +$\tt \descr{ÐÅÒÅÍÅÎÎÁÑ} \rightarrow \descr{ÜÔÉËÅÔËÁ}\descr{ÓÕÆÆÉËÓ}$\\ +%%$\tt \descr{variable} \rightarrow \descr{tag}\descr{suffix}$\\ +$\tt \descr{ÓÕÆÆÉËÓ} \rightarrow \descr{ÐÕÓÔÏ} \;|\; \descr{ÓÕÆÆÉËÓ}\descr{ÉÎÄÅËÓ} \;|\; \descr{ÓÕÆÆÉËÓ}\descr{ÜÔÉËÅÔËÁ}$\\ +%%$\tt \descr{suffix} \rightarrow \descr{empty} \;|\; \descr{suffix}\descr{subscript} \;|\; \descr{suffix}\descr{tag}$\\ +$\tt \qquad \;|\; \descr{ÐÁÒÁÍÅÔÒ-ÓÕÆÆÉËÓ}$\\ +%%$\tt \qquad \;|\; \descr{suffix parameter}$\\ +$\tt \descr{ÉÎÄÅËÓ} \rightarrow \descr{ÞÉÓÌÏ} \;|\; \hbox{\tt [}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt ]}$\\ +%%$\tt \descr{subscript} \rightarrow \descr{number} \;|\; \hbox{\tt [}\descr{numeric expression}\hbox{\tt ]}$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{×ÎÕÔÒÅÎÎÑÑ ÐÅÒÅÍÅÎÎÁÑ} \rightarrow ahangle \;|\; ahlength \;|\; bboxmargin$\\ +%%$\tt \descr{internal variable} \rightarrow ahangle \;|\; ahlength \;|\; bboxmargin$\\ +$\tt \qquad \;|\; charcode \;|\; day \;|\; defaultcolormodel \;|\; defaultpen \;|\; defaultscale$\\ +$\tt \qquad \;|\; labeloffset \;|\; linecap \;|\; linejoin \;|\; miterlimit \;|\; month$\\ +$\tt \qquad \;|\; pausing \;|\; prologues \;|\; showstopping \;|\; time \;|\; tracingoutput$\\ +$\tt \qquad \;|\; tracingcapsules \;|\; tracingchoices \;|\; tracingcommands$\\ +$\tt \qquad \;|\; tracingequations \;|\; tracinglostchars \;|\; tracingmacros$\\ +$\tt \qquad \;|\; tracingonline \;|\; tracingrestores \;|\; tracingspecs$\\ +$\tt \qquad \;|\; tracingstats \;|\; tracingtitles \;|\; truecorners$\\ +$\tt \qquad \;|\; warningcheck \;|\; year$\\ +$\tt \qquad \;|\; \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË, ÏÐÒÅÄÅÌÅÎÎÙÊ {\tt newinternal}}$ +%%$\tt \qquad \;|\; \descr{symbolic token defined by {\tt newinternal}}$ +\end{ctabbing} +\caption{þÁÓÔØ 2 ÓÉÎÔÁËÓÉÓÁ ×ÙÒÁÖÅÎÉÊ} +%%\caption{Part 2 of the syntax for expressions} +\index{ÏÐÅÒÁÔÏÒ 0?\tdescr{ÏÐÅÒÁÔÏÒ 0-ÕÒÏ×ÎÑ}}\index{of operator?\tdescr{of-ÏÐÅÒÁÔÏÒ}}\index{ÐÅÒ×ÉÞÎÙÊ binop?\tdescr{ÐÅÒ×ÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}% +\index{×ÔÏÒÉÞÎÙÊ binop?\tdescr{×ÔÏÒÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}\index{ÉÎÄÅËÓ?\tdescr{ÉÎÄÅËÓ}}\index{ÓÕÆÆÉËÓ?\tdescr{ÓÕÆÆÉËÓ}}% +\index{ÔÒÅÔÉÞÎÙÊ binop?\tdescr{ÔÒÅÔÉÞÎÙÊ ÂÉÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}\index{ÕÎÁÒÎÙÊ op?\tdescr{ÕÎÁÒÎÙÊ ÏÐÅÒÁÔÏÒ}}% +%%\index{nullary op?\tdescr{nullary op}}\index{of operator?\tdescr{of operator}}\index{primary binop?\tdescr{primary binop}}% +%%\index{secondary binop?\tdescr{secondary binop}}\index{subscript?\tdescr{subscript}}\index{suffix?\tdescr{suffix}}% +%%\index{tertiary binop?\tdescr{tertiary binop}}\index{unary op?\tdescr{unary op}}% +\label{syexpr2} +\end{figure} + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÐÓÅ×ÄÏÆÕÎËÃÉÑ} \rightarrow min\hbox{\tt (}\descr{ÓÐÉÓÏË ×ÙÒÁÖÅÎÉÊ}\hbox{\tt )}$\\ +%%$\tt \descr{pseudo function} \rightarrow min\hbox{\tt (}\descr{expression list}\hbox{\tt )}$\\ +$\tt \qquad \;|\; max\hbox{\tt (}\descr{ÓÐÉÓÏË ×ÙÒÁÖÅÎÉÊ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; max\hbox{\tt (}\descr{expression list}\hbox{\tt )}$\\ +$\tt \qquad \;|\; incr\hbox{\tt (}\descr{ÞÉÓÌÏ×ÁÑ ÐÅÒÅÍÅÎÎÁÑ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; incr\hbox{\tt (}\descr{numeric variable}\hbox{\tt )}$\\ +$\tt \qquad \;|\; decr\hbox{\tt (}\descr{ÞÉÓÌÏ×ÁÑ ÐÅÒÅÍÅÎÎÁÑ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; decr\hbox{\tt (}\descr{numeric variable}\hbox{\tt )}$\\ +$\tt \qquad \;|\; dashpattern\hbox{\tt (}\descr{ÓÐÉÓÏË on\hbox{\tt /}off}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; dashpattern\hbox{\tt (}\descr{on\hbox{\tt /}off list}\hbox{\tt )}$\\ +$\tt \qquad \;|\; interpath\hbox{\tt (}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; interpath\hbox{\tt (}\descr{numeric expression}\hbox{\tt ,} \descr{path expression}\hbox{\tt ,} \descr{path expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; buildcycle\hbox{\tt (}\descr{ÓÐÉÓÏË ×ÙÒÁÖÅÎÉÊ-ÐÕÔÅÊ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; buildcycle\hbox{\tt (}\descr{path expression list}\hbox{\tt )}$\\ +$\tt \qquad \;|\; thelabel\descr{ÓÕÆÆÉËÓ ÍÅÔËÉ}\hbox{\tt (}\descr{×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; thelabel\descr{label suffix}\hbox{\tt (}\descr{expression}\hbox{\tt ,} \descr{pair expression}\hbox{\tt )}$\\ +$\tt \descr{ÓÐÉÓÏË ×ÙÒÁÖÅÎÉÊ-ÐÕÔÅÊ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}$\\ +%%$\tt \descr{path expression list} \rightarrow \descr{path expression}$\\ +$\tt \qquad \;|\; \descr{ÓÐÉÓÏË ×ÙÒÁÖÅÎÉÊ-ÐÕÔÅÊ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}$\\ +%%$\tt \qquad \;|\; \descr{path expression list}\hbox{\tt ,} \descr{path expression}$\\ +$\tt \descr{ÓÐÉÓÏË on\hbox{\tt /}off} \rightarrow \descr{ÓÐÉÓÏË on\hbox{\tt /}off}\descr{ÐÕÎËÔ on\hbox{\tt /}off} \;|\; \descr{ÐÕÎËÔ on\hbox{\tt /}off}$\\ +%%$\tt \descr{on\hbox{\tt /}off list} \rightarrow \descr{on\hbox{\tt /}off list}\descr{on\hbox{\tt /}off clause} \;|\; \descr{on\hbox{\tt /}off clause}$\\ +$\tt \descr{ÐÕÎËÔ on\hbox{\tt /}off} \rightarrow on \descr{ÞÉÓÌÏ×ÁÑ ÔÒÅÔÉÞÎÏÓÔØ} \;|\; off \descr{ÞÉÓÌÏ×ÁÑ ÔÒÅÔÉÞÎÏÓÔØ}$ +%%$\tt \descr{on\hbox{\tt /}off clause} \rightarrow on \descr{numeric tertiary} \;|\; off \descr{numeric tertiary}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ÍÁËÒÏÓÏ×, ÐÏÈÏÖÉÈ ÎÁ ÆÕÎËÃÉÉ} +%%\caption{The syntax for function-like macros} +\index{label suffix?\tdescr{ÓÕÆÆÉËÓ ÍÅÔËÉ}}% +%%\index{label suffix?\tdescr{label suffix}}% +\label{sypseudo} +\end{figure} + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÌÏÇÉÞÅÓËÏÅ ×ÙÒÁÖÅÎÉÅ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{boolean expression} \rightarrow \descr{expression}$\\ +$\tt \descr{×ÙÒÁÖÅÎÉÅ-cmyk-Ã×ÅÔ } \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{cmykcolor expression} \rightarrow \descr{expression}$\\ +$\tt \descr{×ÙÒÁÖÅÎÉÅ-Ã×ÅÔ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{color expression} \rightarrow \descr{expression}$\\ +$\tt \descr{ÞÉÓÌÏ×ÏÊ ÁÔÏÍ} \rightarrow \descr{ÁÔÏÍ}$\\ +%%$\tt \descr{numeric atom} \rightarrow \descr{atom}$\\ +$\tt \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{numeric expression} \rightarrow \descr{expression}$\\ +$\tt \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒ×ÉÞÎÏÓÔØ} \rightarrow \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{numeric primary} \rightarrow \descr{primary}$\\ +$\tt \descr{ÞÉÓÌÏ×ÁÑ ÔÒÅÔÉÞÎÏÓÔØ} \rightarrow \descr{ÔÒÅÔÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{numeric tertiary} \rightarrow \descr{tertiary}$\\ +$\tt \descr{ÞÉÓÌÏ×ÁÑ ÐÅÒÅÍÅÎÎÁÑ} \rightarrow \descr{ÐÅÒÅÍÅÎÎÁÑ} \;|\; \descr{×ÎÕÔÒÅÎÎÑÑ ÐÅÒÅÍÅÎÎÁÑ}$\\ +%%$\tt \descr{numeric variable} \rightarrow \descr{variable} \;|\; \descr{internal variable}$\\ +$\tt \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{pair expression} \rightarrow \descr{expression}$\\ +$\tt \descr{ÐÁÒÁ-ÐÅÒ×ÉÞÎÏÓÔØ} \rightarrow \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$\\ +%%$\tt \descr{pair primary} \rightarrow \descr{primary}$\\ +$\tt \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{path expression} \rightarrow \descr{expression}$\\ +$\tt \descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \rightarrow \descr{ÐÏÄ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{path subexpression} \rightarrow \descr{subexpression}$\\ +$\tt \descr{×ÙÒÁÖÅÎÉÅ-ÐÅÒÏ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{pen expression} \rightarrow \descr{expression}$\\ +$\tt \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{picture expression} \rightarrow \descr{expression}$\\ +$\tt \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ} \rightarrow \descr{ÐÅÒÅÍÅÎÎÁÑ}$\\ +%%$\tt \descr{picture variable} \rightarrow \descr{variable}$\\ +$\tt \descr{×ÙÒÁÖÅÎÉÅ-rgb-Ã×ÅÔ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{rgbcolor expression} \rightarrow \descr{expression}$\\ +$\tt \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{string expression} \rightarrow \descr{expression}$\\ +$\tt \descr{ÐÁÒÁÍÅÔÒ-ÓÕÆÆÉËÓ} \rightarrow \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \descr{suffix parameter} \rightarrow \descr{parameter}$\\ +$\tt \descr{ÔÒÁÎÓÆÏÒÍÁÃÉÑ-ÐÅÒ×ÉÞÎÏÓÔØ} \rightarrow \descr{ÐÅÒ×ÉÞÎÏÓÔØ}$ +%%$\tt \descr{transform primary} \rightarrow \descr{primary}$ +\end{ctabbing} +\caption{òÁÚÌÉÞÎÙÅ ÐÒÁ×ÉÌÁ, ÎÕÖÎÙÅ ÄÌÑ ÚÁ×ÅÒÛÅÎÉÑ îæâî} +%%\caption{Miscellaneous productions needed to complete the BNF} +\label{sytypexpr} +\end{figure} + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÐÒÏÇÒÁÍÍÁ} \rightarrow \descr{ÓÐÉÓÏË ÍÅÔÁËÏÍÁÎÄ} end$\\ +%%$\tt \descr{program} \rightarrow \descr{statement list} end$\\ +$\tt \descr{ÓÐÉÓÏË ÍÅÔÁËÏÍÁÎÄ} \rightarrow \descr{ÐÕÓÔÏ} \;|\; \descr{ÓÐÉÓÏË ÍÅÔÁËÏÍÁÎÄ} \hbox{\tt ;} \descr{ÍÅÔÁËÏÍÁÎÄÁ}$\\ +%%$\tt \descr{statement list} \rightarrow \descr{empty} \;|\; \descr{statement list} \hbox{\tt ;} \descr{statement}$\\ +$\tt \descr{ÍÅÔÁËÏÍÁÎÄÁ} \rightarrow \descr{ÐÕÓÔÏ}$\\ +%%$\tt \descr{statement} \rightarrow \descr{empty}$\\ +$\tt \qquad \;|\; \descr{ÕÒÁ×ÎÅÎÉÅ} \;|\; \descr{ÐÒÉÓ×ÁÉ×ÁÎÉÅ}$\\ +%%$\tt \qquad \;|\; \descr{equation} \;|\; \descr{assignment}$\\ +$\tt \qquad \;|\; \descr{ÄÅËÌÁÒÁÃÉÑ} \;|\; \descr{ÏÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ}$\\ +%%$\tt \qquad \;|\; \descr{declaration} \;|\; \descr{macro definition}$\\ +$\tt \qquad \;|\; \descr{ÂÌÏË} \;|\; \descr{ÐÓÅ×ÄÏÐÒÏÃÅÄÕÒÁ}$\\ +%%$\tt \qquad \;|\; \descr{compound} \;|\; \descr{pseudo procedure}$\\ +$\tt \qquad \;|\; \descr{ËÏÍÁÎÄÁ}$\\ +%%$\tt \qquad \;|\; \descr{command}$\\ +$\tt \descr{ÂÌÏË} \rightarrow begingroup \descr{ÓÐÉÓÏË ÍÅÔÁËÏÍÁÎÄ} endgroup$\\ +%%$\tt \descr{compound} \rightarrow begingroup \descr{statement list} endgroup$\\ +$\tt \qquad \;|\; beginfig\hbox{\tt (}\descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}\hbox{\tt );} \descr{ÓÐÉÓÏË ÍÅÔÁËÏÍÁÎÄ}\hbox{\tt ;} endfig$\\ +%%$\tt \qquad \;|\; beginfig\hbox{\tt (}\descr{numeric expression}\hbox{\tt );} \descr{statement list}\hbox{\tt ;} endfig$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ÕÒÁ×ÎÅÎÉÅ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ} \hbox{\tt =} \descr{ÐÒÁ×ÁÑ ÞÁÓÔØ}$\\ +%%$\tt \descr{equation} \rightarrow \descr{expression} \hbox{\tt =} \descr{right-hand side}$\\ +$\tt \descr{ÐÒÉÓ×ÁÉ×ÁÎÉÅ} \rightarrow \descr{ÐÅÒÅÍÅÎÎÁÑ} \hbox{\tt :=} \descr{ÐÒÁ×ÁÑ ÞÁÓÔØ}$\\ +%%$\tt \descr{assignment} \rightarrow \descr{variable} \hbox{\tt :=} \descr{right-hand side}$\\ +$\tt \qquad \;|\; \descr{×ÎÕÔÒÅÎÎÑÑ ÐÅÒÅÍÅÎÎÁÑ} \hbox{\tt :=} \descr{ÐÒÁ×ÁÑ ÞÁÓÔØ}$\\ +%%$\tt \qquad \;|\; \descr{internal variable} \hbox{\tt :=} \descr{right-hand side}$\\ +$\tt \descr{ÐÒÁ×ÁÑ ÞÁÓÔØ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ} \;|\; \descr{ÕÒÁ×ÎÅÎÉÅ} \;|\; \descr{ÐÒÉÓ×ÁÉ×ÁÎÉÅ}$\\ +%%$\tt \descr{right-hand side} \rightarrow \descr{expression} \;|\; \descr{equation} \;|\; \descr{assignment}$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ÄÅËÌÁÒÁÃÉÑ} \rightarrow \descr{ÔÉÐ} \descr{ÓÐÉÓÏË ÄÅËÌÁÒÁÃÉÉ}$\\ +%%$\tt \descr{declaration} \rightarrow \descr{type} \descr{declaration list}$\\ +$\tt \descr{ÓÐÉÓÏË ÄÅËÌÁÒÁÃÉÉ} \rightarrow \descr{ÏÂÏÂÝÅÎÉÅ ÐÅÒÅÍÅÎÎÏÊ}$\\ +%%$\tt \descr{declaration list} \rightarrow \descr{generic variable}$\\ +$\tt \qquad \;|\; \descr{ÓÐÉÓÏË ÄÅËÌÁÒÁÃÉÉ}\hbox{\tt ,} \descr{ÏÂÏÂÝÅÎÉÅ ÐÅÒÅÍÅÎÎÏÊ}$\\ +%%$\tt \qquad \;|\; \descr{declaration list}\hbox{\tt ,} \descr{generic variable}$\\ +$\tt \descr{ÏÂÏÂÝÅÎÉÅ ÐÅÒÅÍÅÎÎÏÊ} \rightarrow \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} \descr{ÏÂÏÂÝÅÎÉÅ ÓÕÆÆÉËÓÁ}$\\ +%%$\tt \descr{generic variable} \rightarrow \descr{symbolic token} \descr{generic suffix}$\\ +$\tt \descr{ÏÂÏÂÝÅÎÉÅ ÓÕÆÆÉËÓÁ} \rightarrow \descr{ÐÕÓÔÏ} \;|\; \descr{ÏÂÏÂÝÅÎÉÅ ÓÕÆÆÉËÓÁ} \descr{ÜÔÉËÅÔËÁ}$\\ +%%$\tt \descr{generic suffix} \rightarrow \descr{empty} \;|\; \descr{generic suffix} \descr{tag}$\\ +$\tt \qquad \;|\; \descr{ÏÂÏÂÝÅÎÉÅ ÓÕÆÆÉËÓÁ} \hbox{\tt []}$\\ +%%$\tt \qquad \;|\; \descr{generic suffix} \hbox{\tt []}$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ÏÐÒÅÄÅÌÅÎÉÅ ÍÁËÒÏÓÁ} \rightarrow \descr{ÚÁÇÏÌÏ×ÏË ÍÁËÒÏÓÁ} \hbox{\tt =} \descr{ÔÅËÓÔ ÚÁÍÅÎÙ} enddef$\\ +%%$\tt \descr{macro definition} \rightarrow \descr{macro heading} \hbox{\tt =} \descr{replacement text} enddef$\\ +$\tt \descr{ÚÁÇÏÌÏ×ÏË ÍÁËÒÏÓÁ} \rightarrow def \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} \descr{ÎÅÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ}$\\ +%%$\tt \descr{macro heading} \rightarrow def \descr{symbolic token} \descr{delimited part} \descr{undelimited part}$\\ +$\tt \qquad \;|\; vardef \descr{ÏÂÏÂÝÅÎÉÅ ÐÅÒÅÍÅÎÎÏÊ} \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} \descr{ÎÅÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ}$\\ +%%$\tt \qquad \;|\; vardef \descr{generic variable} \descr{delimited part} \descr{undelimited part}$\\ +$\tt \qquad \;|\; vardef \descr{ÏÂÏÂÝÅÎÉÅ ÐÅÒÅÍÅÎÎÏÊ} \hbox{\verb|@#|} \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} \descr{ÎÅÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ}$\\ +%%$\tt \qquad \;|\; vardef \descr{generic variable} \hbox{\verb|@#|} \descr{delimited part} \descr{undelimited part}$\\ +$\tt \qquad \;|\; \descr{ÏÐÒÅÄÅÌÅÎÉÅ ÂÉÎÁÒÎÏÓÔÉ} \descr{ÐÁÒÁÍÅÔÒ} \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \qquad \;|\; \descr{binary def} \descr{parameter} \descr{symbolic token} \descr{parameter}$\\ +$\tt \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} \rightarrow \descr{ÐÕÓÔÏ}$\\ +%%$\tt \descr{delimited part} \rightarrow \descr{empty}$\\ +$\tt \qquad \;|\; \descr{ÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ}\hbox{\tt (}\descr{ÔÉÐ ÐÁÒÁÍÅÔÒÁ} \descr{ÐÁÒÁÍÅÔÒÙ-ÚÎÁËÉ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; \descr{delimited part}\hbox{\tt (}\descr{parameter type} \descr{parameter tokens}\hbox{\tt )}$\\ +$\tt \descr{ÔÉÐ ÐÁÒÁÍÅÔÒÁ} \rightarrow expr \;|\; suffix \;|\; text$\\ +%%$\tt \descr{parameter type} \rightarrow expr \;|\; suffix \;|\; text$\\ +$\tt \descr{ÐÁÒÁÍÅÔÒÙ-ÚÎÁËÉ} \rightarrow \descr{ÐÁÒÁÍÅÔÒ} \;|\; \descr{ÐÁÒÁÍÅÔÒÙ-ÚÎÁËÉ}\hbox{\tt ,} \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \descr{parameter tokens} \rightarrow \descr{parameter} \;|\; \descr{parameter tokens}\hbox{\tt ,} \descr{parameter}$\\ +$\tt \descr{ÐÁÒÁÍÅÔÒ} \rightarrow \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}$\\ +%%$\tt \descr{parameter} \rightarrow \descr{symbolic token}$\\ +$\tt \descr{ÎÅÏÔÄÅÌÅÎÎÁÑ ÞÁÓÔØ} \rightarrow \descr{ÐÕÓÔÏ}$\\ +%%$\tt \descr{undelimited part} \rightarrow \descr{empty}$\\ +$\tt \qquad \;|\; \descr{ÔÉÐ ÐÁÒÁÍÅÔÒÁ} \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \qquad \;|\; \descr{parameter type} \descr{parameter}$\\ +$\tt \qquad \;|\; \descr{ÕÒÏ×ÅÎØ ÐÒÉÏÒÉÔÅÔÁ} \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \qquad \;|\; \descr{precedence level} \descr{parameter}$\\ +$\tt \qquad \;|\; expr \descr{ÐÁÒÁÍÅÔÒ} of \descr{ÐÁÒÁÍÅÔÒ}$\\ +%%$\tt \qquad \;|\; expr \descr{parameter} of \descr{parameter}$\\ +$\tt \descr{ÕÒÏ×ÅÎØ ÐÒÉÏÒÉÔÅÔÁ} \rightarrow primary \;|\; secondary \;|\; tertiary$\\ +%%$\tt \descr{precedence level} \rightarrow primary \;|\; secondary \;|\; tertiary$\\ +$\tt \descr{ÏÐÒÅÄÅÌÅÎÉÅ ÂÉÎÁÒÎÏÓÔÉ} \rightarrow primarydef \;|\; secondarydef \;|\; tertiarydef$\\ +%%$\tt \descr{binary def} \rightarrow primarydef \;|\; secondarydef \;|\; tertiarydef$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ÐÓÅ×ÄÏÐÒÏÃÅÄÕÒÁ} \rightarrow drawoptions\hbox{\tt (}\descr{ÓÐÉÓÏË ÏÐÃÉÊ}\hbox{\tt )}$\\ +%%$\tt \descr{pseudo procedure} \rightarrow drawoptions\hbox{\tt (}\descr{option list}\hbox{\tt )}$\\ +$\tt \qquad \;|\; label\descr{ÓÕÆÆÉËÓ ÍÅÔËÉ}\hbox{\tt (}\descr{×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; label\descr{label suffix}\hbox{\tt (}\descr{expression}\hbox{\tt ,} \descr{pair expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; dotlabel\descr{ÓÕÆÆÉËÓ ÍÅÔËÉ}\hbox{\tt (}\descr{×ÙÒÁÖÅÎÉÅ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ-ÐÁÒÁ}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; dotlabel\descr{label suffix}\hbox{\tt (}\descr{expression}\hbox{\tt ,} \descr{pair expression}\hbox{\tt )}$\\ +$\tt \qquad \;|\; labels\descr{ÓÕÆÆÉËÓ ÍÅÔËÉ}\hbox{\tt (}\descr{ÓÐÉÓÏË ÎÏÍÅÒÏ× ÔÏÞÅË}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; labels\descr{label suffix}\hbox{\tt (}\descr{point number list}\hbox{\tt )}$\\ +$\tt \qquad \;|\; dotlabels\descr{ÓÕÆÆÉËÓ ÍÅÔËÉ}\hbox{\tt (}\descr{ÓÐÉÓÏË ÎÏÍÅÒÏ× ÔÏÞÅË}\hbox{\tt )}$\\ +%%$\tt \qquad \;|\; dotlabels\descr{label suffix}\hbox{\tt (}\descr{point number list}\hbox{\tt )}$\\ +$\tt \descr{ÓÐÉÓÏË ÎÏÍÅÒÏ× ÔÏÞÅË} \rightarrow \descr{ÓÕÆÆÉËÓ} \;|\; \descr{ÓÐÉÓÏË ÎÏÍÅÒÏ× ÔÏÞÅË}\hbox{\tt ,} \descr{ÓÕÆÆÉËÓ}$\\ +%%$\tt \descr{point number list} \rightarrow \descr{suffix} \;|\; \descr{point number list}\hbox{\tt ,} \descr{suffix}$\\ +$\tt \descr{ÓÕÆÆÉËÓ ÍÅÔËÉ} \rightarrow \descr{ÐÕÓÔÏ} \;|\; lft \;|\; rt \;|\; top \;|\; bot \;|\; ulft \;|\; urt \;|\; llft \;|\; lrt$ +%%$\tt \descr{label suffix} \rightarrow \descr{empty} \;|\; lft \;|\; rt \;|\; top \;|\; bot \;|\; ulft \;|\; urt \;|\; llft \;|\; lrt$ +\end{ctabbing} +\caption{ðÏÌÎÙÊ ÓÉÎÔÁËÓÉÓ ÐÒÏÇÒÁÍÍ MetaPost} +%%\caption{Overall syntax for MetaPost programs} +\index{ÏÂÏÂÝÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ?\tdescr{ÏÂÏÂÝÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ}}\index{label suffix?\tdescr{ÓÕÆÆÉËÓ ÍÅÔËÉ}}\index{ÔÅËÓÔ ÚÁÍÅÎÙ?\tdescr{ÔÅËÓÔ ÚÁÍÅÎÙ}}% +%%\index{suffix?\tdescr{ÓÕÆÆÉËÓ}}% +%%\index{generic variable?\tdescr{generic variable}}\index{label suffix?\tdescr{label suffix}}\index{replacement text?\tdescr{replacement text}}% +%%\index{suffix?\tdescr{suffix}}% +\label{syprog} +\end{figure} + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ËÏÍÁÎÄÁ} \rightarrow clip \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ} to \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}$\\ +%%$\tt \descr{command} \rightarrow clip \descr{picture variable} to \descr{path expression}$\\ +$\tt \qquad \;|\; interim \descr{×ÎÕÔÒÅÎÎÑÑ ÐÅÒÅÍÅÎÎÁÑ} \hbox{\tt :=} \descr{ÐÒÁ×ÁÑ ÞÁÓÔØ}$\\ +%%$\tt \qquad \;|\; interim \descr{internal variable} \hbox{\tt :=} \descr{right-hand side}$\\ +$\tt \qquad \;|\; let \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} \hbox{\tt =} \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}$\\ +%%$\tt \qquad \;|\; let \descr{symbolic token} \hbox{\tt =} \descr{symbolic token}$\\ +$\tt \qquad \;|\; newinternal \descr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×}$\\ +%%$\tt \qquad \;|\; newinternal \descr{symbolic token list}$\\ +$\tt \qquad \;|\; pickup \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; pickup \descr{expression}$\\ +$\tt \qquad \;|\; randomseed \hbox{\tt :=} \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; randomseed \hbox{\tt :=} \descr{numeric expression}$\\ +$\tt \qquad \;|\; save \descr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×}$\\ +%%$\tt \qquad \;|\; save \descr{symbolic token list}$\\ +$\tt \qquad \;|\; setbounds \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ} to \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ}$\\ +%%$\tt \qquad \;|\; setbounds \descr{picture variable} to \descr{path expression}$\\ +$\tt \qquad \;|\; shipout \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ}$\\ +%%$\tt \qquad \;|\; shipout \descr{picture expression}$\\ +$\tt \qquad \;|\; special \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; special \descr{string expression}$\\ +$\tt \qquad \;|\; write \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} to \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; write \descr{string expression} to \descr{string expression}$\\ +$\tt \qquad \;|\; \descr{ËÏÍÁÎÄÁ addto}$\\ +%%$\tt \qquad \;|\; \descr{addto command}$\\ +$\tt \qquad \;|\; \descr{ËÏÍÁÎÄÁ ÒÉÓÏ×ÁÎÉÑ}$\\ +%%$\tt \qquad \;|\; \descr{drawing command}$\\ +$\tt \qquad \;|\; \descr{ËÏÍÁÎÄÁ ÍÅÔÒÉËÉ ÛÒÉÆÔÁ}$\\ +%%$\tt \qquad \;|\; \descr{font metric command}$\\ +$\tt \qquad \;|\; \descr{ËÏÍÁÎÄÁ-ÓÏÏÂÝÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; \descr{message command}$\\ +$\tt \qquad \;|\; \descr{ËÏÍÁÎÄÁ show}$\\ +%%$\tt \qquad \;|\; \descr{show command}$\\ +$\tt \qquad \;|\; \descr{ËÏÍÁÎÄÁ ÔÒÁÓÓÉÒÏ×ËÉ}$\\ +%%$\tt \qquad \;|\; \descr{tracing command}$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ËÏÍÁÎÄÁ show} \rightarrow show \descr{ÓÐÉÓÏË ×ÙÒÁÖÅÎÉÊ}$\\ +%%$\tt \descr{show command} \rightarrow show \descr{expression list}$\\ +$\tt \qquad \;|\; showvariable \descr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×}$\\ +%%$\tt \qquad \;|\; showvariable \descr{symbolic token list}$\\ +$\tt \qquad \;|\; showtoken \descr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×}$\\ +%%$\tt \qquad \;|\; showtoken \descr{symbolic token list}$\\ +$\tt \qquad \;|\; showdependencies$\\ +%%$\tt \qquad \;|\; showdependencies$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×} \rightarrow \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}$\\ +%%$\tt \descr{symbolic token list} \rightarrow \descr{symbolic token}$\\ +$\tt \qquad \;|\; \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË}\hbox{\tt ,} \descr{ÓÐÉÓÏË ÓÉÍ×ÏÌÉÞÅÓËÉÈ ÚÎÁËÏ×}$\\ +%%$\tt \qquad \;|\; \descr{symbolic token}\hbox{\tt ,} \descr{symbolic token list}$\\ +$\tt \descr{ÓÐÉÓÏË ×ÙÒÁÖÅÎÉÊ} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ} \;|\; \descr{ÓÐÉÓÏË ×ÙÒÁÖÅÎÉÊ}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{expression list} \rightarrow \descr{expression} \;|\; \descr{expression list}\hbox{\tt ,} \descr{expression}$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ËÏÍÁÎÄÁ addto} \rightarrow$\\ +%%$\tt \descr{addto command} \rightarrow$\\ +$\tt \qquad addto \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ} also \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \qquad addto \descr{picture variable} also \descr{picture expression} \descr{option list}$\\ +$\tt \qquad \;|\; addto \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ} contour \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \qquad \;|\; addto \descr{picture variable} contour \descr{path expression} \descr{option list}$\\ +$\tt \qquad \;|\; addto \descr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ} doublepath \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \qquad \;|\; addto \descr{picture variable} doublepath \descr{path expression} \descr{option list}$\\ +$\tt \descr{ÓÐÉÓÏË ÏÐÃÉÊ} \rightarrow \descr{ÐÕÓÔÏ} \;|\; \descr{ÏÐÃÉÑ ÒÉÓÏ×ÁÎÉÑ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \descr{option list} \rightarrow \descr{empty} \;|\; \descr{drawing option} \descr{option list}$\\ +$\tt \descr{ÏÐÃÉÑ ÒÉÓÏ×ÁÎÉÑ} \rightarrow withcolor \descr{×ÙÒÁÖÅÎÉÅ-Ã×ÅÔ}$\\ +%%$\tt \descr{drawing option} \rightarrow withcolor \descr{color expression}$\\ +$\tt \qquad \;|\; withrgbcolor \descr{×ÙÒÁÖÅÎÉÅ-rgb-Ã×ÅÔ} \;|\; withcmykcolor \descr{×ÙÒÁÖÅÎÉÅ-cmyk-Ã×ÅÔ}$\\ +%%$\tt \qquad \;|\; withrgbcolor \descr{rgbcolor expression} \;|\; withcmykcolor \descr{cmykcolor expression}$\\ +$\tt \qquad \;|\; withgreyscale \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} \;|\; withoutcolor$\\ +%%$\tt \qquad \;|\; withgreyscale \descr{numeric expression} \;|\; withoutcolor$\\ +$\tt \qquad \;|\; withprescript \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} \;|\; withpostscript \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; withprescript \descr{string expression} \;|\; withpostscript \descr{string expression}$\\ +$\tt \qquad \;|\; withpen \descr{×ÙÒÁÖÅÎÉÅ-ÐÅÒÏ} \;|\; dashed \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ}$\\ +%%$\tt \qquad \;|\; withpen \descr{pen expression} \;|\; dashed \descr{picture expression}$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ËÏÍÁÎÄÁ ÒÉÓÏ×ÁÎÉÑ} \rightarrow draw \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \descr{drawing command} \rightarrow draw \descr{picture expression} \descr{option list}$\\ +$\tt \qquad \;|\; \descr{ÔÉÐ ÚÁÐÏÌÎÅÎÉÑ} \descr{×ÙÒÁÖÅÎÉÅ-ÐÕÔØ} \descr{ÓÐÉÓÏË ÏÐÃÉÊ}$\\ +%%$\tt \qquad \;|\; \descr{fill type} \descr{path expression} \descr{option list}$\\ +$\tt \descr{ÔÉÐ ÚÁÐÏÌÎÅÎÉÑ} \rightarrow fill \;|\; draw \;|\; filldraw \;|\; unfill \;|\; undraw \;|\; unfilldraw$\\ +%%$\tt \descr{fill type} \rightarrow fill \;|\; draw \;|\; filldraw \;|\; unfill \;|\; undraw \;|\; unfilldraw$\\ +$\tt \qquad \;|\; drawarrow \;|\; drawdblarrow \;|\; cutdraw$\\ +%%$\tt \qquad \;|\; drawarrow \;|\; drawdblarrow \;|\; cutdraw$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ËÏÍÁÎÄÁ-ÓÏÏÂÝÅÎÉÅ} \rightarrow errhelp \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{message command} \rightarrow errhelp \descr{string expression}$\\ +$\tt \qquad \;|\; errmessage \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; errmessage \descr{string expression}$\\ +$\tt \qquad \;|\; filenametemplate \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; filenametemplate \descr{string expression}$\\ +$\tt \qquad \;|\; message \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; message \descr{string expression}$\\ +$\tt $\\ +%%$\tt $\\ +$\tt \descr{ËÏÍÁÎÄÁ ÔÒÁÓÓÉÒÏ×ËÉ} \rightarrow tracingall \;|\; loggingall \;|\; tracingnone$ +%%$\tt \descr{tracing command} \rightarrow tracingall \;|\; loggingall \;|\; tracingnone$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ËÏÍÁÎÄ} +%%\caption{The syntax for commands} +\index{ÓÐÉÓÏË ÏÐÃÉÊ?\tdescr{ÓÐÉÓÏË ÏÐÃÉÊ}}\index{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ?\tdescr{ÐÅÒÅÍÅÎÎÁÑ-ËÁÒÔÉÎËÁ}}% +%%\index{option list?\tdescr{option list}}\index{picture variable?\tdescr{picture variable}}% +\label{sycmds} + +% is this really true? in practice, in real implementations? +%\bigskip +%By the way, the default for \ttindex{randomseed} is, in effect, +%$\textsl{day} + \textsl{time}*\epsilon$. Unfortunately, \textsl{time} +%is in minutes. +\end{figure} + +\begin{figure}[htp] +\begin{ctabbing} +$\tt \descr{ÐÒÏ×ÅÒËÁ if} \rightarrow if \descr{ÌÏÇÉÞÅÓËÏÅ ×ÙÒÁÖÅÎÉÅ} \hbox{\tt :} \descr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ} \descr{ÁÌØÔÅÒÎÁÔÉ×Ù} fi$\\ +%%$\tt \descr{if test} \rightarrow if \descr{boolean expression} \hbox{\tt :} \descr{balanced tokens} \descr{alternatives} fi$\\ +$\tt \descr{ÁÌØÔÅÒÎÁÔÉ×Ù} \rightarrow \descr{ÐÕÓÔÏ}$\\ +%%$\tt \descr{alternatives} \rightarrow \descr{empty}$\\ +$\tt \qquad \;|\; else\hbox{\tt :} \descr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ}$\\ +%%$\tt \qquad \;|\; else\hbox{\tt :} \descr{balanced tokens}$\\ +$\tt \qquad \;|\; elseif \descr{ÌÏÇÉÞÅÓËÏÅ ×ÙÒÁÖÅÎÉÅ} \hbox{\tt :} \descr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ} \descr{ÁÌØÔÅÒÎÁÔÉ×Ù}$\\ +%%$\tt \qquad \;|\; elseif \descr{boolean expression} \hbox{\tt :} \descr{balanced tokens} \descr{alternatives}$\\ +$\tt $\\ +$\tt \descr{ÃÉËÌ} \rightarrow \descr{ÚÁÇÏÌÏ×ÏË ÃÉËÌÁ}\hbox{\tt :} \descr{ÔÅÌÏ ÃÉËÌÁ} endfor$\\ +%%$\tt \descr{loop} \rightarrow \descr{loop header}\hbox{\tt :} \descr{loop text} endfor$\\ +$\tt \descr{ÚÁÇÏÌÏ×ÏË ÃÉËÌÁ} \rightarrow for \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} \hbox{\tt =} \descr{ÐÒÏÇÒÅÓÓÉÑ}$\\ +%%$\tt \descr{loop header} \rightarrow for \descr{symbolic token} \hbox{\tt =} \descr{progression}$\\ +$\tt \qquad \;|\; for \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} \hbox{\tt =} \descr{ÓÐÉÓÏË for}$\\ +%%$\tt \qquad \;|\; for \descr{symbolic token} \hbox{\tt =} \descr{for list}$\\ +$\tt \qquad \;|\; for \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} \hbox{\tt within} \descr{×ÙÒÁÖÅÎÉÅ-ËÁÒÔÉÎËÁ}$\\ +%%$\tt \qquad \;|\; for \descr{symbolic token} \hbox{\tt within} \descr{picture expression}$\\ +$\tt \qquad \;|\; forsuffixes \descr{ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÚÎÁË} \hbox{\tt =} \descr{ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×}$\\ +%%$\tt \qquad \;|\; forsuffixes \descr{symbolic token} \hbox{\tt =} \descr{suffix list}$\\ +$\tt \qquad \;|\; forever$\\ +%%$\tt \qquad \;|\; forever$\\ +$\tt \descr{ÐÒÏÇÒÅÓÓÉÑ} \rightarrow \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} upto \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{progression} \rightarrow \descr{numeric expression} upto \descr{numeric expression}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} downto \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \qquad \;|\; \descr{numeric expression} downto \descr{numeric expression}$\\ +$\tt \qquad \;|\; \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} step \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} until \descr{ÞÉÓÌÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} $\\ +%%$\tt \qquad \;|\; \descr{numeric expression} step \descr{numeric expression} until \descr{numeric expression} $\\ +$\tt \descr{ÓÐÉÓÏË for} \rightarrow \descr{×ÙÒÁÖÅÎÉÅ} \;|\; \descr{ÓÐÉÓÏË for}\hbox{\tt ,} \descr{×ÙÒÁÖÅÎÉÅ}$\\ +%%$\tt \descr{for list} \rightarrow \descr{expression} \;|\; \descr{for list}\hbox{\tt ,} \descr{expression}$\\ +$\tt \descr{ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×} \rightarrow \descr{ÓÕÆÆÉËÓ} \;|\; \descr{ÓÐÉÓÏË ÓÕÆÆÉËÓÏ×}\hbox{\tt ,} \descr{ÓÕÆÆÉËÓ}$ +%%$\tt \descr{suffix list} \rightarrow \descr{suffix} \;|\; \descr{suffix list}\hbox{\tt ,} \descr{suffix}$ +\end{ctabbing} +\caption{óÉÎÔÁËÓÉÓ ÄÌÑ ÕÓÌÏ×ÉÊ É ÃÉËÌÏ×} +%%\caption{The syntax for conditionals and loops} +\index{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ?\tdescr{ÓÂÁÌÁÎÓÉÒÏ×ÁÎÎÙÅ ÚÎÁËÉ}}\index{ÓÕÆÆÉËÓ?\tdescr{ÓÕÆÆÉËÓ}}% +%%\index{balanced tokens?\tdescr{balanced tokens}}\index{suffix?\tdescr{suffix}}% +\label{sycondloop} +\end{figure} + +\clearpage + +\let\topfraction=\svtopfrac % restore values from the start of this appendix +\let\textfraction=\svtxtfrac +\setcounter{topnumber}{\value{svtopnum}} +\setcounter{totalnumber}{\value{svtotnum}} + +\section{MetaPost É \MF} +%%\section{MetaPost Versus \MF} +\label{MPvsMF} + +éÚ-ÚÁ ÔÏÇÏ, ÞÔÏ ÑÚÙËÉ \MF\index{metafont?\MF} É MetaPost ÉÍÅÀÔ ÔÁË ÍÎÏÇÏ +ÏÂÝÅÇÏ, ÐÏÌØÚÏ×ÁÔÅÌÉ-ÜËÓÐÅÒÔÙ \MF\ ×ÏÚÍÏÖÎÏ ÚÁÈÏÔÑÔ ÐÒÏÐÕÓÔÉÔØ ÂÏÌØÛÕÀ +ÞÁÓÔØ ÏÂßÑÓÎÅÎÉÊ ÉÚ ÜÔÏÇÏ ÄÏËÕÍÅÎÔÁ É ÓËÏÎÃÅÎÔÒÉÒÏ×ÁÔØÓÑ ÎÁ ÕÎÉËÁÌØÎÙÈ +ËÏÎÃÅÐÃÉÑÈ MetaPost. +%%Since the \MF\index{metafont?\MF} and MetaPost languages have so much in +%%common, expert users of \MF\ will want to skip most of the explanations +%%in this document and concentrate on concepts that are unique to +%%MetaPost. +óÒÁ×ÎÅÎÉÑ × ÜÔÏÍ ÐÒÉÌÏÖÅÎÉÅ ÐÒÉ×ÏÄÑÔÓÑ ÄÌÑ ÐÏÍÏÝÉ ÜËÓÐÅÒÔÁÍ, ÈÏÒÏÛÏ +ÚÎÁËÏÍÙÍ Ó {\sl The\ \MF book}, Á ÔÁËÖÅ ÄÒÕÇÉÍ ÐÏÌØÚÏ×ÁÔÅÌÑÍ, ÞÔÏ +ÈÏÔÑÔ ÐÏÌÕÞÉÔØ ÐÏÌØÚÕ ÉÚ ÂÏÌÅÅ ÄÅÔÁÌØÎÙÈ ÏÂßÑÓÎÅÎÉÊ ÒÁÂÏÔÙ ëÎÕÔÁ \cite{kn:c}. +%%The comparisons in this appendix are intended to help experts +%%that are familiar with {\sl The\ \MF book} as well as other users that +%%want to benefit from Knuth's more detailed explanations \cite{kn:c}. + +÷ÓÌÅÄÓÔ×ÉÅ ÔÏÇÏ, ÞÔÏ \MF\ ÐÒÅÄÎÁÚÎÁÞÅÎ ÄÌÑ ÉÚÇÏÔÏ×ÌÅÎÉÑ ÛÒÉÆÔÏ× \TeX, +ÏÎ ÉÍÅÅÔ ÒÑÄ ÐÒÉÍÉÔÉ×Ï× ÄÌÑ ÇÅÎÅÒÁÃÉÉ +{\tt tfm}\index{tfm file?{\tt tfm}-ÆÁÊÌ}\index{ÆÁÊÌÙ!tfm?{\tt tfm}}-ÆÁÊÌÏ×, +ÎÕÖÎÙÈ \TeX\ ÄÌÑ ÉÚÍÅÒÅÎÉÑ +ÓÉÍ×ÏÌÏ×, ÉÎÆÏÒÍÁÃÉÉ Ï ÏÔÓÔÕÐÁÈ, ÌÉÇÁÔÕÒÁÈ\index{ÌÉÇÁÔÕÒÙ} É +ËÅÒÎÉÎÇÅ\index{ËÅÒÎÉÎÇ}. +%%Since \MF\ is intended for making \TeX\ fonts, it has a number of +%%primitives for generating the {\tt tfm}\index{tfm file?{\tt tfm} +%%file}\index{files!tfm?{\tt tfm}} files that \TeX\ needs for character +%%dimensions, spacing information, ligatures\index{ligatures} and +%%kerning\index{kerning}. +MetaPost ÍÏÖÅÔ ÔÁËÖÅ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ ÄÌÑ ÇÅÎÅÒÁÃÉÉ ÛÒÉÆÔÏ× É ÏÎ +ÔÁËÖÅ ÉÍÅÅÔ ÐÒÉÍÉÔÉ×Ù \MF\ ÄÌÑ ÓÏÚÄÁÎÉÑ {\tt tfm}-ÆÁÊÌÏ×. +%%MetaPost can also be used for generating fonts, +%%and it also has \MF's primitives for making {\tt tfm} files. +ïÎÉ ÐÅÒÅÞÉÓÌÑÀÔÓÑ × ÔÁÂÌÉÃÅ~\ref{tfmprim}. +%%These are listed in Table~\ref{tfmprim}. +éÈ ÏÂßÑÓÎÅÎÉÑ ÍÏÇÕÔ ÂÙÔØ ÎÁÊÄÅÎÙ × ÄÏËÕÍÅÎÔÁÃÉÉ \MF\ \cite{kn:c,kn:mf3}. +%%Explanations can be found in the \MF\ +%%documentation \cite{kn:c,kn:mf3}. + +\begin{table}[htp] +$$\begin{tabular}{|l|l|} \hline +ËÏÍÁÎÄÙ& {\tt charlist}, {\tt extensible}, +%%commands& {\tt charlist}, {\tt extensible}, + {\tt fontdimen}, {\tt headerbyte} \\ + & {\tt kern}, {\tt ligtable} \\ \hline +ÏÐÅÒÁÔÏÒÙ ÌÉÇÁÔÕÒÎÙÈ& \verb!::!, \verb!=:!, \verb!=:|!, \verb!=:|>!, +%%ligtable operators& \verb!::!, \verb!=:!, \verb!=:|!, \verb!=:|>!, + \verb!|=:!, \verb!|=:>!, \\ +ÔÁÂÌÉÃ& \verb!|=:|!, \verb!|=:|>!, \verb!|=:|>>!, +%% & \verb!|=:|!, \verb!|=:|>!, \verb!|=:|>>!, + \verb!||:! \\ \hline +×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ\index{×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ}& +%%internal variables\index{internal variables}\index{variables!internal}& + {\tt boundarychar}, {\tt chardp}, + {\tt charext}, {\tt charht}, \\ + & {\tt charic}, {\tt charwd}, + {\tt designsize}, {\tt fontmaking} \\ \hline +ÄÒÕÇÉÅ ÏÐÅÒÁÔÏÒÙ& {\tt charexists} \\ \hline +%%other operators& {\tt charexists} \\ \hline +\end{tabular} +$$ +\caption{ðÒÉÍÉÔÉ×Ù MetaPost ÄÌÑ ÓÏÚÄÁÎÉÑ {\tt tfm}-ÆÁÊÌÏ×.} +%%\caption{MetaPost primitives for making {\tt tfm} files.} +\label{tfmprim} +\end{table} + +äÁÖÅ ÈÏÔÑ MetaPost ÉÍÅÅÔ ÐÒÉÍÉÔÉ×Ù ÄÌÑ ÇÅÎÅÒÁÃÉÉ ÛÒÉÆÔÏ×, ÍÎÏÇÉÅ +ÔÁËÉÅ ÐÒÉÍÉÔÉ×Ù É ×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ, ËÏÔÏÒÙÅ ×ÈÏÄÑÔ × Plain +\MF\index{metafont?\MF}, ÎÅ ÏÐÒÅÄÅÌÅÎÙ × Plain MetaPost\index{ÍÁËÒÏÓÙ Plain}. +%%Even though MetaPost has the primitives for generating fonts, many of +%%the font-making primitives and internal variables that are part of Plain +%%\MF\index{metafont?\MF} are not defined in Plain MetaPost\index{Plain +%%macros}. +÷ÍÅÓÔÏ ÜÔÏÇÏ ÉÍÅÅÔÓÑ ÏÔÄÅÌØÎÙÊ ÍÁËÒÏÐÁËÅÔ {\tt +mfplain}\index{mfplain?\texttt{mfplain}}, ÏÐÒÅÄÅÌÑÀÝÉÊ ÍÁËÒÏÓÙ, +ÔÒÅÂÕÅÍÙÅ ÄÌÑ ×ÏÚÍÏÖÎÏÓÔÉ ÏÂÒÁÂÏÔÁÔØ ÞÅÒÅÚ MetaPost ÛÒÉÆÔÙ Computer Modern +ëÎÕÔÁ, --- ÏÎÉ ÐÏËÁÚÁÎÙ × ÔÁÂÌÉÃÅ~\ref{mfponly} \cite{kn:e}. +%%Instead, there is a separate macro package called {\tt +%%mfplain}\index{mfplain?\texttt{mfplain}} that defines the macros +%%required to allow MetaPost to process Knuth's Computer Modern fonts as +%%shown in Table~\ref{mfponly} \cite{kn:e}. +äÌÑ ÚÁÇÒÕÚËÉ ÜÔÉÈ ÍÁËÒÏÓÏ× ÐÏÓÔÁ×ØÔÅ ``\verb|&mfplain|'' ÐÅÒÅÄ ÉÍÅÎÅÍ +×ÈÏÄÎÏÇÏ ÆÁÊÌÁ. +%%To load these macros, put +%%``\verb|&mfplain|'' before the name of the input file. +üÔÏ ÍÏÖÅÔ ÂÙÔØ ÓÄÅÌÁÎÏ ÐÏ ÐÒÉÇÌÁÛÅÎÉÀ {\tt **} ÐÏÓÌÅ ×ÙÚÏ×Á ÉÎÔÅÒÐÒÅÔÁÔÏÒÁ +MetaPost ÂÅÚ ÁÒÇÕÍÅÎÔÏ× ÉÌÉ × ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÅ, +ÎÁÐÒÉÍÅÒ\footnote{óÉÎÔÁËÓÉÓ ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÉ ÚÁ×ÉÓÉÔ ÏÔ ÓÉÓÔÅÍÙ. ëÁ×ÙÞËÉ ÎÕÖÎÙ +× ÂÏÌØÛÉÎÓÔ×Å ÓÉÓÔÅÍ Unix ÄÌÑ ÚÁÝÉÔÙ ÓÐÅÃÉÁÌØÎÙÈ ÓÉÍ×ÏÌÏ×, ÐÏÄÏÂÎÙÈ {\tt\&}.}, +%%This can be done +%%at the {\tt **} prompt after invoking the MetaPost interpreter with no +%%arguments, or on a command line that looks something like +%%this:\footnote{Command line syntax is system dependent. Quotes are +%%needed on most Unix systems to protect special characters like +%%{\tt\&}.} +$$ \hbox{\verb|mpost '&mfplain' cmr10|} $$ +%%$$ \hbox{\verb|mpost '&mfplain' cmr10|} $$ +ëÏÍÁÎÄÏÊ, ÁÎÁÌÏÇÉÞÎÏÊ \MF-ËÏÍÁÎÄÅ +%%The analog of a \MF\ command line like +$$ \hbox{\verb|mf '\mode=lowres; mag=1.2; input cmr10'|,} $$ +%%$$ \hbox{\verb|mf '\mode=lowres; mag=1.2; input cmr10'|} $$ +ÂÕÄÅÔ +%%is +$$ \hbox{\verb|mpost '&mfplain \mode=lowres; mag=1.2; input cmr10'|} $$ +%%$$ \hbox{\verb|mpost '&mfplain \mode=lowres; mag=1.2; input cmr10'|} $$ +òÅÚÕÌØÔÁÔ --- ÜÔÏ ÍÎÏÖÅÓÔ×Ï ÆÁÊÌÏ× PostScript\index{PostScript}, ÐÏ ÏÄÎÏÍÕ +ÎÁ ËÁÖÄÙÊ ÓÉÍ×ÏÌ ÛÒÉÆÔÁ. +%%The result is a set of PostScript\index{PostScript} files, one for each +%%character in the font. +ðÏÔÒÅÂÕÅÔÓÑ ÎÅËÏÔÏÒÏÅ ÒÅÄÁËÔÉÒÏ×ÁÎÉÅ ÄÌÑ ÉÈ ÓÏÅÄÉÎÅÎÉÑ × ÚÁÇÒÕÖÁÅÍÙÊ PostScript +Type 3 ÛÒÉÆÔ~\cite{ad:red2}.. +%%Some editing would be required in order to +%%merge them into a downloadable Type~3 PostScript font~\cite{ad:red2}. + +\begin{table}[htp] +$$ +\renewcommand{\FancyVerbFormatLine}[1]{\hbox{#1}\strut} +\begin{tabular}{|l|} \hline +\multicolumn 1{|c|} +{ïÐÒÅÄÅÌÅÎÙ × ÐÁËÅÔÅ {\tt mfplain}} \\ \hline +%%{Defined in the {\tt mfplain} package} \\ \hline +\begin{verbatim} +beginchar font_identifier +blacker font_normal_shrink +capsule_def font_normal_space +change_width font_normal_stretch +define_blacker_pixels font_quad +define_corrected_pixels font_size +define_good_x_pixels font_slant +define_good_y_pixels font_x_height +define_horizontal_corrected_pixels italcorr +define_pixels labelfont +define_whole_blacker_pixels makebox +define_whole_pixels makegrid +define_whole_vertical_blacker_pixels maketicks +define_whole_vertical_pixels mode_def +endchar mode_setup +extra_beginchar o_correction +extra_endchar proofrule +extra_setup proofrulethickness +font_coding_scheme rulepen +font_extra_space smode +\end{verbatim} + \\ \hline +\multicolumn 1{|c|} +{ïÐÒÅÄÅÌÅÎÙ ËÁË ÐÕÓÔÙÅ ÏÐÅÒÁÃÉÉ × ÐÁËÅÔÅ {\tt mfplain}}\\ \hline +%%{Defined as no-ops in the {\tt mfplain} package}\\ \hline +\begin{verbatim} +cullit proofoffset +currenttransform screenchars +gfcorners screenrule +grayfont screenstrokes +hround showit +imagerules slantfont +lowres_fix titlefont +nodisplays unitpixel +notransforms vround +openit +\end{verbatim} + \\ \hline +\end{tabular} +\renewcommand{\FancyVerbFormatLine}[1]{#1} +$$ +\caption{íÁËÒÏÓÙ É ×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ, ÏÐÒÅÄÅÌÅÎÎÙÅ ÔÏÌØËÏ × ÐÁËÅÔÅ {\tt mfplain}.} +%%\caption{Macros and internal variables defined only in the {\tt mfplain} +%%package.} +\label{mfponly} +\end{table} + +äÒÕÇÉÍ ÏÇÒÁÎÉÞÅÎÉÅÍ ÐÁËÅÔÁ {\tt mfplain} Ñ×ÌÑÅÔÓÑ ÔÏ, ÞÔÏ ÏÐÒÅÄÅÌÅÎÎÙÅ +ÐÅÒÅÍÅÎÎÙÅ ÉÚ Plain \MF\index{metafont?\MF} ÎÅ ÍÏÇÕÔ ÐÏÌÕÞÉÔØ ÒÁÚÕÍÎÙÈ +ÏÐÒÅÄÅÌÅÎÉÊ × MetaPost. +%%Another limitation of the {\tt mfplain} package is that certain internal +%%variables from Plain \MF\index{metafont?\MF} cannot be given reasonable +%%MetaPost definitions. +óÒÅÄÉ ÎÉÈ {\tt displaying}, {\tt +currentwindow}, \verb|screen_rows| É \verb|screen_cols|, ËÏÔÏÒÙÅ ÚÁ×ÉÓÑÔ +ÏÔ ÓÐÏÓÏÂÎÏÓÔÉ \MF\ ÉÚÏÂÒÁÖÁÔØ ÒÉÓÕÎËÉ ÎÁ ÜËÒÁÎÅ ËÏÍÐØÀÔÅÒÁ. +%%These include {\tt displaying}, {\tt +%%currentwindow}, \verb|screen_rows|, and \verb|screen_cols| which depend +%%on \MF's ability to display images on the computer screen. +ëÒÏÍÅ ÔÏÇÏ, \verb|pixels_per_inch| Ñ×ÌÑÅÔÓÑ ÎÅÕÍÅÓÔÎÙÍ ÉÚ-ÚÁ ÔÏÇÏ, ÞÔÏ MetaPost +ÉÓÐÏÌØÚÕÅÔ ÆÉËÓÉÒÏ×ÁÎÎÙÅ ÅÄÉÎÉÃÙ ÐÕÎËÔÏ× PostScript\index{PostScript!ÐÕÎËÔ}\index{ÐÕÎËÔ!PostScript}. +%%In addition, +%%\verb|pixels_per_inch| is irrelevant since MetaPost uses fixed units of +%%PostScript\index{PostScript!point}\index{point!PostScript} points. + +ïÓÎÏ×ÁÎÉÑ ÔÏÇÏ, ÞÔÏ ÎÅËÏÔÏÒÙÅ ÍÁËÒÏÓÙ É ×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ\index{×ÎÕÔÒÅÎÎÉÅ +ÐÅÒÅÍÅÎÎÙÅ}\index{ÐÅÒÅÍÅÎÎÙÅ!×ÎÕÔÒÅÎÎÉÅ} ÎÉÞÅÇÏ ÎÅ ÚÎÁÞÁÔ × MetaPost × ÔÏÍ, +ÞÔÏ ÐÒÉÍÉÔÉ×ÎÙÅ ËÏÍÁÎÄÙ \MF\ {\tt cull}, {\tt display}, {\tt +openwindow}, {\tt numspecial} É {\tt totalweight} ÎÅ ÒÅÁÌÉÚÏ×ÁÎÙ × +MetaPost. +%%The reason why some macros and internal variables\index{internal +%%variables}\index{variables!internal} are not meaningful in MetaPost is +%%that \MF\ primitive commands {\tt cull}, {\tt display}, {\tt +%%openwindow}, {\tt numspecial} and {\tt totalweight} are not implemented +%%in MetaPost. +ôÁËÖÅ ÎÅ ÒÅÁÌÉÚÏ×ÁÎÙ ÒÑÄ ×ÎÕÔÒÅÎÎÉÈ ÐÅÒÅÍÅÎÎÙÈ É +\tdescr{ÏÐÃÉÑ ÒÉÓÏ×ÁÎÉÑ} {\tt withweight}. +%%Also not implemented are a number of internal variables as +%%well as the \tdescr{drawing option} {\tt withweight}. +äÁÌÅÅ ÓÌÅÄÕÅÔ ÐÏÌÎÙÊ ÓÐÉÓÏË ×ÎÕÔÒÅÎÎÉÈ ÐÅÒÅÍÅÎÎÙÈ, ÞØÉ ÐÒÉÍÉÔÉ×ÎÙÅ +\MF-ÚÎÁÞÅÎÉÑ ÎÅ ÉÍÅÀÔ ÓÍÙÓÌÁ × MetaPost: +%%Here is a +%%complete listing of the internal variables whose primitive meanings in +%%\MF\ do not make sense in MetaPost: +$$\begin{verbatim} +autorounding fillin proofing tracingpens xoffset +chardx granularity smoothing turningcheck yoffset +chardy hppp tracingedges vppp +\end{verbatim} +$$ + +åÓÔØ ÅÝÅ ÐÒÉÍÉÔÉ× \MF, ÉÍÅÀÝÉÊ ÎÅÓËÏÌØËÏ ÉÎÏÅ ÚÎÁÞÅÎÉÅ × MetaPost. +%%There is also one \MF\ primitive that has a slightly different meaning in +%%MetaPost. +ïÂÁ ÑÚÙËÁ ÄÏÐÕÓËÁÀÔ ËÏÍÁÎÄÕ × ÆÏÒÍÅ\index{special?\texttt{special}}\label{Dspecl} +$$ {\tt special}\, \descr{ÓÔÒÏËÏ×ÏÅ ×ÙÒÁÖÅÎÉÅ} \hbox{\tt; }, $$ +ÎÏ \MF\ ËÏÐÉÒÕÅÔ ÓÔÒÏËÕ × Ó×ÏÊ ×ÙÈÏÄÎÏÊ ÆÁÊÌ ``ÏÂÏÂÝÅÎÎÏÇÏ ÛÒÉÆÔÁ'', ÔÏÇÄÁ ËÁË +MetaPost ÉÎÔÅÒÐÒÅÔÉÒÕÅÔ ÓÔÒÏËÕ ËÁË ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ËÏÍÁÎÄ PostScript\index{PostScript}, +ËÏÔÏÒÙÅ ÐÏÍÅÝÁÀÔÓÑ × ÎÁÞÁÌÏ ÓÌÅÄÕÀÝÅÇÏ ×ÙÈÏÄÎÏÇÏ ÆÁÊÌÁ +%%Both languages allow statements of the +%%form\index{special?\texttt{special}}\label{Dspecl} +%%$$ {\tt special}\, \descr{string expression} \hbox{\tt;} $$ +%%but \MF\ copies the string into its ``generic font'' output file, while +%%MetaPost interprets the string as a sequence of PostScript\index{PostScript} +%%commands that are to be placed at the beginning of the next output file. + +÷ ÜÔÏÍ ÒÁÓÓÍÏÔÒÅÎÉÉ ÓÔÏÉÔ ÚÁÍÅÔÉÔØ, ÞÔÏ ÌÉÎÅÊËÉ × ÍÁÔÅÒÉÁÌÅ \TeX, +×ËÌÀÞÁÅÍÏÍ ÞÅÒÅÚ {\tt btex..etex}, × MetaPost ÏËÒÕÇÌÑÀÔÓÑ ÄÏ ÐÒÁ×ÉÌØÎÏÇÏ +ÞÉÓÌÁ ÐÉËÓÅÌÏ×, ÓÏÇÌÁÓÎÏ ÐÒÁ×ÉÌÁÍ ÐÒÅÏÂÒÁÚÏ×ÁÎÉÑ +PostScript\index{PostScript!ÐÒÁ×ÉÌÁ ÐÒÅÏÂÒÁÚÏ×ÁÎÉÑ}~\cite{ad:red2}. +%%In this regard, it is worth mentioning that rules in \TeX\ material +%%included via {\tt btex..etex} in MetaPost are rounded to the correct +%%number of pixels according to PostScript\index{PostScript!conversion rules} +%%conversion rules~\cite{ad:red2}. +÷ \MF ÌÉÎÅÊËÉ ÎÁÐÒÑÍÕÀ ÎÅ ÇÅÎÅÒÉÒÕÀÔÓÑ, Á ÐÒÏÓÔÏ ×ËÌÀÞÁÀÔÓÑ × +special-ËÏÍÁÎÄÙ É ÉÎÔÅÒÐÒÅÔÉÒÕÀÔÓÑ ÐÏÚÖÅ ÄÒÕÇÉÍÉ ÐÒÏÇÒÁÍÍÁÍÉ, ÔÁËÉÍÉ +ËÁË {\tt gftodvi}\index{gftodvi?\ttt{gftodvi}}, ÐÏÜÔÏÍÕ ÚÄÅÓØ ÎÅÔ +ÎÉËÁËÉÈ ÐÒÅÏÂÒÁÚÏ×ÁÎÉÊ. +%%In \MF, rules are not generated +%%directly, but simply included in specials and interpreted later by +%%other programs, such as {\tt gftodvi}\index{gftodvi?\ttt{gftodvi}}, +%%so there is no special conversion. + +÷ÓÅ ÄÒÕÇÉÅ ÒÁÚÌÉÞÉÑ ÍÅÖÄÕ \MF\ É MetaPost --- ÜÔÏ ×ÏÚÍÏÖÎÏÓÔÉ, ËÏÔÏÒÙÅ +ÍÏÖÎÏ ÎÁÊÔÉ ÔÏÌØËÏ × MetaPost. +%%All the other differences between \MF\ and MetaPost are features found +%%only in MetaPost. +ïÎÉ ÐÅÒÅÞÉÓÌÅÎÙ × ÔÁÂÌÉÃÅ~\ref{mponly}. +%%These are listed in Table~\ref{mponly}. +åÄÉÎÓÔ×ÅÎÎÙÍÉ ËÏÍÁÎÄÁÍÉ, ËÏÔÏÒÙÅ ÎÅ ÏÂÓÕÖÄÁÌÉÓØ × ÐÒÅÄÙÄÕÝÉÈ ÒÁÚÄÅÌÁÈ É ËÏÔÏÒÙÅ +ÅÓÔØ × ÜÔÏÊ ÔÁÂÌÉÃÅ, Ñ×ÌÑÀÔÓÑ +\verb|extra_beginfig|\index{extra_beginfig?\texttt{extra\_beginfig}}\label{Dxbfig}, +\verb|extra_endfig|\index{extra_endfig?\texttt{extra\_endfig}}\label{Dxefig} +É {\tt mpxbreak}. +%%The only +%%commands listed in this table that the preceding sections do not discuss +%%are +%%\verb|extra_beginfig|\index{extra_beginfig?\texttt{extra\_beginfig}}\label{Dxbfig}, +%%\verb|extra_endfig|\index{extra_endfig?\texttt{extra\_endfig}}\label{Dxefig}, +%%and {\tt mpxbreak}. +ðÅÒ×ÙÅ Ä×Å --- ÜÔÏ ÓÔÒÏËÉ, ÓÏÄÅÒÖÁÝÉÅ ÄÏÐÏÌÎÉÔÅÌØÎÙÅ ËÏÍÁÎÄÙ ÄÌÑ ÏÂÒÁÂÏÔËÉ × +ÓÏÏÔ×ÅÔÓÔ×ÅÎÎÏ {\tt +beginfig}\index{beginfig?\texttt{beginfig}} É {\tt +endfig}\index{endfig?\texttt{endfig}}, --- ÏÎÉ ÐÏÄÏÂÎÙ \verb|extra_beginchar| É +\verb|extra_endchar|, ÏÂÒÁÂÁÔÙ×ÁÅÍÙÍ × {\tt beginchar} É {\tt endchar}. +%%The first two are strings that contain extra +%%commands to be processed by {\tt +%%beginfig}\index{beginfig?\texttt{beginfig}} and {\tt +%%endfig}\index{endfig?\texttt{endfig}} just as \verb|extra_beginchar| and +%%\verb|extra_endchar| are processed by {\tt beginchar} and {\tt endchar}. +æÁÊÌ {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} ÉÓÐÏÌØÚÕÅÔ ÜÔÉ +×ÏÚÍÏÖÎÏÓÔÉ. +%%(The file {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} uses these +%%features). + +äÒÕÇÏÊ ÎÏ×ÏÊ ×ÏÚÍÏÖÎÏÓÔØÀ, ÐÒÉ×ÅÄÅÎÎÏÊ × ÔÁÂÌÉÃÅ~\ref{mponly}, Ñ×ÌÑÅÔÓÑ +{\tt mpxbreak}\index{mpxbreak?\texttt{mpxbreak}}. +%%The other new feature listed in Table~\ref{mponly} not listed in the +%%index is {\tt mpxbreak}\index{mpxbreak?\texttt{mpxbreak}}. +ïÎÁ ÉÓÐÏÌØÚÕÅÔÓÑ ÄÌÑ ÒÁÚÄÅÌÅÎÉÑ ÂÌÏËÏ× ÔÒÁÎÓÌÉÒÏ×ÁÎÎÙÈ ËÏÍÁÎÄ +\TeX\index{TeX?\TeX} ÉÌÉ troff\index{troff} × +{\tt mpx}\index{ÆÁÊÌÙ!mpx?{\tt mpx}}-ÆÁÊÌÁÈ. +%%This is used +%%to separate blocks of translated \TeX\index{TeX?\TeX} or +%%troff\index{troff} commands in {\tt mpx}\index{files!mpx?{\tt mpx}} +%%files. +ïÎÁ ÎÅ ÄÏÌÖÎÁ ÚÁÔÒÁÇÉ×ÁÔØ ÐÏÌØÚÏ×ÁÔÅÌÅÊ, Ô.Ë. {\tt mpx}-ÆÁÊÌÙ +ÇÅÎÅÒÉÒÕÀÔÓÑ Á×ÔÏÍÁÔÉÞÅÓËÉ. +%%It should be of no concern to users since {\tt mpx} files are +%%generated automatically. + +\begin{table} +\centering +\begin{tabular}{|c|}\hline +ðÒÉÍÉÔÉ×Ù MetaPost, ÏÔÓÕÔÓÔ×ÕÀÝÉÅ × \MF\\\hline +%%MetaPost primitives not found in \MF\\\hline +\begin{minipage}[b]{.75\linewidth}\ttfamily +\begin{multicols}{3} +blackpart\\ +bluepart\\ +bounded\\ +btex\\ +clip\\ +clipped\\ +closefrom\\ +cmykcolor\\ +color\\ +colormodel\\ +cyanpart\\ +dashed\\ +dashpart\\ +defaultcolormodel\\ +etex\\ +filenametemplate\\ +filled\\ +fontmapfile\\ +fontmapline\\ +fontpart\\ +fontsize\\ +for within\\ +greenpart\\ +greypart\\ +infont\\ +linecap\\ +linejoin\\ +llcorner\\ +lrcorner\\ +magentapart\\ +miterlimit\\ +mpprocset\\ +mpxbreak\\ +pathpart\\ +penpart\\ +prologues\\ +readfrom\\ +redpart\\ +restoreclipcolor\\ +rgbcolor\\ +setbounds\\ +stroked\\ +textpart\\ +textual\\ +tracinglostchars\\ +troffmode\\ +truecorners\\ +ulcorner\\ +urcorner\\ +verbatimtex\\ +withcmykcolor\\ +withcolor\\ +withgreyscale\\ +withoutcolor\\ +withpostscript\\ +withprescript\\ +withrgbcolor\\ +write to\\ +yellowpart +\end{multicols} +\end{minipage}\\\hline + +ðÅÒÅÍÅÎÎÙÅ É ÍÁËÒÏÓÙ, ÏÐÒÅÄÅÌÅÎÎÙÅ ÔÏÌØËÏ × Plain MetaPost\\\hline +%%Variables and Macros defined only in Plain MetaPost\\\hline +\begin{minipage}[b]{.75\linewidth}\ttfamily +\begin{multicols}{3} +ahangle\\ +ahlength\\ +background\\ +bbox\\ +bboxmargin\\ +beginfig\\ +beveled\\ +black\\ +blue\\ +buildcycle\\ +butt\\ +center\\ +cutafter\\ +cutbefore\\ +cuttings\\ +dashpattern\\ +defaultfont\\ +defaultpen\\ +defaultscale\\ +dotlabel\\ +dotlabels\\ +drawarrow\\ +drawdblarrow\\ +drawoptions\\ +endfig\\ +EOF\\ +evenly\\ +extra\_beginfig\\ +extra\_endfig\\ +green\\ +image\\ +label\\ +labeloffset\\ +mitered\\ +red\\ +rounded\\ +squared\\ +thelabel\\ +white +\end{multicols} +\end{minipage}\\\hline +\end{tabular} +\caption{íÁËÒÏÓÙ É ×ÎÕÔÒÅÎÎÉÅ ÐÅÒÅÍÅÎÎÙÅ, ÏÐÒÅÄÅÌÅÎÎÙÅ ÔÏÌØËÏ × MetaPost, --- ÉÈ ÎÅÔ × \MF.} +%%\caption{Macros and internal variables defined in MetaPost but not \MF.} +\label{mponly} +\end{table} + + +\bibliographystyle{plain} +\bibliography{mpman-ru} + + +\printindex + + +\end{document} + +% Copyright 1990 - 1995 by AT&T Bell Laboratories. +% Updated 2006 by Taco Hoekwater, Karl Berry, and others. + +% Permission to use, copy, modify, and distribute this software +% and its documentation for any purpose and without fee is hereby +% granted, provided that the above copyright notice appear in all +% copies and that both that the copyright notice and this +% permission notice and warranty disclaimer appear in supporting +% documentation, and that the names of AT&T Bell Laboratories or +% any of its entities not be used in advertising or publicity +% pertaining to distribution of the software without specific, +% written prior permission. + +% AT&T disclaims all warranties with regard to this software, +% including all implied warranties of merchantability and fitness. +% In no event shall AT&T be liable for any special, indirect or +% consequential damages or any damages whatsoever resulting from +% loss of use, data or profits, whether in an action of contract, +% negligence or other tortious action, arising out of or in +% connection with the use or performance of this software. + +% In addition, John Hobby, the original author of MetaPost and this +% manual, makes the following requests: +% - I request that it remain clear that I am the author of +% "A User's Manual for MetaPost" and "Drawing Graphs with MetaPost". +% - I request to be consulted before significant changes are made. diff --git a/info/metapost/doc/russian/mpman-ru/mpman.ist b/info/metapost/doc/russian/mpman-ru/mpman.ist new file mode 100644 index 0000000000..9238679ce0 --- /dev/null +++ b/info/metapost/doc/russian/mpman-ru/mpman.ist @@ -0,0 +1,4 @@ +% MakeIndex style file for MetaPost doc, by John Hobby. Public domain. + +% @ is a valid character in some entries +actual '?' % ? instead of @ diff --git a/info/metapost/examples/Makefile b/info/metapost/examples/Makefile new file mode 100644 index 0000000000..f230031071 --- /dev/null +++ b/info/metapost/examples/Makefile @@ -0,0 +1,21 @@ +METAPOST = mpost --interaction=nonstopmode + +all: + perl mp2html.pl + +old_all: + TEX=latex $(METAPOST) examples.mp + +clean: + rm -f examples.[0-9] examples.[0-9][0-9] examples.[0-9][0-9][0-9] *.mps + rm -f examples.tex examples.ps examples.dvi examples.pdf + rm -f *.dvi *.aux *.log *\~ + rm -f mpxerr.* *.mpx mptextmp.* + rm -f nohup.out + +cleanse: clean + rm -f examples.[0-9].gif examples.[0-9][0-9].gif examples.[0-9][0-9][0-9].gif + rm -f examples.[0-9].eps examples.[0-9][0-9].eps examples.[0-9][0-9][0-9].eps + rm -f examples.[0-9].ps examples.[0-9][0-9].ps examples.[0-9][0-9][0-9].ps + rm -f examples.[0-9].tex examples.[0-9][0-9].tex examples.[0-9][0-9][0-9].tex + rm -f examples.html diff --git a/info/metapost/examples/README b/info/metapost/examples/README new file mode 100644 index 0000000000..a884163d65 --- /dev/null +++ b/info/metapost/examples/README @@ -0,0 +1,21 @@ +These are a few (hundred) example pictures drawn with +metapost, ranging from very simple (lines and circles) +to rather intricate (uncommon geometric transformations, +fractals, bitmap, etc.). + +README this file +data1 sample data file (for plot drawings) +data2 +data3 +examples.mp The examples +mptohtml.pl A perl script that turns the examples into a PostScript + file and into an HTML file and GIF pictures + The resulting (huge) Web page may be seen here: + http://www.math.jussieu.fr/~zoonek/LaTeX/Metapost/metapost.html +Makefile runs the above script + +Vincent Zoonekynd <zoonek@math.jussieu.fr> +August 1999 +Updated august 2001 +Version 0.01 +Distributed under the GPL (see http://www.gnu.org/copyleft/gpl.html for details) diff --git a/info/metapost/examples/data1 b/info/metapost/examples/data1 new file mode 100644 index 0000000000..24092f087b --- /dev/null +++ b/info/metapost/examples/data1 @@ -0,0 +1,11 @@ +0 82 +1 90 +2 100 +3 97 +4 70 +5 75 +6 93 +7 103 +8 115 +9 121 +10 119 diff --git a/info/metapost/examples/data2 b/info/metapost/examples/data2 new file mode 100644 index 0000000000..c934e72a70 --- /dev/null +++ b/info/metapost/examples/data2 @@ -0,0 +1,11 @@ +0 100 +1 95 +2 85 +3 80 +4 83 +5 90 +6 88 +7 96 +8 99 +9 100 +10 105 diff --git a/info/metapost/examples/data3 b/info/metapost/examples/data3 new file mode 100644 index 0000000000..7e54a066ff --- /dev/null +++ b/info/metapost/examples/data3 @@ -0,0 +1,11 @@ +0 125 +1 119 +2 123 +3 104 +4 81 +5 94 +6 90 +7 88 +8 85 +9 89 +10 90 diff --git a/info/metapost/examples/examples.mp b/info/metapost/examples/examples.mp new file mode 100644 index 0000000000..7a156f03de --- /dev/null +++ b/info/metapost/examples/examples.mp @@ -0,0 +1,4896 @@ +warningcheck:=0; + +input rboxes; +input sarith; +input graph; + +verbatimtex +\documentclass[a4paper,12pt]{article} +\usepackage[T1]{fontenc} +\usepackage[latin1]{inputenc} +\begin{document} +etex + +vardef TEX primary s = + write "verbatimtex" to "mptextmp.mp"; + write "\documentclass[12pt]{article}" to "mptextmp.mp"; + write "\usepackage[T1]{fontenc}" to "mptextmp.mp"; + write "\usepackage{amsmath,amssymb}" to "mptextmp.mp"; + write "\begin{document}" to "mptextmp.mp"; + write "etex" to "mptextmp.mp"; + write "btex "&s&" etex" to "mptextmp.mp"; + write EOF to "mptextmp.mp"; + scantokens "input mptextmp" +enddef; + +vardef longueur(expr p) = + save l,i; + numeric l; + l:=0; + for i=0 step .01 until length(p): + l:=l+abs( (point i of p) - (point(i+.01) of p) ); + endfor; + l % Pas de point-virgule +enddef; + +vardef milieu(expr p) = + save l,i,tot,A,B; + numeric l,tot,i; + pair A,B; + tot := longueur(p); + l:=0; + B := point 0 of p; + for i:=0 step .01 until length(p): + A := B; + B := point i of p; + l := l+abs(B-A); + exitif l > 1/2 tot; + endfor; + show l; show tot; + 1/2[A,B] +enddef; + +vardef milieu_time(expr p) = + save l,i,tot,A,B,t; + numeric l,tot,i,t; + pair A,B; + tot := longueur(p); + l:=0; + B := point 0 of p; + for i:=0 step .01 until length(p): + t:=i; + A := B; + B := point i of p; + l := l+abs(B-A); + exitif l > 1/2 tot; + endfor; + t +enddef; + +beginfig(1) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C; + +endfig; +beginfig(2) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + +endfig; +beginfig(3) + pair A[]; + A[0]:=(-1cm, -1cm); + A[1]:=( 1cm, -1cm); + A[2]:=( 1cm, 1cm); + A[3]:=(-1cm, 1cm); + draw A[0]--A[1]--A[2]--A[3]--cycle; + draw A[0]--A[2]; + draw A[1]--A[3]; +endfig; +beginfig(4) + pair A; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A withpen pencircle scaled 4bp; + +endfig; +beginfig(5) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + draw A withpen pencircle scaled 4bp; + draw B withpen pencircle scaled 4bp; + draw C withpen pencircle scaled 4bp; +endfig; +beginfig(6) + pair A, B, C, D; + A:=(0,0); B:=(1cm,0); + C:=(1cm,1cm); D:=(0,1cm); + draw A--B--C--D--cycle; + draw A--C; + draw B--D; + draw A withpen pencircle scaled 4bp; + draw B withpen pencircle scaled 4bp; + draw C withpen pencircle scaled 4bp; + draw D withpen pencircle scaled 4bp; +endfig; +beginfig(7) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + draw 1/2[A,B] -- C; + draw 1/2[B,C] -- A; + draw 1/2[C,A] -- B; +endfig; +beginfig(8) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + draw 1/2[A,B] -- C; + draw 1/2[B,C] -- A; + draw 1/2[C,A] -- B; + draw 1/3 A + 1/3 B + 1/3 C + withpen pencircle scaled 4bp; +endfig; +beginfig(9) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + draw A--B withpen pencircle scaled 2bp; + +endfig; +beginfig(10) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + draw A--B withcolor (green + red); + +endfig; +beginfig(11) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B; + draw B--C dashed evenly; + draw C--A dashed withdots; + +endfig; +beginfig(12) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B withpen pencircle scaled 2bp withcolor .8white; + draw B--C withpen pencircle scaled 2bp withcolor .6white; + draw C--A withpen pencircle scaled 2bp withcolor .4white; + +endfig; +beginfig(13) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + draw 1/2[A,B] -- C dashed evenly; + draw 1/2[B,C] -- A dashed evenly; + draw 1/2[C,A] -- B dashed evenly; + draw 1/3 A + 1/3 B + 1/3 C + withpen pencircle scaled 4bp + withcolor red; +endfig; +beginfig(14) + draw (0,0)--(3cm,0) dashed evenly scaled 2; + draw (0,-5mm)--(3cm,-5mm) dashed evenly; + +endfig; +beginfig(15) + draw (0,0)--(3cm,0) + dashed dashpattern(on 2bp off 3bp); + +endfig; +beginfig(16) + draw (0,0)--(3cm,0) dashed dashpattern(on 1bp off 2bp on 10bp off 2bp); +endfig; +beginfig(17) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + drawarrow C--B--A; + drawarrow A--C withpen pencircle scaled 2bp; + +endfig; +beginfig(18) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw C--B--A--cycle; + drawdblarrow A--C withpen pencircle scaled 2bp; + +endfig; +beginfig(19) + draw (-1.5cm,0)--(1.5cm,0); + draw (0,-1.5cm)--(0,1.5cm); + drawarrow (0,0)--(1cm,0) + withpen pencircle scaled 2bp; + drawarrow (0,0)--(0,1cm) + withpen pencircle scaled 2bp; +endfig; +beginfig(20) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + fill A--B--C--cycle withcolor .8 white; + +endfig; +beginfig(21) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + fill A--B--C--cycle withcolor .8 white; + draw A--B--C--cycle; + +endfig; +beginfig(22) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + fill A--B--C--cycle withcolor .8 white; + draw A--B--C--cycle withpen pencircle scaled 2bp; +endfig; +beginfig(23) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle withpen pencircle scaled 2bp; + fill A--B--C--cycle withcolor .8 white; +endfig; +beginfig(24) + pair A, B, C, D; + A:=(0,0); B:=(1cm,0); + C:=(1cm,1cm); D:=(0,1cm); + fill A--C--B--D--cycle withcolor .8white; +endfig; +beginfig(25) + pair A, B, C, D; + A:=(0,0); B:=(1cm,0); + C:=(1cm,1cm); D:=(0,1cm); + path p; + p := A--C--B--D--cycle; + fill p withcolor .8white; + draw p; +endfig; +beginfig(26) + pair A, B, C, D; + A:=(-1.5cm,-1.5cm); B:=(1.5cm,-1.5cm); + C:=(1.5cm,1.5cm); D:=(-1.5cm,1.5cm); + fill A--C--B--D--cycle withcolor .8white; + draw (-1.5cm,0)--(1.5cm,0); + draw (0,-1.5cm)--(0,1.5cm); + drawarrow (0,0)--(1cm,0) + withpen pencircle scaled 2bp; + drawarrow (0,0)--(0,1cm) + withpen pencircle scaled 2bp; +endfig; +beginfig(27) + pair A; + A := (0,0); + draw A withpen pencircle scaled 4bp; + label.top(btex Au dessus etex, A); + label.bot(btex En dessous etex, A); + label.rt (btex À droite etex, A); + label.lft(btex À gauche etex, A); + +endfig; +beginfig(28) + pair A; + A := (0,0); + draw A withpen pencircle scaled 4bp; + label.ulft(btex En haut à gauche etex, A); + label.urt (btex En haut à droite etex, A); + label.llft(btex En bas à gauche etex, A); + label.lrt (btex En bas à droite etex, A); + +endfig; +beginfig(29) + pair A; + A := (0,0); + dotlabel.urt(btex $A$ etex, A); + +endfig; +beginfig(30) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + dotlabel.llft(btex $A$ etex, A); + dotlabel.lrt(btex $B$ etex, B); + dotlabel.top(btex $C$ etex, C); +endfig; +beginfig(31) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + label.bot(btex $1$ etex, 1/2[A,B]); + label.lft(btex $1$ etex, 1/2[A,C]); + label.urt(btex $\sqrt 2$ etex, 1/2[B,C]); +endfig; +beginfig(32) + u:=1cm; + pair A,B,C,D,E,F,G; + A := (-u,u); + B := (0,u); + C := (u,u); + D := (-u,0); + E := (0,0); + F := (u,0); + draw A--D; draw A--E; draw A--F; + draw B--D; draw B--E; draw B--F; + draw C--D; draw C--E; draw C--F; + dotlabel.top(btex $a$ etex, A); + dotlabel.top(btex $b$ etex, B); + dotlabel.top(btex $c$ etex, C); + dotlabel.bot(btex $a'$ etex, D); + dotlabel.bot(btex $b'$ etex, E); + dotlabel.bot(btex $c'$ etex, F); +endfig; +beginfig(33) + draw fullcircle; + +endfig; +beginfig(34) + draw (0,0) withpen pencircle scaled 4bp; + draw fullcircle scaled 1cm; + +endfig; +beginfig(35) + draw (0,0) withpen pencircle scaled 4bp; + draw fullcircle scaled 1cm shifted (1cm,1cm); + +endfig; +beginfig(36) + pair A, B, C; + A:=(0,0); B:=(1cm,0); C:=(0,1cm); + draw A--B--C--cycle; + fill fullcircle scaled 4bp shifted A withcolor white; + fill fullcircle scaled 4bp shifted B withcolor white; + fill fullcircle scaled 4bp shifted C withcolor white; + draw fullcircle scaled 4bp shifted A; + draw fullcircle scaled 4bp shifted B; + draw fullcircle scaled 4bp shifted C; +endfig; +beginfig(37) + draw (0,0) .. (0,1cm) .. (1cm,0) .. (1cm,1cm); + draw (0,0) withpen pencircle scaled 4bp; + draw (0,1cm) withpen pencircle scaled 4bp; + draw (1cm,0) withpen pencircle scaled 4bp; + draw (1cm,1cm) withpen pencircle scaled 4bp; + +endfig; +beginfig(38) + draw (0,0) -- (0,1cm) .. (1cm,0) .. (1cm,1cm); + +endfig; +beginfig(39) + draw (0,0) --- (0,1cm) .. (1cm,0) .. (1cm,1cm); + +endfig; +beginfig(40) + draw (0,0) .. (0,1cm) .. (1cm,0) .. (1cm,1cm) + .. cycle; + +endfig; +beginfig(41) + pair A, B, C, D; + A:=(0,0); B:=(1cm,0); + C:=(1cm,1cm); D:=(0,1cm); + draw A..B..C..D..cycle; +endfig; +beginfig(42) + draw (0,0) .. (1cm,1cm) .. cycle; +endfig; +beginfig(43) + draw (0,0){(0,1)} .. (2cm,0){(1,0)}; + +endfig; +beginfig(44) + draw (0,0){dir 90} .. (2cm,0){dir 0}; + +endfig; +beginfig(45) + draw (0,0){up} .. (2cm,0){right}; + +endfig; +beginfig(46) + draw (0,0){up} .. (2cm,0){up}; +endfig; +beginfig(47) + draw (0,0){up} .. (2cm,0){up} .. cycle; +endfig; +beginfig(48) + alpha := 30; + draw (0,0) -- 2cm*dir 0; + draw (0,0) -- 2cm*dir alpha; + draw 1cm * dir 0 {dir 90} .. + 1cm * dir alpha {dir(90+alpha)}; +endfig; +beginfig(49) + alpha := 30; + draw (0,0) -- 2cm*dir 0; + draw (0,0) -- 2cm*dir alpha; + draw 1cm * dir 0 {dir 90} .. + 1cm * dir alpha {dir(90+alpha)}; + draw 1.1cm * dir 0 {dir 90} .. + 1.1cm * dir alpha {dir(90+alpha)}; +endfig; +beginfig(50) + def draw_angle(expr A, O, B, n) = + draw_angle_(A,O,B,5mm); + if n>1 : draw_angle_(A,O,B,4.5mm); fi; + if n>2 : draw_angle_(A,O,B,4mm); fi; + if n>3 : draw_angle_(A,O,B,5.5mm); fi; + enddef; + def draw_angle_(expr A,O,B,d) = + draw (O + d*unitvector(A-O)) + { d*unitvector(A-O) rotated 90 } + .. + { d*unitvector(B-O) rotated 90 } + (O + d*unitvector(B-O)); + enddef; + pair A, B, C; + A := (0,0); + B := (3cm,0); + C := (1cm,2cm); + draw A--B--C--cycle; + draw_angle(B,A,C,1); + draw_angle(C,B,A,2); + draw_angle(A,C,B,3); +endfig; +beginfig(51) + u:=1cm; + path p; + p := (u,0){up}..(-u,0){down}--cycle; + fill p withcolor .8*white; + draw p withpen pencircle scaled 1bp; +endfig; +beginfig(52) + u:=1cm; + path p; + p := (u,0){up} .. + (-u,0){down} -- + (-.2u,0){up} .. + (.2u,0){down} -- + cycle; + fill p withcolor .8*white; + draw p withpen pencircle scaled 1bp; +endfig; +beginfig(53) + u:=1cm; + pair A,AA,B,BB,C,D; + A := ( .2u, .05u); + AA := ( .2u, -.05u); + B := ( u, .05u); + BB := ( u, -.05u); + C := (-.2u, 0); + D := ( -u, 0); + path p; + p:= B{up} .. D{down} .. BB{up} -- + AA{down} .. C{up} .. A{down} -- cycle; + fill p withcolor .8*white; + draw p withpen pencircle scaled 1bp; +endfig; +beginfig(54) + u:=1cm; + pair A,B,C,D; + A:=(0,0); + B:=u*dir 60; + C:=u*dir -60; + D:=(2u,0); + draw A withpen pencircle scaled 4bp; + draw B withpen pencircle scaled 4bp; + draw C withpen pencircle scaled 4bp; + draw D withpen pencircle scaled 4bp; + draw A--D--B--D--C; + draw A{up}..B; + draw A{down}..C; + draw A{dir 30}..B; + draw A{dir -30}..C; +endfig; +beginfig(55) + draw (0,0) .. (1cm,1cm) .. (2cm,0); + +endfig; +beginfig(56) + draw (0,0) .. tension 2 .. + (1cm,1cm) .. (2cm,0); + +endfig; +beginfig(57) + draw (0,u) {right} .. + ( u*dir -150 ){dir 120} .. + ( u*dir -30 ){dir -120} .. + cycle; +endfig; +beginfig(58) + draw (0,u) {right} .. tension 2 .. + ( u*dir -150 ){dir 120} .. tension 2 .. + ( u*dir -30 ){dir -120} .. tension 2 .. + cycle; +endfig; +beginfig(59) + draw (0,u) {right} .. tension 4 .. + ( u*dir -150 ){dir 120} .. tension 4 .. + ( u*dir -30 ){dir -120} .. tension 4 .. + cycle; +endfig; +beginfig(60) + u:=.5cm; + pair A,B,C,D; + A:=(0,0); B:=(-u,2u); + C:=(4u,3u); D:=(3u,0); + draw A.. controls B and C .. D + withpen pencircle scaled 2pt; + draw B--C dashed evenly; + drawarrow A--B; + drawarrow D--C; + +endfig; +beginfig(61) + pair A, B, C, D; + A = (0,0); + D = (2u,0); + B = (-u,2u); + C = (3u,3u); + + draw A withpen pencircle scaled 4bp; + draw B withpen pencircle scaled 4bp; + draw C withpen pencircle scaled 4bp; + draw D withpen pencircle scaled 4bp; + draw A .. controls B and C .. D; + + pair a[]; + a[1] := A; + a[2] := B; + a[3] := C; + a[4] := D; + + a[12] := 1/2 [ a[1], a[2] ]; + a[23] := 1/2 [ a[2], a[3] ]; + a[34] := 1/2 [ a[3], a[4] ]; + a[123] := 1/2 [ a[12], a[23] ]; + a[234] := 1/2 [ a[23], a[34] ]; + a[1234] := 1/2 [ a[123], a[234] ]; + + draw a[1234] withpen pencircle scaled 4bp; +endfig; +beginfig(62) +vardef bezier(expr n,A,B,C,D) = + save a; + pair a[]; + a[1] := A; + a[2] := B; + a[3] := C; + a[4] := D; + + a[12] := 1/2 [ a[1], a[2] ]; + a[23] := 1/2 [ a[2], a[3] ]; + a[34] := 1/2 [ a[3], a[4] ]; + a[123] := 1/2 [ a[12], a[23] ]; + a[234] := 1/2 [ a[23], a[34] ]; + a[1234] := 1/2 [ a[123], a[234] ]; + + if n>0: + bezier(n-1, a[1], a[12], a[123], a[1234]); + bezier(n-1, a[1234], a[234], a[34], a[4]); + else: + draw a[1234] withpen pencircle scaled 2bp; + fi; +enddef; + + pair A, B, C, D; + A = (0,0); + D = (2u,0); + B = (-u,2u); + C = (3u,3u); + + draw A withpen pencircle scaled 4bp; + draw B withpen pencircle scaled 4bp; + draw C withpen pencircle scaled 4bp; + draw D withpen pencircle scaled 4bp; + + bezier(5,A,B,C,D); +endfig; +beginfig(63) + draw (0,0){up} .. (1cm, 1mm) .. (2cm,0){down}; + +endfig; +beginfig(64) + draw (0,0){up} ... (1cm, 1mm) ... (2cm,0){down}; + +endfig; +beginfig(65) + draw (0,0){curl 0} .. (0,1cm)..(1cm,0)..(1cm,1cm); + +endfig; +beginfig(66) + draw (0,0){curl 1} .. (0,1cm)..(1cm,0)..(1cm,1cm); + +endfig; +beginfig(67) + draw (0,0){curl 2} .. (0,1cm)..(1cm,0)..(1cm,1cm); + +endfig; +beginfig(68) + pair A,B,C,D; + xpart A = ypart A = ypart B = xpart C = 0; + xpart B = ypart C = xpart D = ypart D = 2cm; + draw A--B--C--D--cycle withpen pencircle scaled 2bp; +endfig; +beginfig(69) + pair A,B,C,D,M; + numeric lambda, mu; + A=(0,0); B=(2cm,3cm); + C=(1cm,0); D=(-1cm,2cm); + M = lambda [A,B]; + M = mu [C,D]; + draw A--B; + draw C--D; + draw M withpen pencircle scaled 4bp; + +endfig; +beginfig(70) + pair A,B,C,D,M; + A=(0,0); B=(2cm,3cm); + C=(1cm,0); D=(-1cm,2cm); + M = whatever [A,B]; + M = whatever [C,D]; + draw A--B; + draw C--D; + draw M withpen pencircle scaled 4bp; + +endfig; +beginfig(71) + pair A,B,C,AA,BB,CC,G; + A=(0,0); B=(3cm,0); C=(1cm,2cm); + AA = 1/2 [B,C]; + BB = 1/2 [C,A]; + CC = 1/2 [A,B]; + G = whatever [A,AA]; + G = whatever [B,BB]; + draw A--B--C--cycle; + draw A--AA dashed withdots; + draw B--BB dashed withdots; + draw C--CC dashed withdots; + draw G withpen pencircle scaled 4bp; +endfig; +beginfig(72) + path p; + p := fullcircle scaled 5mm; + draw p; + draw p shifted (1mm,2mm); + draw p shifted 2(1mm,2mm); + draw p shifted 3(1mm,2mm); + draw p shifted 4(1mm,2mm); + draw p shifted 5(1mm,2mm); + +endfig; +beginfig(73) + path p; + p := (5mm,-5mm) {right} .. (2cm,0); + draw p; + draw p rotated 10; + draw p rotated 20; + draw p rotated 30; + draw p rotated 40; + draw p rotated 50; + draw p rotated 60; + draw p rotated 70; + draw p rotated 80; + draw p rotated 90; + +endfig; +beginfig(74) + path p; + p := fullcircle scaled 5mm; + draw p; + draw p xscaled 2; + draw p xscaled 3; + draw p xscaled 4; + +endfig; +beginfig(75) + pair A,B,C,D,E; + A := (1cm,0); + B := A rotated 72; + C := B rotated 72; + D := C rotated 72; + E := D rotated 72; + draw A--B--C--D--E--cycle; +endfig; +beginfig(76) + pair A,B,C,D,E; + A := (1cm,0); + B := A rotated 72; + C := B rotated 72; + D := C rotated 72; + E := D rotated 72; + draw A--C--E--B--D--cycle; +endfig; +beginfig(77) + pair A,B,C,D,E; + A := (1cm,0); + B := A rotated 72; + C := B rotated 72; + D := C rotated 72; + E := D rotated 72; + pair AA, BB, CC, DD, EE; + AA = whatever [A, C]; + AA = whatever [B, D]; + BB = whatever [B, D]; + BB = whatever [C, E]; + CC = whatever [C, E]; + CC = whatever [D, A]; + DD = whatever [D, A]; + DD = whatever [E, B]; + EE = whatever [E, B]; + EE = whatever [A, C]; + fill A--C--E--B--D--cycle withcolor .8white; + fill AA--BB--CC--DD--EE--cycle withcolor white; + draw A--C--E--B--D--cycle; +endfig; +beginfig(78) + path p; + p := (0,0) -- (1cm,0); + drawarrow p withpen pencircle scaled 2bp; + drawarrow p zscaled (1,2); + +endfig; +beginfig(79) + u:=1cm; + path p; p := (0,0) -- (u,0); + pair A; A := (u,-u); + numeric a; a := 90; + drawarrow p withpen pencircle scaled 1bp; + drawarrow p rotatedaround( A, a ); + drawarrow p shifted -A rotated a shifted A + withpen pencircle scaled 1bp dashed withdots; +endfig; +beginfig(80) + path p; p := (0,0) -- (u,0); + pair A; A := (u,-u); + numeric a; a := 90; + drawarrow p withpen pencircle scaled 1bp; + draw A withpen pencircle scaled 4bp; + label ulft ( btex $A$ etex, A ); + draw (0,0) withpen pencircle scaled 4bp; + label bot ( btex $O$ etex, (0,0) ); + for i=0 upto 10: + drawarrow p shifted -(i*A/10) withcolor red; + endfor; + for i=0 upto 10: + drawarrow p shifted -A rotated (i*a/10) withcolor green; + endfor; + for i=0 upto 10: + drawarrow p shifted -A rotated a shifted (i*A/10) withcolor blue; + endfor; +endfig; +beginfig(81) + pair A,B,C,AA,BB,CC,H; + A=(0,0); B=(3cm,0); C=(1cm,2cm); + AA - A = whatever * (B-C) rotated 90; + AA = whatever [B,C]; + BB - B = whatever * (A-C) rotated 90; + BB = whatever [A,C]; + CC - C = whatever * (A-B) rotated 90; + CC = whatever [A,B]; + H = whatever [A,AA]; + H = whatever [B,BB]; + draw A--B--C--cycle; + draw A--AA; + draw B--BB; + draw C--CC; + draw H withpen pencircle scaled 4bp; +endfig; +beginfig(82) + pair A,B,C,H; + A=(0,0); B=(3cm,0); C=(1cm,2cm); + H - A = whatever * (B-C) rotated 90; + H - B = whatever * (A-C) rotated 90; + draw A--B--C--cycle; + draw H withpen pencircle scaled 4bp; +endfig; +beginfig(83) + pair A,B,C,O; + A=(0,0); B=(3cm,0); C=(1cm,2cm); + O - 1/2[B,C] = whatever * (B-C) rotated 90; + O - 1/2[A,B] = whatever * (A-B) rotated 90; + draw A--B--C--cycle; + draw O withpen pencircle scaled 4bp; + draw fullcircle scaled 2abs(O-A) shifted O; +endfig; +beginfig(84) + pair A,B,C,D; + u:=2cm; + A=(0,0); B=(u,0); C=(u,u); D=(0,u); + + transform T; + A transformed T = 1/5[A,B]; + B transformed T = 1/5[B,C]; + C transformed T = 1/5[C,D]; + + path p; + p = A--B--C--D--cycle; + draw p; + draw p transformed T; + +endfig; +beginfig(85) + pair A,B,C,D; + u:=2cm; + A=(0,0); B=(u,0); C=(u,u); D=(0,u); + + transform T; + A transformed T = 1/5[A,B]; + B transformed T = 1/5[B,C]; + C transformed T = 1/5[C,D]; + + path p; + p = A--B--C--D--cycle; + for i=0 upto 100: + draw p; + p:= p transformed T; + endfor; + +endfig; +beginfig(86) + u:=1cm; + pair A,B,C,D,E; + A := (0,u); + B := A rotated 72; + C := B rotated 72; + D := C rotated 72; + E := D rotated 72; + transform T; + A transformed T = 1/5[A,B]; + B transformed T = 1/5[B,C]; + C transformed T = 1/5[C,D]; + path p; + p := A--B--C--D--E--cycle; + draw p; + p := p transformed T; draw p; + p := p transformed T; draw p; + p := p transformed T; draw p; +endfig; +beginfig(87) + u:=3mm; + fill fullcircle scaled 2u withcolor .8white; + fill fullcircle scaled u shifted (u*dir30) + withcolor .8white; + fill fullcircle scaled u shifted (u*dir150) + withcolor .8white; +endfig; +beginfig(88) + u:=3mm; + transform T; + (0,0) transformed T = (0,0); + (1,0) transformed T = (1,1); + (0,1) transformed T = (1,0); + + fill fullcircle scaled 2u transformed T withcolor .8white; + fill fullcircle scaled u shifted (u*dir30) transformed T + withcolor .8white; + fill fullcircle scaled u shifted (u*dir150) transformed T + withcolor .8white; +endfig; +beginfig(89) + u:=3mm; + transform T; + xpart T = ypart T = 0; + xxpart T = 1; + yxpart T = 2; + xypart T = 3; + yypart T = 4; + + fill fullcircle scaled 2u transformed T withcolor .8white; + fill fullcircle scaled u shifted (u*dir30) transformed T + withcolor .8white; + fill fullcircle scaled u shifted (u*dir150) transformed T + withcolor .8white; +endfig; +beginfig(90) + draw fullcircle scaled 1cm; + draw fullcircle scaled 5mm shifted (1cm*dir45); + draw fullcircle scaled 5mm shifted (1cm*dir135); + picture mypicture; + mypicture := currentpicture; + currentpicture := nullpicture; + draw mypicture; + draw mypicture shifted (1mm,1mm); + draw mypicture shifted (2mm,2mm); + +endfig; +beginfig(91) + picture pic; + pic := nullpicture; + addto pic contour fullcircle scaled 1cm + withcolor .8white; + addto pic doublepath fullcircle scaled 1cm + withpen pencircle scaled .5bp; + addto pic also pic shifted (1mm,1mm); + draw pic; + +endfig; +beginfig(92) + u:=3mm; + picture mickey; + mickey := nullpicture; + addto mickey contour fullcircle scaled 2u + withcolor .8white; + addto mickey contour fullcircle scaled u + shifted (u*dir30) withcolor .8white; + addto mickey contour fullcircle scaled u + shifted (u*dir150) + withcolor .8white; + draw mickey; +endfig; +beginfig(93) + u:=3mm; + picture mickey; + mickey := nullpicture; + addto mickey contour fullcircle scaled 2u + withcolor .8white; + addto mickey contour fullcircle scaled u + shifted (u*dir30) withcolor .8white; + addto mickey contour fullcircle scaled u + shifted (u*dir150) withcolor .8white; + + transform T; + (0,0) transformed T = (0,0); + (1,0) transformed T = (1,1); + (0,1) transformed T = (1,0); + + draw mickey transformed T; +endfig; +beginfig(94) + u:=3mm; + picture mickey; + fill fullcircle scaled 2u withcolor .8white; + fill fullcircle scaled u shifted (u*dir30) + withcolor .8white; + fill fullcircle scaled u shifted (u*dir150) + withcolor .8white; + mickey := currentpicture; + currentpicture := nullpicture; + + transform T; + (0,0) transformed T = (0,0); + (1,0) transformed T = (1,1); + (0,1) transformed T = (1,0); + + draw mickey transformed T; +endfig; +beginfig(95) + pair A,B; + path p; + A = (0,1cm); + B = A rotated 120; + p = A{dir 0} .. tension 2 .. B{dir 120}; + draw p; + draw p rotated 120; + draw p rotated -120; +endfig; +beginfig(96) + pair A,B; + path p; + numeric n; + n:=5; + A = (0,1cm); + B = A rotated (2*360/n); + p = A{dir 180} .. tension 4 .. B{dir (180+2*360/n)}; + draw p withcolor red; + draw p rotated (1*360/n); + draw p rotated (2*360/n); + draw p rotated (3*360/n); + draw p rotated (4*360/n); +endfig; +beginfig(97) + path c[], l[]; + c[0] = fullcircle xscaled 1cm yscaled .5cm + shifted (0,1cm); + c[1] = c[0] rotated 120; + c[2] = c[1] rotated 120; + pair A; + A = (-.5cm,1cm); + l[0] = A{down} .. + (A xscaled -1 rotated 120){-down rotated 120}; + l[1] = l[0] rotated 120; + l[2] = l[1] rotated 120; + draw c[0]; draw c[1]; draw c[2]; + draw l[0]; draw l[1]; draw l[2]; +endfig; +beginfig(98) + path c[], l[]; + c[0] = fullcircle xscaled 1cm yscaled .5cm + shifted (0,1cm); + c[1] = c[0] rotated (360/4); + c[2] = c[1] rotated (360/4); + c[3] = c[2] rotated (360/4); + pair A; + A = (-.5cm,1cm); + l[0] = A{down} .. + (A xscaled -1 rotated (360/4)) + {-down rotated (360/4)}; + l[1] = l[0] rotated (360/4); + l[2] = l[1] rotated (360/4); + l[3] = l[2] rotated (360/4); + draw c[0]; draw c[1]; draw c[2]; draw c[3]; + draw l[0]; draw l[1]; draw l[2]; draw l[3]; +endfig; +beginfig(99) + pair A, B; + A := (0,0); B := (2cm,1cm); + draw A withpen pencircle scaled 4bp; + draw B withpen pencircle scaled 4bp; + draw fullcircle scaled abs(B-A) shifted 1/2[A,B]; + +endfig; +beginfig(100) + pair A; + A:=(2cm,2cm); + drawarrow origin--A; + drawarrow (origin--A) rotated -1/3 angle(A); + drawarrow (origin--A) rotated -2/3 angle(A); + drawarrow (origin--A) rotated -angle(A); + +endfig; +beginfig(101) + pair A,B; + A:=(1cm,2cm); B:=(2cm,1cm); + numeric alpha; + alpha = angle(A) - angle(B); + drawarrow origin--A; + drawarrow origin--B; + drawarrow (origin--A) rotated -1/3 alpha; + drawarrow (origin--A) rotated -2/3 alpha; + drawarrow (origin--A) rotated -alpha; +endfig; +beginfig(102) + pair A,B,C; + A=(0,0); B=(3cm,0); C=(1cm,2cm); + draw A--B--C--cycle; + label.llft(TEX decimal(angle(C-A)-angle(B-A)), A); + label.lrt(TEX decimal(angle(A-B)-angle(C-B)), B); + label.urt(TEX decimal(angle(B-C)-angle(A-C)), C); +endfig; +beginfig(103) + pair A,AA,B,BB,C,CC,O,H; + A=(0,0); B=(3cm,0); C=(1cm,2cm); + AA = 1/2[B,C]; + BB = 1/2[A,C]; + CC = 1/2[A,B]; + O - 1/2[BB,CC] = whatever * (BB-CC) rotated 90; + O - 1/2[AA,BB] = whatever * (AA-BB) rotated 90; + draw A--B--C--cycle; + draw AA withpen pencircle scaled 4bp; + draw BB withpen pencircle scaled 4bp; + draw CC withpen pencircle scaled 4bp; + draw fullcircle scaled 2abs(O-AA) shifted O; + % Il faut aussi tracer les hauteurs + pair AA,BB,CC; + AA - A = whatever * (B-C) rotated 90; + AA = whatever [B,C]; + BB - B = whatever * (A-C) rotated 90; + BB = whatever [A,C]; + CC - C = whatever * (A-B) rotated 90; + CC = whatever [A,B]; + draw A--AA; draw B--BB; draw C--CC; + draw AA withpen pencircle scaled 4bp; + draw BB withpen pencircle scaled 4bp; + draw CC withpen pencircle scaled 4bp; + % Il passe aussi par le milieu de HA, HB, HC + H = whatever [A,AA]; + H = whatever [B,BB]; + draw 1/2 [A,H] withpen pencircle scaled 4bp; + draw 1/2 [B,H] withpen pencircle scaled 4bp; + draw 1/2 [C,H] withpen pencircle scaled 4bp; +endfig; +beginfig(104) + pair A,B,C,M,h; + u:=2cm; + A=(0,0); B=(2u,-.5u); C=(u,u); + draw A--B--C--cycle; + (M-A) = whatever * ( + (A-C) rotated 1/2( angle(B-A) - angle(C-A)) ); + (M-B) = whatever * ( + (B-A) rotated 1/2( angle(C-B) - angle(A-B)) ); + draw M--A; draw M--B; draw M--C; + M-h = whatever * (B-C) rotated 90; + h = whatever[B,C]; + draw fullcircle scaled 2 abs(M-h) shifted M; +endfig; +beginfig(105) + path p; + p = (0,0){up} .. (2cm,0){down}; + draw p; + draw point 0 of p withpen pencircle scaled 4bp; + draw point .5 of p withpen pencircle scaled 4bp; + draw point 1 of p withpen pencircle scaled 4bp; + +endfig; +beginfig(106) + path p; + p = (0,0){up} .. (2cm,0){down}; + draw p; + pair A; + A := point 0 of p; + B := A + 1cm*unitvector(direction 0 of p); + drawarrow A--B withpen pencircle scaled 1bp; + A := point .5 of p; + B := A + 1cm*unitvector(direction .5 of p); + drawarrow A--B withpen pencircle scaled 1bp; + A := point 1 of p; + B := A + 1cm*unitvector(direction 1 of p); + drawarrow A--B withpen pencircle scaled 1bp; + +endfig; +beginfig(107) + u:=5mm; + path p; + p = (0,0) {curl 0} .. (u,2u) .. (2u,1.5u) + .. (3u,2u) .. {curl 0} (4u,0); + draw subpath(0,1) of p withcolor red; + draw subpath(1,2) of p withcolor green; + draw subpath(2,3) of p withcolor blue; + draw subpath(3,3.5) of p dashed evenly; + draw subpath(3.5,4) of p dashed withdots; + +endfig; +beginfig(108) + u:=1cm; + path p,q; + p := (0,0){up} .. (u,2u){up}; + q := (u,0){up} .. (0,2u){up}; + draw p; + draw subpath(0,.4) of q withpen pencircle scaled 1bp; + draw subpath(.6,1) of q withpen pencircle scaled 1bp; +endfig; +beginfig(109) + u:=1cm; + path a,b,c,d; + a = (-u,-.2u){up} .. tension 1.2 .. (u,-.2u){down}; + b = a rotated 90; + c = b rotated 90; + d = c rotated 90; + fill buildcycle(a,b,c,d) withcolor .8white; + draw a; draw b; draw c; draw d; + +endfig; +beginfig(110) + u:=1cm; + path c[]; + c[1] := fullcircle scaled u; + c[2] := c[1] shifted (0,.5u); + draw c[1] dashed evenly; + draw c[2] dashed evenly; + draw buildcycle(c[1],c[2]) withpen pencircle scaled 1bp; +endfig; +beginfig(111) + path a,b,c; + a = fullcircle scaled 2u shifted (.5u,0); + b = a rotated (360/3); + c = b rotated (360/3); + fill a withcolor red; + fill b withcolor green; + fill c withcolor blue; + fill buildcycle(a,b) withcolor red + green; + fill buildcycle(b,c) withcolor green + blue; + fill buildcycle(c,a) withcolor blue + red; + fill buildcycle(a,b,c) withcolor white; + draw a; draw b; draw c; +endfig; +beginfig(112) + def compute_curve(suffix f)(expr xmin, xmax, xinc) = + ( (xmin,f(xmin)) + for x=xmin+xinc step xinc until xmax: + .. (x,f(x)) + endfor ) + enddef; + vardef f(expr x) = x**2 + 1 enddef; + vardef g(expr x) = 2 - (x-1)**2 enddef; + path p, q; + p := compute_curve(f, -1, 1.5, .1) scaled 1cm; + q := compute_curve(g, -.5, 2, .1) scaled 1cm; + fill buildcycle(p,reverse q) withcolor red+green; + draw p withpen pencircle scaled 1bp; + draw q withpen pencircle scaled 1bp; + draw (-1cm,0) -- (2cm,0); + draw (0,g(-.5)*1cm) -- (0,f(1.5)*1cm); +endfig; +beginfig(113) + path p, q; + p = (0,0){up} .. (2cm,0){up}; + q = (0,1cm){dir -60}..(1cm,-1cm)..{dir 60}(2cm,1cm); + draw p; draw q; + draw p intersectionpoint q withpen pencircle scaled 4bp; + +endfig; +beginfig(114) + path p, q; + p = (0,0){up} .. (2cm,0){up}; + q = (0,1cm){dir -60}..(1cm,-1cm)..{dir 60}(2cm,1cm); + draw p; draw q; + numeric a,b; + (a,whatever) = p intersectiontimes q; + draw point a of p withpen pencircle scaled 4bp; + +endfig; +beginfig(115) + pair A,B; + path p; + A = (0,1cm); + B = A rotated 120; + p = A{dir 0} .. tension 2 .. B{dir 120}; + numeric a; + (a,whatever) = p intersectiontimes (p rotated 120); + draw subpath(0,a-.02) of p; + draw subpath(a+.02,1) of p; + draw subpath(0,a-.02) of p rotated 120; + draw subpath(a+.02,1) of p rotated 120; + draw subpath(0,a-.02) of p rotated -120; + draw subpath(a+.02,1) of p rotated -120; +endfig; +beginfig(116) + u:=2cm; + pair A[], B[], C[], D[], E[]; + path p[]; + + A[0] = u*up; + for i=1 upto 10: + A[i] := A[i-1] rotated 72; + endfor; + for i=0 upto 4: + p[i] := A[i]--A[i+1]; + draw p[i]; + draw (point 1 of p[i]) -- + ( (point 1 of p[i]) + 4mm*unitvector(direction 1 of p[i])); + draw (point 0 of p[i]) -- + ( (point 0 of p[i]) - 4mm*unitvector(direction 0 of p[i])); + endfor + + for i=0 upto 9: + B[i] := 1/2[ A[i], A[i+1] ]; + endfor; + B[5]:=B[0]; + + for i=0 upto 9: + C[i] := .8*B[i]; + endfor; + + for i=0 upto 4: + p[i] := B[i] --- C[i] .. C[i+2]{dir 72i}; + draw p[i]; + draw (point 2 of p[i]) -- + ( (point 2 of p[i]) + 4mm*unitvector(direction 2 of p[i])); + draw (point 0 of p[i]) -- + ( (point 0 of p[i]) - 4mm*unitvector(direction 0 of p[i])); + endfor; + for i=0 upto 4: + draw subpath(1,1.4) of p[i] withpen pencircle scaled 4bp withcolor white; + draw subpath(0,1.5) of p[i]; + endfor; + + for i=0 upto 4: + draw A[i] withpen pencircle scaled 4bp; + draw B[i] withpen pencircle scaled 4bp; + draw C[i] withpen pencircle scaled 4bp; + endfor; +endfig; +beginfig(117) + u:=2cm; + pair A, B, C, D, E; + path p, q, r; + + A = u*up; + p := (-.2)[ A, A rotated 72 ] -- (1.2)[ A, A rotated 72 ]; + for i=0 upto 5: + draw p rotated 72i; + endfor; + B := 1/2[ A, A rotated 72 ]; + C := .8*B; + + p := B --- C .. (C rotated (2*72)){right}; + % On allonge le chemin p + p := ( (point 0 of p) - 4mm*unitvector(direction 0 of p)) + -- + (point 0 of p) + & p & + (point 2 of p) + -- + ( (point 2 of p) + 4mm*unitvector(direction 2 of p)); + + E = p intersectionpoint (p rotated 72); + q := p cutbefore fullcircle scaled -2mm shifted E; + r := p cutafter fullcircle scaled 2mm shifted E; + + for i=0 upto 4: + draw q rotated 72i; + draw r rotated 72i; + draw A rotated 72i withpen pencircle scaled 4bp; + draw B rotated 72i withpen pencircle scaled 4bp; + draw C rotated 72i withpen pencircle scaled 4bp; + endfor; +endfig; +beginfig(118) + for i=0 step 1 until 3: + draw 1cm*right rotated (i*90) + withpen pencircle scaled 4bp; + endfor; + +endfig; +beginfig(119) + draw for i=0 step 1 until 3: + 1cm*right rotated (i*90) -- + endfor cycle; + +endfig; +beginfig(120) + n:=5; + draw for i=0 step 1 until n-1: + 1cm*up rotated (i*360/n) -- + endfor cycle; +endfig; +beginfig(121) + n:=7; + draw for i=0 step 1 until n-1: + 1cm*up rotated (i*360/n) -- + endfor cycle; +endfig; +beginfig(122) + path p; + p = (0,0) .. (-1cm,2cm) .. (2cm,1cm) .. (1cm,0); + draw p; + n:=10; + for i=0 step 1 until n: + draw point (i/n*length(p)) of p + withpen pencircle scaled 4bp; + endfor; +endfig; +beginfig(123) + path p; + p = (0,0) .. (-1cm,2cm) .. (2cm,1cm) .. (1cm,0); + draw p; + n:=10; + for i=0 step length(p)/n until length(p): + drawarrow (point i of p) -- + 1cm * unitvector(direction i of p) + shifted point i of p; + endfor; +endfig; +beginfig(124) + u:=1cm; + draw (-2u,0)--(2u,0); + draw (0,-2u)--(0,2u); + for i=-2u step u until 2u: + draw (i,u/20)--(i,-u/20); + draw (u/20,i)--(-u/20,i); + endfor; +endfig; +beginfig(125) + u:=1cm; + draw (-2u,0)--(2u,0); + draw (0,-2u)--(0,2u); + for i=-2u step u until 2u: + draw (i,u/10)--(i,-u/10); + draw (u/10,i)--(-u/10,i); + endfor; + for i=-2u step u/5 until 2u: + draw (i,u/20)--(i,-u/20); + draw (u/20,i)--(-u/20,i); + endfor; +endfig; +beginfig(126) + u:=1cm; + draw (-2u,0)--(2u,0); + draw (0,-2u)--(0,2u); + for i=-2u step u until 2u: + draw (i,2u)--(i,-2u); + draw (2u,i)--(-2u,i); + endfor; +endfig; +beginfig(127) + u:=1cm; + draw (-2u,0)--(2u,0); + draw (0,-2u)--(0,2u); + for i=-2u step u until 2u: + draw (i,2u)--(i,-2u); + draw (2u,i)--(-2u,i); + endfor; + for i=-2u step u/5 until 2u: + draw (i,2u)--(i,-2u) withpen pencircle scaled .2bp; + draw (2u,i)--(-2u,i) withpen pencircle scaled .2bp; + endfor; +endfig; +beginfig(128) + u := 5mm; + % vardef est nécessaire pour pouvoir passer f en argument + vardef f(expr x) = x**2 -.1 enddef; + def axes(expr xmin,xmax,ymin,ymax) = + draw ( (xmin,0) -- (xmax,0) ) scaled u; + draw ( (0,ymin) -- (0,ymax) ) scaled u; + enddef; + def courbe(suffix f)(expr xmin, xmax, M) = + draw ( ( xmin, f(xmin) ) + for i=1 upto M: + -- ( xmin + (i/M)*(xmax - xmin), f( xmin + (i/M)*(xmax - xmin) )) + endfor ) scaled u; + enddef; + vardef newton(suffix f)(expr y, h, M) = + save x,t; + numeric x,t; x:=y; + for i=1 upto M: + t := x - f(x)/( (f(x+h) - f(x))/h ); + draw ( (x,f(x)) -- (t,0) -- (t,f(t)) ) scaled u; + x := t; + endfor; + enddef; + axes(-.5,2,-.5,4); + courbe(f,-.5,2, 100); + newton(f, 2, .01, 10); +endfig; +beginfig(129) + transform T; + u:=1cm; + z0=(0,0); z1=(2u,0); z3 = z1 rotated 90; z2 = z1+z3; + z0 transformed T = .1[z0,z1]; + z1 transformed T = .1[z1,z2]; + z2 transformed T = .1[z2,z3]; + path p; + p = z0--z1--z2--z3--cycle; + fill p withcolor .8*white; + fill p transformed T withcolor white; +endfig; +beginfig(130) + transform T; + u:=1cm; + z0=(0,0); z1=(2u,0); z3 = z1 rotated 90; z2 = z1+z3; + z0 transformed T = .1[z0,z1]; + z1 transformed T = .1[z1,z2]; + z2 transformed T = .1[z2,z3]; + path p; + p = z0--z1--z2--z3--cycle; + for i=0 upto 100: + fill p withcolor .8*white; + p := p transformed T; + fill p withcolor white; + p := p transformed T; + endfor; +endfig; +beginfig(131) + transform T; + u:=1cm; + z1=(0,2u); + n := 5; + for i=1 upto n-1: + z[i+1] = z1 rotated (360*i/n); + endfor; + z1 transformed T = .1[z1,z2]; + z2 transformed T = .1[z2,z3]; + z3 transformed T = .1[z3,z4]; + path p; + p = for i=1 upto n: z[i] -- endfor cycle; + for i=0 upto 100: + fill p withcolor .8*white; + p := p transformed T; + fill p withcolor white; + p := p transformed T; + endfor; +endfig; +beginfig(132) + u:=1cm; + pair A[]; + numeric n; n:=7; + A[0] = (u,0); + for i=1 upto n-1: + A[i] = A[0] rotated (360/n*i); + endfor; + for i=0 upto n-1: + draw A[i] withpen pencircle scaled 4bp; + for j=0 upto n-1: + if i<>j: draw A[i]--A[j] fi; + endfor; + endfor; +endfig; +beginfig(133) + u:=2cm; + numeric n,m; n:=4; m:=5; + pair A[], B[]; + for i=1 upto n-1: A[i+1]-A[i] = (0,.2u); endfor; + for j=1 upto m-1: B[j+1]-B[j] = (0,.2u); endfor; + (0,0) for i=1 upto n: + A[i] endfor = (0,0); + (0,0) for j=1 upto m: + B[j] endfor = (4u,0); + for i=1 upto n: + draw A[i] withpen pencircle scaled 4bp; + endfor; + for j=1 upto m: + draw B[j] withpen pencircle scaled 4bp; + endfor; + for i=1 upto n: + for j=1 upto m: + draw A[i]--B[j]; + endfor; + endfor; +endfig; +beginfig(134) + u:=1cm; + numeric n,m; n:=3; m:=3; + pair A[], B[]; + for i=1 upto n-1: A[i+1]-A[i] = (.5u,0); endfor; + for j=1 upto m-1: B[j+1]-B[j] = (.5u,0); endfor; + (0,0) for i=1 upto n: + A[i] endfor = (0,0); + (0,0) for j=1 upto m: + B[j] endfor = (0,4u); + for i=1 upto n: + draw A[i] withpen pencircle scaled 4bp; + endfor; + for j=1 upto m: + draw B[j] withpen pencircle scaled 4bp; + endfor; + for i=1 upto n: + for j=1 upto m: + draw A[i]--B[j]; + endfor; + endfor; +endfig; +beginfig(135) + pair A[], B[]; + numeric n; n:=6; + for i=0 upto n-1: + A[i] = 1cm * right rotated (i*360/n); + B[i] = 2cm * right rotated (i*360/n); + endfor; + A[n] = A[0]; B[n] = B[0]; + for i=0 upto n-1: + draw A[i] -- A[i+1] -- B[i+1] -- B[i]; + draw A[i] withpen pencircle scaled 4bp; + draw B[i] withpen pencircle scaled 4bp; + endfor; +endfig; +beginfig(136) + numeric n; n:=5; + pair O,A,B,C,D; + O = (0,0); + A = 1cm*up; + B = 2cm*up rotatedabout(A,30); + C = 2cm*up; + D = 2cm*up rotatedabout(A,-30); + for i=0 upto n-1: + draw (O--A--C) rotated (i*360/n); + draw (B--A--D) rotated (i*360/n); + draw A rotated (i*360/n) withpen pencircle scaled 4bp; + draw B rotated (i*360/n) withpen pencircle scaled 4bp; + draw C rotated (i*360/n) withpen pencircle scaled 4bp; + draw D rotated (i*360/n) withpen pencircle scaled 4bp; + endfor; + draw O withpen pencircle scaled 4bp; +endfig; +beginfig(137) + path p; u:=1cm; + p = fullcircle xscaled -u yscaled 3u; + draw p; + for i=2 step .5 until 6: + draw (point 2 of p){down} .. (point i of p); + endfor; +endfig; +beginfig(138) + pair P[], Q[], R[], S[]; + u:=.5cm; + for i=0 upto 4: + P[i] = u* down rotated (i*360/5); + endfor; + P[5] = P[0]; + for i=0 upto 4: + Q[i] = 3*( 1/2[ P[i], P[i+1] ] ); + endfor; + Q[5] = Q[0]; + for i=0 upto 4: + R[i] = 1/3( Q[i] + Q[i+1] + P[i+1] ); + endfor; + R[5] = R[0]; + for i=0 upto 5: + S[i] = 1.5*Q[i]; + endfor; + for i=0 upto 4: + draw P[i] -- P[i+1]; + draw P[i+1] -- R[i]; + draw Q[i] -- R[i]; + draw R[i] -- Q[i+1]; + draw Q[i] -- S[i]; + draw S[i] -- S[i+1]; + endfor; +endfig; +beginfig(139) + pair P[], Q[], R[], S[]; + u:=.5cm; + for i=0 upto 4: + P[i] = u* down rotated (i*360/5); + endfor; + P[5] = P[0]; + for i=0 upto 4: + Q[i] = 3*( 1/2[ P[i], P[i+1] ] ); + endfor; + Q[5] = Q[0]; + for i=0 upto 4: + R[i] = 1/3( Q[i] + Q[i+1] + P[i+1] ); + endfor; + R[5] = R[0]; + for i=0 upto 5: + S[i] = 1.5*Q[i]; + endfor; + for i=0 upto 4: + draw P[i] -- P[i+1]; + draw P[i+1] -- R[i]; + draw Q[i] -- R[i]; + draw R[i] -- Q[i+1]; + draw Q[i] -- S[i]; + draw S[i] -- S[i+1]; + endfor; + draw P[2] -- P[3] -- P[4] -- P[0] -- P[1] -- + R[0] -- Q[0] -- R[4] -- Q[4] -- R[3] + -- Q[3] -- R[2] -- Q[2] -- + S[2] -- S[3] -- S[4] -- S[0] -- S[1] -- + Q[1] -- R[1] -- cycle + withpen pencircle scaled 2bp; +endfig; +beginfig(140) + for i=1 step -.01 until 0: + fill fullcircle scaled (i*2cm) withcolor i*white; + endfor; + draw fullcircle scaled 2cm withpen pencircle scaled 2bp; +endfig; +beginfig(141) + u:=5mm; + path p; + p = (0,0) .. (-1,1) .. (2,0) .. (0,-3) .. cycle; + p := p shifted (-1,0); + for i=1 step -.01 until 0: + fill p scaled (i*u) withcolor i*white; + endfor; + draw p scaled u withpen pencircle scaled 2bp; +endfig; +beginfig(142) + z0 = (50,50); + z1 = z0 rotated 90; + z2 = z1 rotated 90; + z3 = z2 rotated 90; + path carre; + carre = z0--z1--z2--z3--cycle; + s := .01; + path rect; + z4 = s [z2,z3]; z5 = s [z1,z0]; + rect = z1--z2--z4--z5--cycle; + for i=0 step s until 1: + fill rect shifted (i*(z0-z1)) withcolor i*white; + endfor; + draw carre withpen pencircle scaled 2bp; +endfig; +beginfig(143) + z0 = (50,50); + z1 = z0 rotated 90; + z2 = z1 rotated 90; + z3 = z2 rotated 90; + path carre; + carre = z0--z1--z2--z3--cycle; + s := .01; + for i=1 step -s until s: + fill carre scaled i withcolor i*white; + endfor; +endfig; +beginfig(144) + u:=1cm; + vardef degrade(expr p,q,M,N) = + save a,b; + numeric a,b; + a := length(p); + b := length(q); + for i=0 upto M: + draw (i/M) [ point 0 of p, point 0 of q ] + for j=1 upto N: + .. (i/M) [ point (j/N*a) of p, point (j/N*b) of q ] + endfor; + endfor; + enddef; + degrade( + (-.1u,-.1u) .. (.1u,.1u) .. cycle, + (-u,-u) -- (u,-u) -- (u,u) -- (-u,u) -- cycle, + 10, + 100); +endfig; +beginfig(145) + u:=1cm; + def couleur(expr c) = c*white enddef; + vardef degrade(expr p,q,M,N) = + save a,b; + numeric a,b; + a := length(p); + b := length(q); + for i=0 upto M: + draw (i/M) [ point 0 of p, point 0 of q ] + for j=1 upto N: + .. (i/M) [ point (j/N*a) of p, point (j/N*b) of q ] + endfor + withcolor couleur(i/M); + endfor; + enddef; + degrade( + (-.5u,-.5u) .. (.5u,.5u) .. cycle, + (-u,-u) -- (u,-u) -- (u,u) -- (-u,u) -- cycle, + 255, + 100); +endfig; +beginfig(146) + def degrade(expr p, q, N) = + begingroup + save n, m, M; + numeric n, m, M; + n := length(p); + m := length(q); + M := n*m; % Il faudrait prendre le ppcm + for i=0 upto N: + draw + (i/N)[ point 0 of p, point 0 of q ] + { (i/N)[ direction 0 of p, direction 0 of q ] } + for j=1 upto M-1: + .. + { (i/N) [ direction 1 of subpath((j-1)*n/M,j*n/M) of p, + direction 1 of subpath((j-1)*m/M,j*m/M) of q ] } + (i/N)[ point (j*n/M) of p, point (j*m/M) of q ] + { (i/N) [ direction 0 of subpath(j*n/M,(j+1)*n/M) of p, + direction 0 of subpath(j*m/M,(j+1)*m/M) of q ] } + endfor + .. + { (i/N)[ direction n of p, direction m of q ] } + (i/N)[ point n of p, point m of q ] + ; + endfor; + endgroup; + enddef; + numeric u; + u := 2cm; + path p, q; + p := fullcircle scaled u; + q := (-u,-u)--(u,-u)--(u,u)--(-u,u)--cycle; + degrade(p,q,10); +endfig; +beginfig(147) + draw for i=0 step 10 until 360: + 2cm* (sind(2*i), cosd(3*i)) .. + endfor cycle; +endfig; +beginfig(148) + for i=0 step .1 until 360: + col := i/360; + draw 2cm* (sind(2*i), cosd(3*i)) + withpen pencircle scaled 2bp + withcolor + if col>.5: (2*(1-col)) [red, blue] + else: (1-2col) [blue, red] + fi; + endfor; +endfig; +beginfig(149) + def couleur(expr x) = + if x>.5: (2*(1-x)) [red, blue]; + else: (1-2x) [blue, red] + fi + enddef; + for i=0 step .1 until 360: + draw 2cm* (sind(2*i), cosd(3*i)) + withpen pencircle scaled 2bp + withcolor couleur(i/360); + endfor; +endfig; +beginfig(150) + for i=0 step 1 until 360: + pair P; + P = 2cm* (sind(2*i), cosd(3*i)); + fill fullcircle scaled 4mm shifted P withcolor white; + draw fullcircle scaled 4mm shifted P; + endfor; +endfig; +beginfig(151) + for i=0 step 1 until 360: + pair P; + P = 2cm* (sind(2*i), cosd(3*i)); + fill fullcircle scaled 4mm shifted P withcolor white; + draw fullcircle scaled 4mm shifted P; + endfor; + picture p; + p:=nullpicture; + for i=-180 step 1 until 180: + pair P; + P = 2cm* (sind(2*i), cosd(3*i)); + addto p contour fullcircle scaled 4mm shifted P withcolor white; + addto p doublepath fullcircle scaled 4mm shifted P + withpen pencircle scaled .5bp; + endfor; + clip p to (.5cm,2.5cm) -- (.5cm,1.5cm)-- + (-.5cm,1.5cm) -- (-.5cm,2.5cm)--cycle; + draw p; +endfig; +beginfig(152) + u:=5mm; + vardef project(expr x,y,z) = + x*(-1,-1) + y*(1,0) + z*(0,1) + enddef; + vardef f(expr x,y) = sind(x/u*180)*sind(y/u*180)*u enddef; + numeric m,M; + m:=-2u; M:=2u; + for i=m step .1u until M: + path p; + p = + for j=m step .1u until M: + project(i,j,f(i,j)) -- + endfor + project(i,M,f(i,M)); + fill (project(i,m,f(i,m)) - (0,3u)) -- p -- + (project(i,M,f(i,M)) - (0,3u)) -- cycle + withcolor white; + draw (project(i,m,f(i,m)) - (0,3u)) -- p -- + (project(i,M,f(i,M)) - (0,3u)) -- cycle; + draw p; + endfor; +endfig; +beginfig(153) + vardef project(expr x,y,z) = + x*(-1,-1) + y*(1,0) + z*(0,1) + enddef; + vardef f(expr x,y) = sind(x/u*180)*sind(y/u*180)*u enddef; + m:=-2u; M:=2u; inc:=.1u; + for i=m step inc until M: + for j=m step inc until M: + path p; + p = project(i,j,f(i,j)) -- + project(i,j+inc,f(i,j+inc)) -- + project(i+inc,j+inc,f(i+inc,j+inc)) -- + project(i+inc,j,f(i+inc,j)) -- + cycle; + fill p withcolor white; + draw p; + endfor + endfor; +endfig; +beginfig(154) + vardef project(expr x,y,z) = + x*(-1,-1) + y*(1,0) + z*(0,1) + enddef; + vardef f(expr x,y) = sind(x/u*180)*sind(y/u*180)*u enddef; + numeric m,M,inc,couleur; + m:=-2u; M:=2u; inc:=.1u; + for i=m step inc until M: + for j=m step inc until M: + path p; + p = project(i,j,f(i,j)) -- + project(i,j+inc,f(i,j+inc)) -- + project(i+inc,j+inc,f(i+inc,j+inc)) -- + project(i+inc,j,f(i+inc,j)) -- + cycle; + dfdx := (f(i,j) - f(i+inc,j))/inc; + dfdy := (f(i,j) - f(i,j+inc))/inc; + couleur := 1/sqrt( dfdx**2 + dfdy**2 + 1); + fill p withcolor couleur*(red+green); + endfor + endfor; +endfig; +beginfig(155) +vardef f(expr x,y) = sind(x/u*180)*sind(y/u*180)*u enddef; + +boolean dessine_fil_de_fer; dessine_fil_de_fer := false; +color dessine_couleur; dessine_couleur := red+green; + +vardef dessine(suffix f)(expr xmin, xmax, xinc, ymin, ymax, yinc) = + save i,j,p,dfdx,dfdy,project; + vardef project(expr x,y,z) = + x*(-1,-1) + y*(1,0) + z*(0,1) + enddef; + for i=m step inc until M: + for j=m step inc until M: + path p; + p = project(i,j,f(i,j)) -- + project(i,j+inc,f(i,j+inc)) -- + project(i+inc,j+inc,f(i+inc,j+inc)) -- + project(i+inc,j,f(i+inc,j)) -- + cycle; + dfdx := (f(i,j) - f(i+inc,j))/inc; + dfdy := (f(i,j) - f(i,j+inc))/inc; + couleur := 1/sqrt( dfdx**2 + dfdy**2 + 1); + fill p withcolor couleur*dessine_couleur; + if dessine_fil_de_fer: draw p fi; + endfor + endfor; +enddef; + + % Il faudrait pouvoir choisir différents + % types d'« éclairage ». + vardef f(expr x,y) = sind(x/u*180)*sind(y/u*180)*u enddef; + dessine(f,-2u,2u,.1u, -2u,2u,.1u); +endfig; +beginfig(156) + vardef random_path (expr n) = + save i, A ; numeric i; pair A[]; + for i=0 upto n: + A[i] = (uniformdeviate(2u), uniformdeviate(2u)); + endfor; + A[0] + for i=1 upto n: + .. A[i] + endfor + enddef; + + vardef intersections(expr p,q) = + save a,b,N,i,j; + numeric N,i,j; + N:=10; + for i=0 step length(p)/N until length(p): + for j=0 step length(q)/N until length(p): + numeric a,b; + pair A; + (a,b) = (subpath(i,i+length(p)/N) of p) + intersectiontimes + (subpath(j,j+length(q)/N) of q); + if a <> -1: + A = point a of subpath(i,i+length(p)/N) of p; + show A; + draw A withpen pencircle scaled 4bp; + fi; + endfor; + endfor; + enddef; + + path p,q; + p:=random_path(4); + q:=random_path(4); + draw p withcolor red; + draw q withcolor blue; + intersections(p,q); +endfig; +beginfig(157) + vardef auto_intersections(expr p) = + save a,b,N,i,j; + numeric N,i,j; + N:=100; + for i=0 step length(p)/N until length(p): + for j=i+2*length(p)/N + step length(p)/N + until length(p): + numeric a,b; + pair A; + (a,b) = (subpath(i,i+length(p)/N) of p) + intersectiontimes + (subpath(j,j+length(p)/N) of p); + if a <> -1: + A = point a of subpath(i,i+length(p)/N) of p; + show A; + draw A withpen pencircle scaled 4bp; + fi; + endfor; + endfor; + enddef; + + u:=2cm; + path p,q; + p:=random_path(12); + draw p; + auto_intersections(p); +endfig; +beginfig(158) + path p; + p := (0,0){up} .. (1cm,1cm) .. (1cm,0); + draw p; + draw point 1/2length(p) of p + withpen pencircle scaled 4bp withcolor red; + draw point (arctime (1/2 arclength(p)) of p) of p + withpen pencircle scaled 4bp; + +endfig; +beginfig(159) + vardef milieu(expr p) = + save l,i,tot,A,B; + numeric l,tot,i; + pair A,B; + tot := longueur(p); + l:=0; + B := point 0 of p; + for i:=0 step .01 until length(p): + A := B; + B := point i of p; + l := l+abs(B-A); + exitif l > 1/2 tot; + endfor; + 1/2[A,B] + enddef; + + path p; + p := (0,0){up} .. (1cm,1cm) .. (1cm,0); + draw p; + draw point 1/2length(p) of p withpen pencircle scaled 4bp withcolor red; + draw milieu(p) withpen pencircle scaled 4bp; +endfig; +beginfig(160) + vardef milieu_time(expr p) = + save l,i,tot,A,B,t; + numeric l,tot,i,t; + pair A,B; + tot := longueur(p); + l:=0; + B := point 0 of p; + for i:=0 step .01 until length(p): + t:=i; + A := B; + B := point i of p; + l := l+abs(B-A); + exitif l > 1/2 tot; + endfor; + t % Pas de point-virgule + enddef; + + save arrowhead; + vardef arrowhead expr p = + save A,u; pair A,u; + A := milieu(p); + u := unitvector(direction milieu_time(p) of p); + A -- (A - ahlength*u rotated 15) -- + (A - ahlength*u rotated -15) -- cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(161) + save arrowhead; + vardef arrowhead expr p = + save A,B,u; pair A,B,u; + A := milieu(p); + B := p intersectionpoint + (fullcircle scaled ahlength shifted A); + u := unitvector(direction milieu_time(p) of p); + A -- (A - ahlength*u rotated 30) -- B -- + (A - ahlength*u rotated -30) -- cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(162) + save arrowhead; + vardef arrowhead expr p = + save A,u; pair A,u; + A := milieu(p); + u := unitvector(direction milieu_time(p) of p); + A -- (A - ahlength*u rotated 30) -- A -- + (A - ahlength*u rotated -30) -- cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(163) + save arrowhead; + vardef arrowhead expr p = + save A,u,a,b; pair A,u; path a,b; + A := milieu(p); + u := unitvector(direction milieu_time(p) of p); + a := A{-u} .. (A - ahlength*u rotated 30); + b := A{-u} .. (A - ahlength*u rotated -30); + ( a & reverse(a) & b & reverse(b) ) --cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(164) + pair A,B,C; + C = 3mm*up; + A = C rotated 120; + B = C rotated -120; + picture pic ; + pic:=nullpicture; + addto pic doublepath A--B--C--cycle withpen currentpen; + addto pic doublepath A withpen pencircle scaled 4bp; + addto pic doublepath B withpen pencircle scaled 4bp; + addto pic doublepath C withpen pencircle scaled 4bp; + for i=-3 upto 3: + for j=-3 upto 3: + draw pic shifted( i*(B-A) + j*(C-A) ); + endfor; + endfor; + clip currentpicture to (-2cm,-2cm)--(2cm,-2cm)--(2cm,2cm)--(-2cm,2cm)--cycle; +endfig; +beginfig(165) + pair A,B,C; + C = 3mm*up; + A = C rotated 120; + B = C rotated -120; + picture pic ; + pic:=nullpicture; + path p; + p := A{(C-A) rotated 30} .. C{(C-A) rotated 30}; + addto pic doublepath p withpen currentpen; + addto pic doublepath p rotated 120 withpen currentpen; + addto pic doublepath p rotated -120 withpen currentpen; + for i=-3 upto 3: + for j=-3 upto 3: + draw pic shifted( i*(B-A) + j*(C-A) ); + endfor; + endfor; + clip currentpicture to (-2cm,-2cm)--(2cm,-2cm)--(2cm,2cm)--(-2cm,2cm)--cycle; +endfig; +beginfig(166) + ux:=2mm; + uy:=5mm; + numeric xmin, xmax, ymin, ymax, M; + xmin := -6.3; xmax := 12.6; + ymin := -2; ymax := 2; + M := 100; + draw (ux*xmin,0) -- (ux*xmax,0); + draw (0,uy*ymin) -- (0,uy*ymax); + pair a[]; + for i=0 upto M: + a[i] := ( + xmin + (i/M)*(xmax-xmin), + sind(180/3.14*( xmin + (i/M)*(xmax-xmin) )) + ) xscaled ux yscaled uy; + endfor; + draw a[0] for i=1 upto M: --a[i] endfor; +endfig; +beginfig(167) + ux:=5mm; + uy:=2mm; + numeric xmin, xmax, ymin, ymax, M; + xmin := -2; xmax := 2; + ymin := -.1; ymax := 8; + M := 100; + draw (ux*xmin,0) -- (ux*xmax,0); + draw (0,uy*ymin) -- (0,uy*ymax); + pair a[]; + for i=0 upto M: + a[i] := ( + xmin + (i/M)*(xmax-xmin), + mexp(256*( xmin + (i/M)*(xmax-xmin) )) + ) xscaled ux yscaled uy; + endfor; + draw a[0] for i=1 upto M: --a[i] endfor; +endfig; +beginfig(168) + ux:=5mm; + uy:=5mm; + numeric xmin, xmax, ymin, ymax, M; + xmin := .2; xmax := 3; + ymin := -1.6; ymax := 1.2; + M := 100; + draw (ux*-.1,0) -- (ux*xmax,0); + draw (0,uy*ymin) -- (0,uy*ymax); + pair a[]; + for i=0 upto M: + a[i] := ( + xmin + (i/M)*(xmax-xmin), + (1/256)*mlog(( xmin + (i/M)*(xmax-xmin) )) + ) xscaled ux yscaled uy; + endfor; + draw a[0] for i=1 upto M: --a[i] endfor; +endfig; +beginfig(169) + path p; + p = fullcircle scaled 2cm; + z0 = (-1cm,0); + draw p; + draw z0 withpen pencircle scaled 2pt; + + pair A[]; + for i=0 step length(p)/100 until length(p): + pair M,N; + M = point i of p; + N-M = whatever * direction i of p; + N-z0 = whatever * direction i of p rotated 90; + A[i] := N; + endfor; + draw for i=0 step length(p)/100 until length(p): + A[i] .. + endfor cycle; +endfig; +beginfig(170) +vardef cardiodide(expr p, O) = + save i,M,N; + numeric i; + for i=0 step length(p)/100 until length(p): + hide( + pair M,N; + M = point i of p; + N-M = whatever * direction i of p; + N-O = whatever * direction i of p rotated 90; + ) + N .. + endfor cycle +enddef; + + path p; + p = fullcircle scaled 2cm; + z0 = (-1cm,0); + draw p; + draw z0 withpen pencircle scaled 2pt; + draw cardiodide(p,z0); +endfig; +beginfig(171) +vardef cardiodide(expr p, O) = + save i,M,N; + numeric i; + for i=0 step length(p)/100 until length(p): + hide( + pair M,N; + M = point i of p; + N-M = whatever * direction i of p; + N-O = whatever * direction i of p rotated 90; + ) + N .. + endfor cycle +enddef; + + path p; + p = fullcircle scaled 2cm; + z0 = (-1cm,0); + pickup pencircle scaled 1pt + draw p; + draw z0 withpen pencircle scaled 3pt; + draw cardiodide(p,z0); + pickup pencircle scaled .4pt + pair M,N; + i:=1.5; + M = point i of p; + N-M = whatever * direction i of p; + N-z0 = whatever * direction i of p rotated 90; + draw z0--N; + draw (-1/2)[N,M]--(3/2)[N,M]; + draw N withpen pencircle scaled 3pt; + draw M withpen pencircle scaled 3pt; +endfig; +beginfig(172) + path p; + p := (-1cm,0) .. (1cm,-1cm) .. (8mm,0) + .. (1cm,1cm) .. (-1cm,1cm) .. cycle; + z0 = (-2cm,0); + draw p withpen pencircle scaled 1bp; + draw z0 withpen pencircle scaled 3pt; + draw cardiodide(p,z0); +endfig; +beginfig(173) +vardef inversion (expr O,k,M) = + if pair M: + (O + k*unitvector(M-O)/abs(M-O)) + elseif path M: + for i=0 step length(M)/100 until length(M): + inversion(O,k,point i of M) .. + endfor + cycle + fi +enddef; + + u:=4cm; + path p[],A,B; + + z0 = (5u,0) rotated 10; + + A = fullcircle scaled 2u; + B = A scaled 3; + draw inversion( z0, 2 (u**2), A ) + withpen pencircle scaled 1pt; + draw inversion( z0, 2 (u**2), B ) + withpen pencircle scaled 1pt; + + p0 = fullcircle scaled 2u shifted (2u,0); + for i=0 upto 5: + if i<>0: + p[i] = p[i-1] rotated (360/6); + fi; + draw inversion( z0, 2 (u**2), p[i] ); + endfor; +endfig; +beginfig(174) + def curve(expr p,i,q,j,t) = + point i of p {direction i of p} .. + tension t .. + point j of q {direction j of q} + enddef; + + vardef sphere_with_holes (expr n) = + save i; + c[0] = fullcircle xscaled u yscaled 2u + shifted (4u,0) rotated (360/(2n)) ; + draw c[0]; + for i=1 upto n-1: + c[i] = c[i-1] rotated (360/n); + draw c[i]; + endfor; + l[0] = curve(c[0], 2, c[1], -2, 1); + draw l[0]; + for i=1 upto n-1: + l[i] = l[i-1] rotated (360/n); + draw l[i]; + endfor; + enddef; + + u:=3mm; + path c[], l[]; + sphere_with_holes(5); +endfig; +beginfig(175) + def curve(expr p,i,q,j,t) = + point i of p {direction i of p} .. + tension t .. + point j of q {direction j of q} + enddef; + + vardef sphere_with_holes (expr n) = + save i; + c[0] = fullcircle xscaled u yscaled 2u + shifted (4u,0) rotated (360/(2n)) ; + for i=1 upto n-1: + c[i] = c[i-1] rotated (360/n); + endfor; + l[0] = curve(c[0], 2, c[1], -2, 1); + for i=1 upto n-1: + l[i] = l[i-1] rotated (360/n); + endfor; + fill for i=0 upto n-1: + ( reverse subpath(2,6) of c[i] ) & + l[i] & + endfor + % To turn it into a cycle (ugly) + point length(l[n-1]) of l[n-1] -- cycle + withcolor .8white; + for i=0 upto n-1: + draw c[i]; draw l[i]; + endfor; + enddef; + + u:=3mm; + path c[], l[]; + sphere_with_holes(5); +endfig; +beginfig(176) + path c[], l[]; + sphere_with_holes(6); + def ellipse(expr a,b,c,d,e) = + draw curve(a,b,c,d,e) ; + draw curve(c,d,a,b,e) dashed evenly; + enddef; + + ellipse (l[0], 2/3, l[2], 1/3, 4); + ellipse (l[1], 2/3, l[3], 1/3, 4); + ellipse (l[2], 2/3, l[4], 1/3, 4); + ellipse (l[3], 2/3, l[5], 1/3, 4); + ellipse (l[4], 2/3, l[0], 1/3, 4); + ellipse (l[5], 2/3, l[1], 1/3, 4); +endfig; +beginfig(177) + vardef bar(expr m,a,b,c) = + m = 1/3a + 1/3b + 1/3c + enddef; + vardef dbar(expr m,a,b,c) = + draw m--a; draw m--b; draw m--c; + draw m withpen pencircle scaled 4bp; + enddef; + + pair P[], A,B,C; + for i=0 upto 4: + P[i] = 1cm * up rotated (i*360/5); + draw P[i] withpen pencircle scaled 4bp; + endfor; + bar(A, P[0], P[4], B); + bar(B, A, P[1], C); + bar(C, B, P[2], P[3]); + draw fullcircle scaled 2cm dashed evenly; + dbar(A, P[0], P[4], B); + dbar(B, A, P[1], C); + dbar(C, B, P[2], P[3]); +endfig; +beginfig(178) +% M est sur la bissectrice de l'angle A +vardef bissectrice(expr M,A,B,C) = + (M-A) = whatever * ( + (A-C) rotated 1/2(angle(B-A) - angle(C-A))) +enddef; + +% Le cercle inscrit +vardef cercle_inscrit(expr A,B,C) = + save M, h; pair M, h; + bissectrice(M,A,B,C); + bissectrice(M,B,C,A); + M-h = whatever * (B-C) rotated 90; + h = whatever[B,C]; + fullcircle scaled 2 length(M-h) shifted M +enddef; + + pair A,B,C,M; + u:=2cm; + A=(0,0); B=(2u,-.5u); C=(u,u); + draw A--B--C--cycle; + bissectrice(M, A,B,C); + bissectrice(M, B,C,A); + draw M--A; draw M--B; draw M--C; + draw cercle_inscrit(A,B,C); +endfig; +beginfig(179) +vardef premiere_trisectrice (expr M, A,B,C) = + (M-A) = whatever * ( (A-B) rotated 1/3 (angle(C-A) - angle(B-A)) ) +enddef; + +vardef deuxieme_trisectrice (expr M, A,B,C) = + (M-A) = whatever * ( (A-B) rotated 2/3 (angle(C-A) - angle(B-A)) ) +enddef; + + pair A,B,C,M[]; + u:=2cm; + A=(0,0); B=(2u,-.5u); C=(u,u); + draw A--B--C--cycle; + + premiere_trisectrice(M1,A,B,C); + deuxieme_trisectrice(M1,B,C,A); + premiere_trisectrice(M2,B,C,A); + deuxieme_trisectrice(M2,C,A,B); + premiere_trisectrice(M3,C,A,B); + deuxieme_trisectrice(M3,A,B,C); + + draw M1--A; draw M1--B; + draw M2--B; draw M2--C; + draw M3--C; draw M3--A; + + draw M1--M2--M3--cycle; +endfig; +beginfig(180) + save arrowhead; + vardef arrowhead expr p = + save A,u; pair A,u; + A := point length(p) of p; + u := unitvector(direction length(p) of p); + A -- (A - ahlength*u rotated 15) -- + (A - ahlength*u rotated -15) -- cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(181) + save arrowhead; + vardef arrowhead expr p = + save A,B,u; pair A,B,u; + A := point length(p) of p; + B := p intersectionpoint + (fullcircle scaled ahlength shifted A); + u := unitvector(direction length(p) of p); + A -- (A - ahlength*u rotated 30) -- B -- + (A - ahlength*u rotated -30) -- cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(182) + save arrowhead; + vardef arrowhead expr p = + save A,u; pair A,u; + A := point length(p) of p; + u := unitvector(direction length(p) of p); + A -- (A - ahlength*u rotated 30) -- A -- + (A - ahlength*u rotated -30) -- cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(183) + save arrowhead; + vardef arrowhead expr p = + save A,u,a,b; pair A,u; path a,b; + A := point length(p) of p; + u := unitvector(direction length(p) of p); + a := A{-u} .. (A - ahlength*u rotated 30); + b := A{-u} .. (A - ahlength*u rotated -30); + ( a & reverse(a) & b & reverse(b) ) --cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(184) + save arrowhead; + vardef arrowhead expr p = + save A,u; pair A,u; + A := point 1/2length(p) of p; + u := unitvector(direction 1/2length(p) of p); + A -- (A - ahlength*u rotated 15) -- + (A - ahlength*u rotated -15) -- cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(185) + save arrowhead; + vardef arrowhead expr p = + save A,B,u; pair A,B,u; + A := point 1/2length(p) of p; + B := p intersectionpoint + (fullcircle scaled ahlength shifted A); + u := unitvector(direction 1/2length(p) of p); + A -- (A - ahlength*u rotated 30) -- B -- + (A - ahlength*u rotated -30) -- cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(186) + save arrowhead; + vardef arrowhead expr p = + save A,u; pair A,u; + A := point 1/2length(p) of p; + u := unitvector(direction 1/2length(p) of p); + A -- (A - ahlength*u rotated 30) -- A -- + (A - ahlength*u rotated -30) -- cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(187) + save arrowhead; + vardef arrowhead expr p = + save A,u,a,b; pair A,u; path a,b; + A := point 1/2length(p) of p; + u := unitvector(direction 1/2length(p) of p); + a := A{-u} .. (A - ahlength*u rotated 30); + b := A{-u} .. (A - ahlength*u rotated -30); + ( a & reverse(a) & b & reverse(b) ) --cycle + enddef; + + u:=1cm; + drawarrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(188) + def drawwhitearrow expr p = _apth:=p; _finwhitearr enddef; + + def _finwhitearr text t = + draw _apth t; + fill arrowhead _apth t withcolor white; + draw arrowhead _apth t + enddef; + + u:=1cm; + drawwhitearrow (0,0) .. (-u,u) .. (u,u); +endfig; +beginfig(189) + def draw_white_arrow expr p = _apth:=p; _fin_white_arr enddef; + def _fin_white_arr text t = + draw _apth t; + fill arrowhead _apth withcolor white; + draw arrowhead _apth t + enddef; + + def draw_middle_arrow expr p = _apth:=p; _fin_middle_arr enddef; + def _fin_middle_arr text t = + draw _apth t; + filldraw arrowhead_middle _apth t + enddef; + vardef arrowhead_middle expr p = + save A,u; pair A,u; + A := point (arctime (.5arclength p) of p) of p; + u := unitvector(direction (arctime (.5arclength p) of p) of p); + A -- (A - ahlength*u rotated (.5ahangle) ) -- + (A - ahlength*u rotated (-.5ahangle) ) -- cycle + enddef; + + def draw_middle_white_arrow expr p = _apth:=p; _fin_middle_white_arr enddef; + let draw_white_middle_arrow = draw_middle_white_arrow; + def _fin_middle_white_arr text t = + draw _apth t; + fill arrowhead_middle _apth t withcolor white; + draw arrowhead_middle _apth t + enddef; + + def draw_other_arrow expr p = _apth:=p; _fin_other_arr enddef; + def _fin_other_arr text t = + draw _apth t; + draw arrowhead_other _apth t + enddef; + vardef arrowhead_other expr p = + save A,u,a,b; pair A,u; path a,b; + A := point (length p) of p; + u := unitvector(direction (length p) of p); + a := A{-u} .. (A - ahlength*u rotated 30); + b := A{-u} .. (A - ahlength*u rotated -30); + ( a & reverse(a) & b & reverse(b) ) --cycle + enddef; + + def draw_other_middle_arrow expr p = _apth:=p; _fin_other_middle_arr enddef; + let draw_middle_other_arrow = draw_other_middle_arrow; + def _fin_other_middle_arr text t = + draw _apth t; + draw arrowhead_other_middle _apth t + enddef; + vardef arrowhead_other_middle expr p = + save A,u,a,b; pair A,u; path a,b; + A := point (arctime (.5arclength p) of p) of p; + u := unitvector(direction (arctime (.5arclength p) of p) of p); + a := A{-u} .. (A - ahlength*u rotated 30); + b := A{-u} .. (A - ahlength*u rotated -30); + ( a & reverse(a) & b & reverse(b) ) --cycle + enddef; + + path p; + p := halfcircle scaled 2cm; + p := (0,0) .. (3cm,1cm) .. (-1cm,3cm); + p := p scaled .3; + draw_middle_arrow p; + draw_white_arrow p scaled 1.3 withpen pencircle scaled 1bp; + draw_white_middle_arrow p scaled 1.6; + draw_other_middle_arrow p scaled 1.8 withpen pencircle scaled 1bp; + draw_other_arrow p scaled 2 withpen pencircle scaled 1bp; +endfig; +beginfig(190) + vardef mylabel(expr pic, p, t) = + save A; pair A; + A = point t of p + + 8bp * unitvector(direction t of p) rotated 90; + label(pic, A); + enddef; + path p; u:=1cm; + p = (0,0)..(-u,u)..(u,u); + draw p; + for i=0 step .2 until length(p): + draw point i of p withpen pencircle scaled 4bp; + mylabel(btex $A$ etex,p,i); + endfor; +endfig; +beginfig(191) + vardef mylabel(expr pic, p, t) = + save A; pair A; + A = point t of p + + 8bp * unitvector(direction t of p) rotated 90; + label(pic, A); + enddef; + path p; u:=1cm; + p = (0,0)..(-u,u)..(u,u); + draw p; + for i=0 step .2 until length(p): + draw point i of p withpen pencircle scaled 4bp; + mylabel(TEX decimal(i),p,i); + endfor; +endfig; +beginfig(192) + vardef mylabel(expr pic, p, t) = + save A,a; pair A; numeric a; + a := angle(direction t of p rotated 90); + show(a); + a := a + 45/2; + if a>180: a := a - 360 fi; + save ll, lr, ul, ur; + pair ul,ur,ll,lr; + ll := llcorner pic; + lr := lrcorner pic; + ul := ulcorner pic; + ur := urcorner pic; + A = point t of p + + 8bp * unitvector(direction t of p) rotated 90; + label(pic shifted ll, A + + if (a >= 0) and (a <= 45): 1/2(ur-ul) + elseif (a >= 45) and (a <= 90): 1/2(ur-ul) + 1/2(ur-lr) + elseif (a >= 90) and (a <= 135): 1/2(ur-lr) + elseif (a >= 135) and (a <= 180): 1/2(ll-lr) + 1/2(ur-lr) + elseif (a >= -180) and (a <= -135): 1/2(ll-lr) + elseif (a >= -135) and (a <= -90): 1/2(ll-ul) + 1/2(ll-lr) + elseif (a >= -90) and (a <= -45): 1/2(ll-ul) + elseif (a >= -45) and (a <= 0): 1/2(ll-ul) - 1/2(ll-lr) + else: hide(show "BUG") (0,0) + fi); + draw A withpen pencircle scaled 2bp withcolor red; + enddef; + path p; u:=1cm; + p = (0,0)..(-u,u)..(u,u); + p := reverse fullcircle scaled 2u; + draw p; + for i=0 step length(p)/10 until length(p): + draw point i of p withpen pencircle scaled 4bp; + mylabel(TEX decimal(i),p,i); + endfor; +endfig; +beginfig(193) + n:=8; + u:=5mm; + for i=0 upto n-1: + for j=0 upto n-1: + if odd(i+j): + fill (0,0)--(u,0)--(u,u)--(0,u)--cycle + shifted (i*u,j*u) withcolor .8white; + fi; + endfor; + endfor; + for i=0 upto n: + draw (0,i*u)--(n*u,i*u); + draw (i*u,0)--(i*u,n*u); + endfor; +endfig; +beginfig(194) + n:=8; + u:=5mm; + for i=0 upto n-1: + for j=0 upto n-1: + if odd(i+j): + for k=0 step u/5 until u: + draw ( (k,0)--(u,u-k) ) + shifted (i*u,j*u); + draw ( (0,k)--(u-k,u) ) + shifted (i*u,j*u); + endfor; + fi; + endfor; + endfor; + for i=0 upto n: + draw (0,i*u)--(n*u,i*u); + draw (i*u,0)--(i*u,n*u); + endfor; +endfig; +beginfig(195) + n:=8; + u:=5mm; + for i=0 upto n-1: + for j=0 upto n-1: + if odd(i+j): + for k=0 step u/5 until 4/5 u: + if odd(k*5/u): + fill ( (k,0)--(u,u-k)--(u,u-k-u/5)-- + (k+u/5,0)--cycle ) + shifted (i*u,j*u) withcolor .8white; + else: + fill ( (0,k)--(u-k,u)--(u-k-u/5,u)-- + (0,k+u/5)--cycle ) + shifted (i*u,j*u) withcolor .8white; + fi; + endfor; + fi; + endfor; + endfor; + for i=0 upto n: + draw (0,i*u)--(n*u,i*u); + draw (i*u,0)--(i*u,n*u); + endfor; +endfig; +beginfig(196) + vardef trace (suffix f)(expr a,b,inc) = + save i; numeric i; + for i=a step inc until b: + (i*1cm, f(i)*1cm) .. + endfor (b*1cm, f(b)*1cm) + enddef; + + vardef axes = + save p; picture p; + p:=nullpicture; + addto p doublepath (-infinity,0)--(infinity,0) withpen currentpen; + addto p doublepath (0,-infinity)--(0,infinity) withpen currentpen; + clip p to bbox currentpicture; + draw p; + enddef; + + vardef trace_rectangles_left (suffix f)(expr a,b,inc) = + save i; numeric i; + for i=a step inc until b-inc: + path p; + p = (i,0)--(i+inc,0)--(i+inc,f(i))--(i,f(i))--cycle; + p := p scaled 1cm; + fill p withcolor .8*white; + draw p; + endfor; + enddef; + + vardef f(expr x) = 2 ** x enddef; + + trace_rectangles_left(f,-2,2,.5); + draw trace(f, -2,2,.1); + axes; +endfig; +beginfig(197) + vardef trace_trapezes (suffix f)(expr a,b,inc) = + save i; numeric i; + for i=a step inc until b-inc: + path p; + p = (i,0)--(i+inc,0)--(i+inc,f(i+inc))--(i,f(i))--cycle; + p := p scaled 1cm; + fill p withcolor .8*white; + draw p; + endfor; + enddef; + + vardef f(expr x) = 4 - x**2 enddef; + + trace_trapezes(f,-2,2,.5); + draw trace(f, -2,2,.1); + axes; +endfig; +beginfig(198) + vardef trace_rectangles_right (suffix f)(expr a,b,inc) = + save i; numeric i; + for i=a step inc until b-inc: + path p; + p = (i,0)--(i+inc,0)--(i+inc,f(i+inc))--(i,f(i+inc))--cycle; + p := p scaled 1cm; + fill p withcolor .8*white; + draw p; + endfor; + enddef; + + trace_rectangles_right(f,-2,2,.5); + draw trace(f, -2,2,.1); + axes; +endfig; +beginfig(199) + vardef maxf(suffix f)(expr a,b) = + save m,i; numeric m,i; + m:=f(a); + for i=a step (b-a)/100 until b: + if m<f(i): m:=f(i); fi; + endfor; + m + enddef; + + vardef trace_rectangles_max (suffix f)(expr a,b,inc) = + save i; numeric i; + for i=a step inc until b-inc: + path p; numeric m; + m:=maxf(f,i,i+inc); + p = (i,0)--(i+inc,0)--(i+inc,m)--(i,m)--cycle; + p := p scaled 1cm; + fill p withcolor .8*white; + draw p; + endfor; + enddef; + + vardef f(expr x) = 4 - x**2 enddef; + + trace_rectangles_max(f,-2,2,.5); + draw trace(f, -2,2,.1); + axes; +endfig; +beginfig(200) + vardef minf(suffix f)(expr a,b) = + save m,i; numeric m,i; + m:=f(a); + for i=a step (b-a)/100 until b: + if m>f(i): m:=f(i); fi; + endfor; + m + enddef; + + vardef trace_rectangles_min (suffix f)(expr a,b,inc) = + save i; numeric i; + for i=a step inc until b-inc: + path p; numeric m; + m:=minf(f,i,i+inc); + p = (i,0)--(i+inc,0)--(i+inc,m)--(i,m)--cycle; + p := p scaled 1cm; + fill p withcolor .8*white; + draw p; + endfor; + enddef; + + vardef f(expr x) = 4 - x**2 enddef; + + trace_rectangles_min(f,-2,2,.5); + draw trace(f, -2,2,.1); + axes; +endfig; +beginfig(201) + u:=2cm; + vardef koch(expr A,B,n) = + save C; pair C; + C = A rotatedaround(1/3[A,B], 120); + if n>0: + koch( A, 1/3[A,B], n-1); + koch( 1/3[A,B], C, n-1); + koch( C, 2/3[A,B], n-1); + koch( 2/3[A,B], B, n-1); + else: + draw A--1/3[A,B]--C--2/3[A,B]--B; + fi; + enddef; + z0=(u,0); + z1=z0 rotated 120; + z2=z1 rotated 120; + koch( z0, z1, 4 ); + koch( z1, z2, 4 ); + koch( z2, z0, 4 ); +endfig; +beginfig(202) + u:=2cm; + vardef koch(expr A,B,n) = + save C; pair C; + C = A rotatedaround(1/3[A,B], -120); + if n>0: + koch( A, 1/3[A,B], n-1); + koch( 1/3[A,B], C, n-1); + koch( C, 2/3[A,B], n-1); + koch( 2/3[A,B], B, n-1); + else: + draw A--1/3[A,B]--C--2/3[A,B]--B; + fi; + enddef; + z0=(u,0); + z1=z0 rotated 120; + z2=z1 rotated 120; + koch( z0, z1, 4 ); + koch( z1, z2, 4 ); + koch( z2, z0, 4 ); +endfig; +beginfig(203) + pair A,B,C,D; + u := 3cm; + A := (0,0); + B := (u,0); + D := B rotated 72; + C := (u,0) + D; + draw A--B--C--D--cycle; + draw A--C; + draw btex $B'$ etex shifted 1/3 (A+B+C); + draw btex $B$ etex shifted 1/3 (A+D+C); + +endfig; +beginfig(204) + pair A,B,C,D,E,F; + numeric d[]; + u := 3cm; + A := (0,0); + B := (u,0); + D := B rotated 72; + C := (u,0) + D; + d[0] := 1; + d[1] := sqrt( 2*(1+cosd(72)) ); + d[2] := sqrt( 2*(1-cosd(36)) ); + A := A; + B := C; + C := D; + draw A--B--C--cycle; + E := (d1/(d0+d1)) [A,C]; + F := (d0/(d0+d2)) [A,B]; + draw E--C--F--cycle; + draw btex $A$ etex shifted 1/3(E+C+F); + draw B--C--F--cycle; + draw btex $B$ etex shifted 1/3(B+C+E); + draw E--F--A--cycle; + draw btex $B'$ etex shifted 1/3(E+F+A); +endfig; +beginfig(205) + pair A,B,C,D,E,F; + numeric d[]; + u := 3cm; + A := (0,0); + B := (u,0); + D := B rotated 72; + C := (u,0) + D; + draw A--B--C--cycle; + d[0] := 1; + d[1] := sqrt( 2*(1+cosd(72)) ); + d[2] := sqrt( 2*(1-cosd(36)) ); + E := (d1/(d0+d1)) [A,C]; + F := (d0/(d0+d2)) [A,B]; + draw E--F--B--cycle; + draw btex $A'$ etex shifted 1/3(E+F+B); + draw E--A--F--cycle; + draw btex $B$ etex shifted 1/3(E+A+F); + draw C--E--B--cycle; + draw btex $B'$ etex shifted 1/3(C+E+B); +endfig; +beginfig(206) + pair A,B,C,D,E,F; + numeric d[]; + u := 3cm; + A := (0,0); + B := (u,0); + D := B rotated 72; + C := (u,0) + D; + d[0] := 1; + d[1] := sqrt( 2*(1+cosd(72)) ); + d[2] := sqrt( 2*(1-cosd(36)) ); + A := A; + B := C; + C := D; + E := (d1/(d0+d1)) [A,C]; + F := (d0/(d0+d2)) [A,B]; + B := 3*(C-E); + C := 3*(F-E); + + draw A--B--C--cycle; + + D := (d0/(d0+d2)) [C,A]; + draw B--C--D--cycle; + draw btex $A$ etex shifted 1/3(B+C+D); + draw B--D--A--cycle; + draw btex $B'$ etex shifted 1/3(B+D+A); +endfig; +beginfig(207) + pair A,B,C,D,E,F; + numeric d[]; + u := 3cm; + A := (0,0); + B := (u,0); + D := B rotated 72; + C := (u,0) + D; + d[0] := 1; + d[1] := sqrt( 2*(1+cosd(72)) ); + d[2] := sqrt( 2*(1-cosd(36)) ); + + % B' + E := (d1/(d0+d1)) [A,C]; + F := (d0/(d0+d2)) [A,B]; + + % A' + A := 2*(E-E); + C := 2*(B-E); + B := 2*(F-E); + + draw A--B--C--cycle; + D := (d0/(d0+d2)) [A,B]; + draw C--D--B--cycle; + draw btex $A'$ etex shifted 1/3(C+D+B); + draw C--A--D--cycle; + draw btex $B$ etex shifted 1/3(C+A+D); +endfig; +beginfig(208) + vardef pave(expr t, A, B, C, n) = + save D, E, d; + pair D,E; + numeric d[]; + d[0] := 1; + d[1] := sqrt( 2*(1+cosd(72)) ); + d[2] := sqrt( 2*(1-cosd(36)) ); + if n>0: + if t=1: + D := (d0/(d0+d2)) [A,C]; + pave(1,B,C,D,n-1); + pave(4,B,D,A,n-1); + elseif t=2: + D := (d0/(d0+d2)) [A,B]; + pave(2,C,D,B,n-1); + pave(3,C,A,D,n-1); + elseif t=3: + D := (d1/(d0+d1)) [A,B]; + E := (d0/(d0+d2)) [A,C]; + pave(1,D,C,E,n-1); + pave(3,B,C,D,n-1); + pave(4,D,E,A,n-1); + elseif t=4: + D := (d1/(d0+d1)) [A,C]; + E := (d0/(d0+d2)) [A,B]; + pave(2,D,E,B,n-1); + pave(3,D,A,E,n-1); + pave(4,C,D,B,n-1); + fi; + else: + draw A--B--C--cycle; + if t=1: + fill A--B--C--cycle withcolor green + blue; + draw A--C withpen pencircle scaled 1bp; + draw A--B withpen pencircle scaled 1bp; + elseif t=2: + fill A--B--C--cycle withcolor green + blue; + draw A--B withpen pencircle scaled 1bp; + draw A--B withpen pencircle scaled 1bp; + elseif t=3: + fill A--B--C--cycle withcolor green + red; + draw A--C withpen pencircle scaled 1bp; + draw C--B withpen pencircle scaled 1bp; + elseif t=4: + fill A--B--C--cycle withcolor green + red; + draw B--C withpen pencircle scaled 1bp; + draw A--B withpen pencircle scaled 1bp; + fi; + fi; + enddef; + numeric M; + M := 6; + pair A,B,C,D; + u := 3cm; + A := (0,0); + B := (u,0); + D := B rotated 72; + C := (u,0) + D; + pave(3,A,C,D,M); + pave(4,A,B,C,M); +endfig; +beginfig(209) +u:=1cm; + +def milieu (expr s, ss, n) = + if n<>0: + for i="A","BA","BBA": + milieu(s&i, ss, n-1); + endfor; + else: + dessine(s&ss); + fi; +enddef; + +def doit(expr N) = + for n=1 upto N: + for i="A","BA","BBA": + for j="","B","BB": + milieu(i,j,n-1); + endfor; + endfor; + endfor; + milieu("","",0); +enddef; + +vardef A(expr a) = + save x,y,n; + numeric x,y,n; + x := xpart a; + y := ypart a; + n:=x*x+y*y; + (-x/n, y/n) +enddef; + +vardef B(expr a) = + save x,y,n; + numeric x,y,n; + x := 1 + xpart a; + y := ypart a; + n := x*x+y*y; + (-x/n, y/n) +enddef; + +def dessine(expr s) = + _dessine(s, dir(60), up, dir(120)); + _dessine(s, dir(60), dir(31), dir(2)); + _dessine(s, dir(120), dir(149), dir(178)); +enddef; + +def _dessine(expr s, a,b,c) = + pair p[]; + p[0] := a; + p[1] := b; + p[2] := c; + + for i=0 upto length(s)-1: + if (substring(i,i+1) of s) = "A": + for j=0 upto 2: p[j] := A( p[j] ); endfor; + elseif (substring(i,i+1) of s) = "B": + for j=0 upto 2: p[j] := B( p[j] ); endfor; + else: show("Ceci n'est pas un générateur : "&substring(i,i+1) of s) + fi; + endfor; + if (xpart p[0] < 2) and (xpart p[0] > -2) and + (xpart p[2] > -2) and (xpart p[2] < 2) and + (ypart p[0] < 2) and (ypart p[2] < 2): + draw ( p[0] .. p[1] .. p[2] ) scaled u; + fi; + +enddef; + + fill (dir(60) .. up .. dir(120) -- + (dir120+up) -- (dir60+up) -- cycle) scaled u + withcolor red+green; + doit(7); + draw (u*dir(60)) withpen pencircle scaled 4bp; + draw (0,u) withpen pencircle scaled 4bp; + draw (u*dir(60) -- u*dir(60)+u*up) shifted (0u,0); + draw (u*dir(60) -- u*dir(60)+u*up) shifted (1u,0); + draw (u*dir(60) -- u*dir(60)+u*up) shifted (-u,0); + draw (u*dir(60) -- u*dir(60)+u*up) shifted (-2u,0); +endfig; +beginfig(210) + u:=5mm; + pickup pencircle scaled 1pt; + for i=0 upto 500: + draw (u*normaldeviate, u*normaldeviate); + endfor; +endfig; +beginfig(211) + u:=2cm; + pickup pencircle scaled 1pt; + for i=0 upto 500: + draw (u*uniformdeviate(1), u*uniformdeviate(1)); + endfor; +endfig; +beginfig(212) + numeric n; + n:=10; + path p; + p := for i=0 upto n-1: + ((1cm + 3mm*normaldeviate,0) rotated (i*360/n)) .. + endfor cycle; + fill p withcolor .8white; + draw p; +endfig; +beginfig(213) + m:=500; + u:=1cm; + pair A,B; + A:=(0,0); + for i=0 upto m: + B:=(i/m*3u, (ypart A)+normaldeviate/m*30u); + draw A--B; + A:=B; + endfor; + draw (0,0)--(3u,0); +endfig; +beginfig(214) + m:=50; + pair A[], B[]; + A[0]=(0,0); + for i=0 upto m: + A[i+1]=(i/m*3u, (ypart A[i])+(uniformdeviate(2)-1)/m*30u); + endfor; + B[0]=A[0]; + B[1]=A[1]; + B[2]=A[2]; + B[3]=A[3]; + for i=4 upto m+1: + B[i] = ( A[i-4] + A[i-3] + A[i-2] + A[i-1] + A[i])/5; + endfor; + for i=0 upto m: + draw B[i]--B[i+1] withpen pencircle scaled 2pt + withcolor .5*white; + endfor; + for i=0 upto m: + draw A[i]--A[i+1]; + endfor; + draw (0,0)--(3u,0); +endfig; +def rescale_currentpic := + if xpart (lrcorner currentpicture - llcorner currentpicture) > 4cm: + currentpicture := currentpicture scaled ( 4cm / + xpart (lrcorner currentpicture - llcorner currentpicture) ); + fi; +enddef; +beginfig(215) +vardef check_pascal = + save again; + boolean again; + again := false; + % Distance entre deux points sur le cercle : au moins 1mm + for i=0 upto 5: + for j=i+1 upto 5: + show( decimal(i) &" "& decimal(j) &" "& decimal(abs(A[i]-A[j])/2mm) ); + if abs(A[i]-A[j]) < 2mm: + again := true; + fi; + endfor; + endfor; + % Distance entre deux des M[i] : au moins 2mm, au plus 10cm + for i=0 upto 2: + for j=i+1 upto 2: + if (abs(M[i]-M[j]) > 10cm) or (abs(M[i]-M[j]) < 2mm): + again := true; + fi; + endfor; + endfor; + % Distance entre un A[i] et un M[i] : au moins 2mm + for i=0 upto 5: + for j=0 upto 2: + if abs(A[i]-M[j]) < 2mm: + again := true; + fi; + endfor; + endfor; + % Distance entre le cercle et l'un des M[i] : au plus 10cm + if abs(M[0])>10cm: + again:=true; + fi; + show again; + not again +enddef; + + forever: + path C; + C := fullcircle scaled 6cm; + pair A[], M[]; + for i=0 upto 5: + A[i] := point uniformdeviate(length(C)) of C; + endfor; + M[0] = whatever[ A[0], A[1] ]; + M[0] = whatever[ A[3], A[4] ]; + M[1] = whatever[ A[1], A[2] ]; + M[1] = whatever[ A[4], A[5] ]; + M[2] = whatever[ A[2], A[3] ]; + M[2] = whatever[ A[5], A[0] ]; + exitif check_pascal; + endfor; + + draw C; + draw A[0]--A[1] withcolor red; + draw A[3]--A[4] withcolor red; + draw A[0]--M[0] withcolor red dashed evenly; + draw A[3]--M[0] withcolor red dashed evenly; + + draw A[1]--A[2] withcolor green; + draw A[4]--A[5] withcolor green; + draw A[1]--M[1] withcolor green dashed evenly; + draw A[4]--M[1] withcolor green dashed evenly; + + draw A[2]--A[3] withcolor blue; + draw A[5]--A[0] withcolor blue; + draw A[2]--M[2] withcolor blue dashed evenly; + draw A[5]--M[2] withcolor blue dashed evenly; + + draw M[0]--M[1]--M[2]--cycle withpen pencircle scaled 2bp; + for i=0 upto 2: + draw M[i] withpen pencircle scaled 6bp; + endfor; + for i=0 upto 5: + draw A[i] withpen pencircle scaled 6bp; + endfor; + rescale_currentpic; +endfig; +beginfig(216) +vardef pascal(expr C) = + forever: + pair A[], M[]; + for i=0 upto 5: + A[i] := point uniformdeviate(length(C)) of C; + endfor; + M[0] = whatever[ A[0], A[1] ]; + M[0] = whatever[ A[3], A[4] ]; + M[1] = whatever[ A[1], A[2] ]; + M[1] = whatever[ A[4], A[5] ]; + M[2] = whatever[ A[2], A[3] ]; + M[2] = whatever[ A[5], A[0] ]; + exitif check_pascal; + endfor; + + draw C; + draw A[0]--A[1] withcolor red; + draw A[3]--A[4] withcolor red; + draw A[0]--M[0] withcolor red dashed evenly; + draw A[3]--M[0] withcolor red dashed evenly; + + draw A[1]--A[2] withcolor green; + draw A[4]--A[5] withcolor green; + draw A[1]--M[1] withcolor green dashed evenly; + draw A[4]--M[1] withcolor green dashed evenly; + + draw A[2]--A[3] withcolor blue; + draw A[5]--A[0] withcolor blue; + draw A[2]--M[2] withcolor blue dashed evenly; + draw A[5]--M[2] withcolor blue dashed evenly; + + draw M[0]--M[1]--M[2]--cycle withpen pencircle scaled 2bp; + for i=0 upto 2: + draw M[i] withpen pencircle scaled 6bp; + endfor; + for i=0 upto 5: + draw A[i] withpen pencircle scaled 6bp; + endfor; +enddef; + + pascal(fullcircle xscaled 6cm yscaled 3cm); + rescale_currentpic; +endfig; +beginfig(217) + pascal((for i=-2cm step .1cm until 2cm: + (i, (i/1cm)**2 *1cm) .. + endfor (2.1cm,4.41cm)) rotated 30); + rescale_currentpic; +endfig; +beginfig(218) +vardef pascal(expr C) = + forever: + pair A[], M[]; + + numeric t[]; + for i=0 upto 5: + t[i] = uniformdeviate(length(C)); + endfor; + for i=0 upto 5: + for j=0 upto 4: + if t[j]>t[j+1]: + tt:=t[j]; t[j]:=t[j+1]; t[j+1]:=tt; + fi; + endfor; + endfor; + for i=0 upto 5: + A[i] = point t[i] of C; + endfor; + + M[0] = whatever[ A[0], A[1] ]; + M[0] = whatever[ A[3], A[4] ]; + M[1] = whatever[ A[1], A[2] ]; + M[1] = whatever[ A[4], A[5] ]; + M[2] = whatever[ A[2], A[3] ]; + M[2] = whatever[ A[5], A[0] ]; + exitif check_pascal; + endfor; + + draw C; + draw A[0]--A[1] withcolor red; + draw A[3]--A[4] withcolor red; + draw A[0]--M[0] withcolor red dashed evenly; + draw A[3]--M[0] withcolor red dashed evenly; + + draw A[1]--A[2] withcolor green; + draw A[4]--A[5] withcolor green; + draw A[1]--M[1] withcolor green dashed evenly; + draw A[4]--M[1] withcolor green dashed evenly; + + draw A[2]--A[3] withcolor blue; + draw A[5]--A[0] withcolor blue; + draw A[2]--M[2] withcolor blue dashed evenly; + draw A[5]--M[2] withcolor blue dashed evenly; + + draw M[0]--M[1]--M[2]--cycle withpen pencircle scaled 2bp; + for i=0 upto 2: + draw M[i] withpen pencircle scaled 6bp; + endfor; + for i=0 upto 5: + draw A[i] withpen pencircle scaled 6bp; + endfor; +enddef; + + pascal(fullcircle scaled 6cm); + rescale_currentpic; +endfig; +beginfig(219) + pascal(fullcircle xscaled 6cm yscaled 3cm); + rescale_currentpic; +endfig; +beginfig(220) + pascal(fullcircle xscaled 6cm yscaled 3cm); + rescale_currentpic; +endfig; +beginfig(221) + vardef barycentre(text t) = + save n, G; + pair G; numeric n; + G := origin; n:=0; + for a=t: + G:=G+a; + n:=n+1; + endfor; + G/n + enddef; + + pair A[]; + n:=10; + for i=0 upto n: + A[i] = 1cm*(normaldeviate, normaldeviate); + draw A[i] withpen pencircle scaled 4bp; + endfor; + draw barycentre(A[0] for i=1 upto 10: ,A[i] endfor) + withpen pencircle scaled 4bp withcolor red; +endfig; +beginfig(222) + vardef barycentre(text t) = + save a, i, n, G, X; + pair G,X; numeric n,i; + G := origin; n:=0; i:=0; + for a=t: + show("i = "& decimal(i)); + show a; + if odd(i): + show("odd"); + n:=n+a; + G:= G + a*X; + else: + show("even"); + X:=a; + fi; + i:=i+1; + endfor; + G/n + enddef; + + pair A[]; + n:=10; + for i=0 upto n: + A[i] = 1cm*(normaldeviate, normaldeviate); + draw A[i] withpen pencircle scaled 4bp; + endfor; + draw barycentre(A[0],0 for i=1 upto 10: ,A[i],i endfor) + withpen pencircle scaled 4bp withcolor red; +endfig; +beginfig(223) + numeric n; + n:=10; + path p; + p := for i=0 upto n-1: + ((1cm + 3mm*normaldeviate,0) rotated (i*360/n)) .. + endfor cycle; + for i=0 step 2mm until 3cm: + draw fullcircle scaled i; + endfor; + clip currentpicture to p; + draw p; + +endfig; +beginfig(224) + u := 5mm; + draw (-2u,0) -- (2u,0); + draw (0,-u) -- (0,4u); + draw (-2u,4u) for i=-1.9 step .1 until 2.01: .. (i*u, i*i*u) endfor + withpen pencircle scaled 1bp; + draw bbox currentpicture withpen pensquare scaled 2bp withcolor .8white; + draw bbox currentpicture withpen pensquare scaled 2bp withcolor .8white; +endfig; +beginfig(225) + path p; + p := (0,0) -- (2cm,0); + def doit (suffix p)(expr t) = + begingroup + interim linecap := t; + draw p withpen pencircle scaled 5mm withcolor .8white; + endgroup; + draw point 0 of p withpen pencircle scaled 4bp; + draw point 1 of p withpen pencircle scaled 4bp; + p := p shifted (0,-7mm) + enddef; + doit(p,rounded); + doit(p,butt); + doit(p,squared); + +endfig; +beginfig(226) + path p; + p := (0,0) -- (1cm,5mm) -- (2cm,0); + def doit (suffix p)(expr t) = + begingroup + interim linejoin := t; + draw p withpen pencircle scaled 5mm withcolor .8white; + endgroup; + draw point 0 of p withpen pencircle scaled 4bp; + draw point 1 of p withpen pencircle scaled 4bp; + draw point 2 of p withpen pencircle scaled 4bp; + p := p shifted (0,-7mm) + enddef; + doit(p,rounded); + doit(p,mitered); + doit(p,beveled); + +endfig; +beginfig(227) + path p; + p := (0,0) -- (2cm,0); + vardef doit (suffix p)(expr t) = + interim linecap := t; + draw p withpen pencircle scaled 5mm withcolor .8white; + draw point 0 of p withpen pencircle scaled 4bp; + draw point 1 of p withpen pencircle scaled 4bp; + draw point 2 of p withpen pencircle scaled 4bp; + p := p shifted (0,-7mm) + enddef; + doit(p,rounded); + doit(p,butt); + doit(p,squared); + +endfig; +beginfig(228) + draw fullcircle scaled 2cm; + special("0 0 moveto 10 10 rlineto -10 10 rlineto stroke"); + +endfig; +beginfig(229) + draw fullcircle shifted (.5,.5) xscaled 18.2cm yscaled 4cm; + special( + "/Times-Roman findfont 150 scalefont setfont " & + "0 0 moveto (ABCabc) false charpath clip stroke " & + "gsave 300 0 translate " & + " 2 4 600 {dup 0 moveto 0 exch 0 exch 0 360 arc stroke} for " & + "grestore " + ); + +endfig; +beginfig(230) + draw fullcircle shifted (.5,.5) xscaled 18.2cm yscaled 4cm; + special( + "gsave " & + "/Times-Roman findfont 150 scalefont setfont " & + "0 0 moveto (ABCabc) false charpath clip stroke " & + "gsave 300 0 translate " & + " 2 4 600 {dup 0 moveto 0 exch 0 exch 0 360 arc stroke} for " & + "grestore " & + "grestore " + ); + +endfig; +beginfig(231) + path p; + p = + (0,u) + for i=.1 step .1 until 10: + hide( pair A; A = (i*u, (sind (i*180/3.14))/i *u); + draw A withpen pencircle scaled 2pt ) + .. A + endfor; + draw p; +endfig; +beginfig(232) +vardef inversion (expr O,k,M) = + if pair M: + (O + k*unitvector(M-O)/abs(M-O)) + elseif path M: + for i=0 step length(M)/10 until length(M): + hide( + draw O--inversion(O,k,point i of M)--(point i of M); + draw inversion(O,k,point i of M) withpen pencircle scaled 2pt; + draw point i of M withpen pencircle scaled 2pt withcolor red; + draw O withpen pencircle scaled 2pt; + ) + inversion(O,k,point i of M) .. + endfor + cycle + fi +enddef; + + path p[]; + p1=fullcircle scaled 2u shifted (u,0); + p2=fullcircle scaled 2u shifted (-u,0); + draw p1 dashed withdots scaled .25; + draw p2 dashed withdots scaled .25; + z0 = (.5u,2u); + draw inversion( z0, 2 (u**2), p1 ); + draw inversion( z0, 2 (u**2), p2 ); +endfig; +beginfig(233) + path p; + p := (0,0) -- (1cm,0); + show ahangle; + begingroup + interim ahangle := 30; + interim linejoin := mitered; + interim linecap := butt; + drawarrow p withpen pencircle scaled 2bp; + endgroup; + begingroup + interim ahangle := 60; + drawarrow p shifted (0,-5mm) withpen pencircle scaled 2bp; + endgroup; + +endfig; +beginfig(234) + numeric x; + x = sind(60); + draw TEX("$\sin 60 = " & decimal(x) & "$"); + +endfig; +beginfig(235) +picture _TEX_pic; + +def largeur(expr p) = + if picture p: + xpart( lrcorner(p) - llcorner(p) ) + elseif string p: + hide(_TEX_pic := TEX(p);) + xpart( lrcorner(_TEX_pic) - llcorner(_TEX_pic) ) + else: + hide( errmessage("largeur: wrong type"); 0) + fi +enddef; + +def hauteur(expr p) = + if picture p: + ypart(ulcorner(p)) + elseif string p: + hide(_TEX_pic := TEX(p);) + ypart(ulcorner(_TEX_pic)) + else: + hide( errmessage("hauteur: wrong type"); 0) + fi +enddef; + +def profondeur (expr p) = + if picture p: + -ypart(llcorner(p)) + elseif string p: + hide(_TEX_pic := TEX(p);) + -ypart(llcorner(_TEX_pic)) + else: + hide( errmessage("profondeur: wrong type"); 0) + fi +enddef; + + picture p; + string s; + s := "\huge\LaTeX"; + p := TEX(s); + drawarrow (0,0) -- (largeur(s),0) withcolor red; + drawarrow (0,0) -- (0,hauteur(s)) withcolor green; + drawarrow (0,0) -- (0,-profondeur(s)) withcolor blue; + draw p; + draw bbox p; +endfig; +beginfig(236) + def reddraw text t = draw t withcolor red enddef; + draw (0,0) -- (2cm,0); + reddraw (0,0) -- (2cm,5mm) withpen pencircle scaled 2bp; + +endfig; +beginfig(237) +path _myfill_p; + +def myfill expr p = + _myfill_p := p; + _myfill +enddef; + +def _myfill text t = + fill _myfill_p t; + draw _myfill_p t withcolor red; +enddef; + + myfill fullcircle scaled 1cm withcolor .8white withpen pencircle scaled 2bp; +endfig; +beginfig(238) + boxit.a(btex Essai etex); + a.c = (0,0); + drawboxed(a); + +endfig; +beginfig(239) + circleit.a(btex Essai etex); + a.c = (0,0); + drawboxed(a); + +endfig; +beginfig(240) + rboxit.a(btex Essai etex); + a.c = (0,0); + drawboxed(a); + +endfig; +beginfig(241) + boxit.a(btex Essai etex); + a.c = (0,0); + drawunboxed(a); + +endfig; +beginfig(242) + circleit.a(btex Essai etex); + a.c = (0,0); + a.dx = a.dy; + drawboxed(a); +endfig; +beginfig(243) + circleit.a(btex Essai etex); + a.c = (0,0); + a.dx = a.dy; + drawunboxed(a); + for i=0 step 10 until 360: + draw (0,0) -- 1cm*right rotated i cutbefore bpath.a; + endfor; +endfig; +beginfig(244) + circleit.a(btex Début etex); + a.c = (0,0); + a.dx = a.dy; + circleit.b(btex Fin etex); + b.c = (2cm,0); + b.dx = b.dy; + drawboxed(a,b); + drawarrow a.c {dir 45} .. b.c {dir -45} + cutbefore bpath.a cutafter bpath.b; + drawarrow b.c {dir -135} .. a.c {dir 135} + cutbefore bpath.b cutafter bpath.a; +endfig; +beginfig(245) + circleit.a(btex Début etex); + a.c = (0,0); + a.dx = a.dy; + circleit.b(btex Fin etex); + b.c = (2cm,0); + b.dx = b.dy; + drawunboxed(a,b); + drawarrow a.c {dir 45} .. b.c {dir -45} + cutbefore bpath.a cutafter bpath.b; + drawarrow b.c {dir -135} .. a.c {dir 135} + cutbefore bpath.b cutafter bpath.a; +endfig; +beginfig(246) + boxjoin( + a.dx = a.dy; + b.dx = b.dy; + a.e + (5mm,0) = b.w; + ); + circleit.a(btex Début etex); + a.c = (0,0); + circleit.b(btex Fin etex); + drawboxed(a,b); + drawarrow a.c {dir 45} .. b.c {dir -45} + cutbefore bpath.a cutafter bpath.b; + drawarrow b.c {dir -135} .. a.c {dir 135} + cutbefore bpath.b cutafter bpath.a; +endfig; +beginfig(247) + % Toujours mettre la commande boxjoin au début. + boxjoin(a.e = b.w); + boxit.a(btex A etex); + boxit.b(btex B etex); + boxit.c(btex C etex); + boxit.d(btex D etex); + drawboxed(a,b,c,d); +endfig; +beginfig(248) + boxjoin(a.e = b.w); + boxit.a(btex a etex); + boxit.b(btex b etex); + boxit.c(btex c etex); + boxit.d(btex d etex); + drawboxed(a,b,c,d); +endfig; +beginfig(249) + boxjoin(a.se = b.sw; a.ne = b.nw); + boxit.a(btex a etex); + boxit.b(btex b etex); + boxit.c(btex c etex); + boxit.d(btex d etex); + drawboxed(a,b,c,d); +endfig; +beginfig(250) + boxjoin(a.se = b.sw; a.ne = b.nw); + boxit.a1(btex a etex); + boxit.a2(btex b etex); + boxit.a3(btex c etex); + boxit.a4(btex d etex); + drawboxed(a1,a2,a3,a4); +endfig; +beginfig(251) + draw (0,0) -- (5cm,0) withcolor red; + draw btex a etex ; + draw btex b etex shifted (1cm,0); + draw btex c etex shifted (2cm,0); + draw btex d etex shifted (3cm,0); + draw btex e etex shifted (4cm,0); +endfig; +beginfig(252) + draw (0,0) -- (5cm,0) withcolor red; + boxjoin(b.c - a.c = (1cm,0)); + boxit a (btex a etex); + boxit b (btex b etex); + boxit c (btex c etex); + boxit d (btex d etex); + boxit e (btex e etex); + drawunboxed(a,b,c,d,e); +endfig; +beginfig(253) + vardef boxTEX expr s = + save p,h,l; + picture p; + numeric h,l; + p := TEX(s); + h := max(ypart ulcorner(p), abs(ypart llcorner(p))); + l := xpart lrcorner(p); + setbounds p to (0,-h)--(l,-h)--(l,h)--(0,h)--cycle; + p + enddef; + + draw (0,0) -- (5cm,0) withcolor red; + boxjoin(b.c - a.c = (1cm,0)); + boxit a (boxTEX "a"); + boxit b (boxTEX "b"); + boxit c (boxTEX "c"); + boxit d (boxTEX "d"); + boxit e (boxTEX "e"); + drawunboxed(a,b,c,d,e); +endfig; +beginfig(254) + draw (0,0) -- (5cm,0) withcolor red; + boxjoin(b.c - a.c = (1cm,0)); + boxit a (boxTEX "a"); + boxit b (boxTEX "b"); + boxit c (boxTEX "c"); + boxit d (boxTEX "d"); + boxit e (boxTEX "e"); + drawboxed(a,b,c,d,e); +endfig; +beginfig(255) + let OLD_beginbox_ = beginbox_; + def beginbox_(expr pp,sp)(suffix $)(text t) = + _n_ := str $; + generic_declare(pair) _n.off, _n.c; + generic_declare(string) pproc_._n, sproc_._n; + generic_declare(picture) pic_._n; + pproc_$:=pp; sproc_$:=sp; + pic_$ = nullpicture; + for _p_=t: + pic_$:= + if picture _p_: _p_ + else: _p_ infont defaultfont scaled defaultscale + fi; + endfor + $c = $off + (.5[xpart llcorner pic_$, xpart urcorner pic_$], 0) + enddef; + + draw (0,0) -- (5cm,0) withcolor red; + boxjoin(b.c - a.c = (1cm,0)); + boxit a (btex a etex); + boxit b (btex b etex); + boxit c (btex c etex); + boxit d (btex d etex); + boxit e (btex e etex); + drawunboxed(a,b,c,d,e); +endfig; +beginfig(256) + draw (0,0) -- (5cm,0) withcolor red; + boxjoin(b.c - a.c = (1cm,0)); + boxit a (btex a etex); + boxit b (btex b etex); + boxit c (btex c etex); + boxit d (btex d etex); + boxit e (btex e etex); + drawboxed(a,b,c,d,e); +endfig; +beginfig(257) +let OLD_boxit = boxit; +let OLD_sizebox_ = sizebox_; +let OLD_clearb_ = clearb_; + +vardef boxit@#(text tt) = + beginbox_("boxpath_","sizebox_",@#,tt); + generic_declare(pair) _n.sw, _n.s, _n.se, _n.e, _n.ne, _n.n, _n.nw, _n.w; + 0 = xpart (@#nw-@#sw) = ypart(@#se-@#sw); + 0 = xpart(@#ne-@#se) = ypart(@#ne-@#nw); + @#s = .5[@#sw,@#se]; + @#n = .5[@#ne,@#nw]; + xpart @#w = xpart @#nw; + xpart @#e = xpart @#ne; + ypart @#w = ypart @#c = ypart @#e; + @#ne-@#c = (@#dx,@#dy) + + (xpart(.5*(urcorner pic_@# - llcorner pic_@#)), ypart urcorner pic_@#); + @#c-@#sw = (@#dx,@#dy) + + (xpart(.5*(urcorner pic_@# - llcorner pic_@#)), -ypart lrcorner pic_@#); + endbox_(clearb_,@#); +enddef; + + draw (0,0) -- (5cm,0) withcolor red; + boxjoin(b.c - a.c = (1cm,0)); + boxit a (btex a etex); + boxit b (btex b etex); + boxit c (btex c etex); + boxit d (btex d etex); + boxit e (btex e etex); + drawboxed(a,b,c,d,e); +endfig; +beginfig(258) + draw (0,0) -- (5cm,0) withcolor red; + boxjoin(b.c - a.c = (1cm,0); b.ne - b.se = a.nw - a.sw); + boxit a (btex a etex); + boxit b (btex b etex); + boxit c (btex c etex); + boxit d (btex d etex); + boxit e (btex e etex); + drawboxed(a,b,c,d,e); +endfig; +beginfig(259) +vardef boxit@#(text tt) = + beginbox_("boxpath_","sizebox_",@#,tt); + generic_declare(pair) _n.sw, _n.s, _n.se, _n.e, _n.ne, _n.n, _n.nw, _n.w; + 0 = xpart (@#nw-@#sw) = ypart(@#se-@#sw); + 0 = xpart(@#ne-@#se) = ypart(@#ne-@#nw); + @#s = .5[@#sw,@#se]; + @#n = .5[@#ne,@#nw]; + xpart @#w = xpart @#nw; + xpart @#e = xpart @#ne; + ypart @#w = ypart @#c = ypart @#e; + @#ne-@#c = (@#dx,@#dyup) + + (xpart(.5*(urcorner pic_@# - llcorner pic_@#)), ypart urcorner pic_@#); + @#c-@#sw = (@#dx,@#dydown) + + (xpart(.5*(urcorner pic_@# - llcorner pic_@#)), -ypart lrcorner pic_@#); + endbox_(clearb_,@#); +enddef; + +def sizebox_(suffix $) = + if unknown $.dx: $.dx=defaultdx; fi + if unknown $.dyup: + if unknown $.dy: + $.dyup=defaultdy + else: + $.dyup=$.dy + fi; + fi; + if unknown $.dydown: + if unknown $.dy: + $.dydown=defaultdy + else: + $.dydown=$.dy + fi; + fi; +enddef; + +vardef clearb_(suffix $) = + _n_ := str $; + generic_redeclare(numeric) _n.sw, _n.s, _n.se, _n.e, _n.ne, _n.n, _n.nw, _n.w, + _n.c, _n.off, _n.dx, _n.dy, _n.dyup, _n.dy_down; +enddef; + + draw (0,0) -- (5cm,0) withcolor red; + boxjoin(b.c - a.c = (1cm,0); ypart( b.ne - a.ne ) = 0; ypart( b.se - a.se ) = 0;); + boxit a (btex a etex); + boxit b (btex b etex); + boxit c (btex c etex); + boxit d (btex d etex); + boxit e (btex e etex); + drawboxed(a,b,c,d,e); +endfig; +beginfig(260) + draw (0,0) -- (5cm,0) withcolor red; + picture p; + numeric h; + p := btex b etex; + h = ypart ( ulcorner p - llcorner p ); + boxjoin( + b.c - a.c = (1cm,0); + ypart( b.ne - a.ne ) = 0; + ypart( a.ne - a.se ) = h+2defaultdy; + ); + boxit a (btex a etex); + boxit b (btex b etex); + boxit c (btex c etex); + boxit d (btex d etex); + boxit e (btex e etex); + drawboxed(a,b,c,d,e); +endfig; +beginfig(261) + % Les lignes suivantes n'ont pas l'effet escompté... + let beginbox_ = OLD_beginbox_; + let boxit = OLD_boxit; + let sizebox_ = OLD_sizebox_; + let clearb_ = OLD_clearb_; + + % On recopie donc les définitions initiales des macros que l'on a modifiées... + extra_beginfig := ""; + extra_endfig := ""; + input boxes; + + % Et on regarde sur un exemple si ça marche... + draw (0,0) -- (5cm,0) withcolor red; + boxjoin(b.c - a.c = (1cm,0)); + boxit a (btex a etex); + boxit b (btex b etex); + boxit c (btex c etex); + boxit d (btex d etex); + boxit e (btex e etex); + drawboxed(a,b,c,d,e); +endfig; +beginfig(262) + boxit.a1(btex $a$ etex); + boxit.b1(btex etex); + boxit.a2(btex $b$ etex); + boxit.b2(btex etex); + boxit.a3(btex $c$ etex); + boxit.b3(btex etex); + boxit.a4(btex $d$ etex); + boxit.b4(btex etex); + for i=1 upto 4: + % Les boites a[i] et b[i] sont collées + a[i].e = b[i].w; + % Il y a un peu d'espace entre b[i] et a[i+1] + b[i].e + (5mm,0) = a[i+1].w; + % La hauteur des boites est la même + a[i].n - a[i].s = a[i+1].n - a[i+1].s = b[i].n - b[i].s ; + % Les b[i] ne sont pas très larges + b[i].e - b[i].w = (2mm,0); + endfor; + drawboxed(a1,b1,a2,b2,a3,b3,a4,b4); + for i=1 upto 3: + drawarrow b[i].c {up} .. a[i+1].c {down} + cutafter bpath.a[i+1]; + endfor; +endfig; +beginfig(263) + boxit.a(btex A etex); + boxit.b(btex B etex); + boxit.c(btex C etex); + boxit.d(btex D etex); + boxit.e(btex E etex); + + b.c-a.c = (1cm,0); + c.c-b.c = (b.c-a.c) rotated 72; + d.c-c.c = (c.c-b.c) rotated 72; + e.c-d.c = (d.c-c.c) rotated 72; + a.c-e.c = (e.c-d.c) rotated 72; + b.c-a.c = (a.c-e.c) rotated 72; + + drawboxed(a,b,c,d,e); + + drawarrow a.c -- b.c cutbefore bpath.a cutafter bpath.b; + drawarrow b.c -- c.c cutbefore bpath.b cutafter bpath.c; + drawarrow c.c -- d.c cutbefore bpath.c cutafter bpath.d; + drawarrow d.c -- e.c cutbefore bpath.d cutafter bpath.e; + drawarrow e.c -- a.c cutbefore bpath.e cutafter bpath.a; +endfig; +beginfig(264) + boxit.a(btex A etex); + boxit.b(btex B etex); + boxit.c(btex C etex); + boxit.d(btex D etex); + boxit.e(btex E etex); + + d.c = 1cm*up; + e.c = 1cm*up rotated (1*72); + a.c = 1cm*up rotated (2*72); + b.c = 1cm*up rotated (3*72); + c.c = 1cm*up rotated (4*72); + + drawunboxed(a,b,c,d,e); + + drawarrow a.c -- b.c cutbefore bpath.a cutafter bpath.b; + drawarrow b.c -- c.c cutbefore bpath.b cutafter bpath.c; + drawarrow c.c -- d.c cutbefore bpath.c cutafter bpath.d; + drawarrow d.c -- e.c cutbefore bpath.d cutafter bpath.e; + drawarrow e.c -- a.c cutbefore bpath.e cutafter bpath.a; +endfig; +beginfig(265) + def linkboxes(suffix a,b) = + drawarrow a.c -- b.c cutbefore bpath.a cutafter bpath.b; + enddef; + + boxit.a(btex A etex); + boxit.b(btex B etex); + boxit.c(btex C etex); + boxit.d(btex D etex); + boxit.e(btex E etex); + + d.c = 1cm*up; + e.c = 1cm*up rotated (1*72); + a.c = 1cm*up rotated (2*72); + b.c = 1cm*up rotated (3*72); + c.c = 1cm*up rotated (4*72); + + drawunboxed(a,b,c,d,e); + + linkboxes(a,b); + linkboxes(b,c); + linkboxes(c,d); + linkboxes(d,e); + linkboxes(e,a); +endfig; +beginfig(266) + boxit a(btex Essai etex); + fill bpath a withcolor .5[red,white]; + drawboxed(a); + +endfig; +beginfig(267) + def drawredboxed(text t) = + forsuffixes a=t: + fill bpath a withcolor .5[red,white]; + endfor; + drawboxed(t); + enddef; + + circleit.a(btex Début etex); + a.c = (0,0); + a.dx = a.dy; + circleit.b(btex Fin etex); + b.c = (2cm,0); + b.dx = b.dy; + drawredboxed(a,b); + drawarrow a.c {dir 45} .. b.c {dir -45} + cutbefore bpath.a cutafter bpath.b; + drawarrow b.c {dir -135} .. a.c {dir 135} + cutbefore bpath.b cutafter bpath.a; + +endfig; +beginfig(268) + def drawcoloredboxed(expr c)(text t) = + forsuffixes a=t: + fill bpath a withcolor c; + endfor; + drawboxed(t); + enddef; + + circleit.a(btex Début etex); + a.c = (0,0); + a.dx = a.dy; + circleit.b(btex Fin etex); + b.c = (2cm,0); + b.dx = b.dy; + drawcoloredboxed(.5[red,white], a); + drawcoloredboxed(.5[blue,white], b); + drawarrow a.c {dir 45} .. b.c {dir -45} + cutbefore bpath.a cutafter bpath.b; + drawarrow b.c {dir -135} .. a.c {dir 135} + cutbefore bpath.b cutafter bpath.a; + +endfig; +beginfig(269) +def begindiag = + begingroup; + save _diag_x, _diag_x_max, _diag_y, _diag_y_max, _diag; + numeric _diag_x, _diag_x_max, _diag_y, _diag_y_max; + string _diag[][]; + % Numéro de ligne et de colonne courrants + _diag_x = -1; _diag_y = 0; + % Numéro de ligne et de colonne maximaux + _diag_x_max = _diag_y_max = 0; + save _diag_ar_n, _diag_ar_source, _diag_ar_but, _diag_ar_up, _diag_ar_down; + % Nombre de flèches + numeric _diag_ar_n; _diag_ar_n=-1; + % Source et but de la flèche + pair _diag_ar_source[], _diag_ar_but[]; + % Ce qu'il faut écrire au dessus ou au dessous + string _diag_ar_up[], _diag_ar_down[]; + save _diag_ar_curved, _diag_ar_shape, _diag_ar_color, _diag_ar_width; + % « courbure » (c'est une distance) + numeric _diag_ar_curved[]; + % Forme de la flèche + string _diag_ar_shape[]; + % Couleur, épaisseur, pointillés + color _diag_ar_color[]; + numeric _diag_ar_width[]; + picture _diag_ar_dashed[]; +enddef; + +def node expr A = + _diag_x := _diag_x + 1; + _diag_x_max := max(_diag_x,_diag_x_max); + _diag[_diag_x][_diag_y] := A; +enddef; + +def nextline = + _diag_x := -1; + _diag_y := _diag_y + 1; + _diag_y_max := max(_diag_y, _diag_y_max); +enddef; + +tertiarydef a => b = a, b enddef; +def even (expr a) = not odd(a) enddef; + +vardef rarrowto(expr a,b)(text t) = + save i,p; + _diag_ar_n := _diag_ar_n + 1; + _diag_ar_source[_diag_ar_n] = (_diag_x, _diag_y); + _diag_ar_but[_diag_ar_n] = (_diag_x + a, _diag_y + b); + + numeric i; i:=0; + string current; + for p=t: + if even(i): + current := p; + else: + if current = "above": + _diag_ar_up[_diag_ar_n] = p; + elseif current = "below": + _diag_ar_down[_diag_ar_n] = p; + elseif current = "shape": + _diag_ar_shape[_diag_ar_n] = p; + elseif current = "curved": + _diag_ar_curved[_diag_ar_n] = p; + elseif current = "color": + _diag_ar_color[_diag_ar_n] = p; + elseif current = "width": + _diag_ar_width[_diag_ar_n] = p; + elseif current = "dashed": + _diag_ar_dashed[_diag_ar_n] = p; + else: + errmessage("rarrowto: Wrong argument "&ditto¤t&ditto); + fi; + fi; + i := i + 1; + endfor; + if odd i: + errmessage("rarrowto: Odd number of arguments "&decimal(i)); + fi; +enddef; + +%% Les têtes de flèches + +picture withsmalldots, notdashed; +withsmalldots := withdots scaled .3; +notdashed := dashpattern(on 50cm); + +vardef diag_arrow_head (expr p, t) = + save A,B,C,u; pair A,B,C,u; + B := point t of p; + u := -unitvector(direction t of p); + A := B + ahlength*u rotated(-ahangle); + C := B + ahlength*u rotated(+ahangle); + A .. {-u} B {u} .. C +enddef; + +vardef diag_arrow_bar (expr p, t) = + save A,B,C,u; pair A,B,C,u; + B := point t of p; + u := unitvector(direction t of p); + A := B + ahlength*sind(ahangle)*u rotated(90); + C := B + ahlength*sind(ahangle)*u rotated(-90); + A .. B .. C +enddef; + +%% Les flèches + +def diag_draw_arrow_default(suffix a,b)(expr curved, w, col, dash) = + p = a.c .. + (1/2 [a.c,b.c] + curved*unitvector(b.c-a.c) rotated 90) + .. b.c; + pp := p cutbefore bpath.a cutafter bpath.b; + draw pp + withcolor col withpen pencircle scaled w dashed dash; + draw diag_arrow_head (pp, length(pp)) + withcolor col withpen pencircle scaled w; +enddef; + +def diag_draw_arrow_middle(suffix a,b)(expr curved, w, col, dash) = + p = a.c .. + (1/2 [a.c,b.c] + curved*unitvector(b.c-a.c) rotated 90) + .. b.c; + pp := p cutbefore bpath.a cutafter bpath.b; + draw pp + withcolor col withpen pencircle scaled w dashed dash; + draw diag_arrow_head(p,1) + withcolor col withpen pencircle scaled w; +enddef; + +def diag_draw_arrow_epi(suffix a,b)(expr curved, w, col, dash) = + p = a.c .. + (1/2 [a.c,b.c] + curved*unitvector(b.c-a.c) rotated 90) + .. b.c; + pp := p cutbefore bpath.a cutafter bpath.b; + draw pp + withcolor col withpen pencircle scaled w dashed dash; + draw diag_arrow_head (pp, length(pp)) + withcolor col withpen pencircle scaled w; + path ppp; + ppp := pp cutafter (fullcircle scaled 1mm shifted point length(pp) of pp); + draw diag_arrow_head(ppp, length(ppp)) + withcolor col withpen pencircle scaled w; +enddef; + +def diag_draw_arrow_mono(suffix a,b)(expr curved, w, col, dash) = + p = a.c .. + (1/2 [a.c,b.c] + curved*unitvector(b.c-a.c) rotated 90) + .. b.c; + pp := p cutbefore bpath.a cutafter bpath.b; + path ppp; + ppp := pp cutbefore (fullcircle scaled 1mm shifted point 0 of pp); + draw ppp + withcolor col withpen pencircle scaled w dashed dash; + draw diag_arrow_head (pp, length(pp)) + withcolor col withpen pencircle scaled w; + draw diag_arrow_head(ppp, 0) + withcolor col withpen pencircle scaled w; +enddef; + +vardef diag_draw_arrow_inj(suffix a,b)(expr curved, w, col, dash) = + p = a.c .. + (1/2 [a.c,b.c] + curved*unitvector(b.c-a.c) rotated 90) + .. b.c; + pp := p cutbefore bpath.a cutafter bpath.b; + path ppp; + ppp := pp cutbefore (fullcircle scaled 1mm shifted point 0 of pp); + draw ppp + withcolor col withpen pencircle scaled w dashed dash; + draw diag_arrow_head (pp, length(pp)) + withcolor col withpen pencircle scaled w; + save u,A,B,C; + pair u,A,B,C; + A := point 0 of ppp; + u := unitvector(direction 0 of ppp); + B := A + ahlength*(-u) rotated (-ahangle); + C := A + 2 ahlength*sind(ahangle)*u rotated 90; + draw C {-u} .. B .. A {u} + withcolor col withpen pencircle scaled w dashed dash; +enddef; + +def diag_draw_arrow_mapsto(suffix a,b)(expr curved, w, col, dash) = + p = a.c .. + (1/2 [a.c,b.c] + curved*unitvector(b.c-a.c) rotated 90) + .. b.c; + pp := p cutbefore bpath.a cutafter bpath.b; + draw pp + withcolor col withpen pencircle scaled w dashed dash; + draw diag_arrow_head (pp, length(pp)) + withcolor col withpen pencircle scaled w; + draw diag_arrow_bar (pp, 0) + withcolor col withpen pencircle scaled w; +enddef; + +def diag_draw_arrow_half_dotted(suffix a,b)(expr curved, w, col, dash) = + p = a.c .. + (1/2 [a.c,b.c] + curved*unitvector(b.c-a.c) rotated 90) + .. b.c; + pp := p cutbefore bpath.a cutafter bpath.b; + draw subpath(0,1) of pp + withcolor col withpen pencircle scaled w dashed withsmalldots; + draw subpath(1,2) of pp + withcolor col withpen pencircle scaled w; + draw diag_arrow_head (pp, length(pp)) + withcolor col withpen pencircle scaled w; +enddef; + +%% Fin des flèches + +def color_to_string (expr a) = + "("& + decimal(redpart a) + &","& + decimal(greenpart a) + &","& + decimal(bluepart a) + &")" +enddef; + +def enddiag = + save i,j,k,l,mm,a,A,p,b; + for i=0 upto _diag_x_max: + for j=0 upto _diag_y_max: + if known _diag[i][j]: + circleit.a[i][j]( _diag[i][j] ); + a[i][j].dx = a[i][j].dy; + a[i][j].c = 1cm * (i,-j); + drawunboxed( a[i][j] ); + fi; + endfor; + endfor; + for m=0 upto _diag_ar_n: + % Vérifier que le but existe + i := xpart _diag_ar_source[m]; + j := ypart _diag_ar_source[m]; + k := xpart _diag_ar_but[m]; + l := ypart _diag_ar_but[m]; + + % On trace la flèche. Le chemin est mis dans la variable p. + path p,pp; + if unknown _diag_ar_shape[m]: _diag_ar_shape[m] := "default" fi; + if unknown _diag_ar_color[m]: _diag_ar_color[m] := black fi; + if unknown _diag_ar_width[m]: _diag_ar_width[m] := .5bp fi; + if unknown _diag_ar_curved[m]: _diag_ar_curved[m] := 0 fi; + if unknown _diag_ar_dashed[m]: _diag_ar_dashed[m] := notdashed fi; + % On ne peut PAS utiliser m dans une chaîne ce caractères que l'on donne + % à scantokens, car m est une variable de boucle. C'est vraiment spécial, + % une variable de boucle. + mm := m; + scantokens( + "diag_draw_arrow_"& _diag_ar_shape[m] + &"(" + &"a[i][j], a[k][l],_diag_ar_curved[mm],_diag_ar_width[mm]," + &"_diag_ar_color[mm],_diag_ar_dashed[mm]" + &");" + ); + + % On écrit des choses au dessus ou au dessous des flèches + pair A; + A = point 1/2 length(p) of p; + if known _diag_ar_up[m]: + boxit.b[m](_diag_ar_up[m]); + b[m].c = A + 4bp*unitvector(direction 1/2 length(p) of p rotated 90); + drawunboxed(b[m]); + fi; + if known _diag_ar_down[m]: + boxit.c[m](_diag_ar_down[m]); + c[m].c = A + 4bp*unitvector(direction 1/2 length(p) of p rotated -90); + drawunboxed(c[m]); + fi; + endfor; + endgroup; +enddef; + + begindiag; + node "A"; + rarrowto(1,0, "above" => "a", + "shape" => "middle", + "curved" => 3mm, + "dashed" => withsmalldots); + rarrowto(0,1, "below" => "b", + "color" => blue, + "shape" => "mapsto", + "dashed" => evenly); + node "A"; + rarrowto(1,0, "above" => "c", "width" => 1bp, "shape" => "inj"); + rarrowto(0,1, "below" => "d", "shape" => "mono"); + node "A"; + nextline; + node "A"; + rarrowto(1,0, "below" => "e", "shape" => "epi"); + node "A"; + rarrowto(1,-1, "below" => "f", "curved" => -3mm, "shape" => "half_dotted"); + enddiag; +endfig; +beginfig(270) + draw begingraph(3cm,2cm) + gdraw "data1"; + endgraph; + +endfig; +beginfig(271) + draw begingraph(3cm,2cm) + gdraw "data1" withpen pencircle scaled 2bp; + endgraph; +endfig; +beginfig(272) + draw begingraph(3cm,2cm) + gdraw "data1" dashed evenly; + endgraph; +endfig; +beginfig(273) + draw begingraph(3cm,2cm) + gdraw "data1" withcolor red; + endgraph; +endfig; +beginfig(274) + draw begingraph(3cm,2cm) + gdraw "data1" withpen pencircle scaled 2bp; + gdraw "data2" ; + endgraph; +endfig; +beginfig(275) + draw begingraph(3cm,2cm) + gdraw "data1" ; + gdraw "data2" dashed evenly; + gdraw "data3" dashed withdots; + endgraph; +endfig; +beginfig(276) + draw begingraph(3cm,2cm) + gdraw "data1" withcolor red; + gdraw "data2" withcolor blue; + endgraph; +endfig; +beginfig(277) + draw begingraph(3cm,2cm) + gdraw "data1" plot btex $\bullet$ etex; + endgraph; + +endfig; +beginfig(278) + picture gros_point; + draw (0,0) withpen pencircle scaled 4bp; + gros_point := currentpicture; + currentpicture := nullpicture; + draw begingraph(3cm,2cm) + gdraw "data1" plot gros_point; + endgraph; +endfig; +beginfig(279) + picture gros_point; + gros_point := nullpicture; + addto gros_point doublepath (0,0) + withpen pencircle scaled 4bp; + draw begingraph(3cm,2cm) + gdraw "data1" plot gros_point; + endgraph; +endfig; +beginfig(280) + picture croix; + croix := nullpicture; + addto croix doublepath (-2bp,2bp)--(2bp,-2bp) + withpen pencircle scaled 1bp; + addto croix doublepath (-2bp,-2bp)--(2bp,2bp) + withpen pencircle scaled 1bp; + picture gros_carre; + gros_carre := nullpicture; + addto gros_carre contour unitsquare shifted (-.5,-.5) scaled 2bp; + + draw begingraph(3cm,2cm) + gdraw "data1"; + gdraw "data1" plot croix; + gdraw "data2"; + gdraw "data2" plot gros_carre; + endgraph; +endfig; +beginfig(281) + draw begingraph(3cm,2cm) + gdata("data1", + v, + glabel(gros_point, v1, v2); + ); + endgraph; + +endfig; +beginfig(282) + draw begingraph(3cm,2cm) + path p; + gdata("data1", + v, + augment.p(v1,v2); + ); + gdraw p; + endgraph; + +endfig; +beginfig(283) + interim linecap := squared; + interim linejoin := mitered; + draw begingraph(3cm,2cm) + path p; + gdata("data1", + v, + augment.p(v1,v2); + ); + gdraw p withpen pencircle scaled 2bp; + gdraw p withpen pencircle scaled 1bp withcolor .8white; + endgraph; +endfig; +beginfig(284) + draw begingraph(3cm,2cm) + gdata("data1", + v, + path p; + augment p (v1,0); + augment p (v1,v2); + gdraw p; + ); + endgraph; +endfig; +beginfig(285) + draw begingraph(3cm,2cm) + gdata("data1", + v, + path p; + augment p (v1,0); + augment p (v1,v2); + gdraw p withpen pencircle scaled 4bp; + ); + endgraph; +endfig; +beginfig(286) + interim linecap:=2; + draw begingraph(3cm,2cm) + gdata("data1", + v, + path p; + augment p (v1,0); + augment p (v1,v2); + gdraw p withpen pencircle scaled 4bp; + ); + endgraph; +endfig; +beginfig(287) + draw begingraph(3cm,2cm) + gdata("data1", v, + path p; + augment p (v1,0); + augment p (v1,v2); + augment p (v1 Sadd "1",v2); + augment p (v1 Sadd "1",0); + gdraw p--cycle; + ); + endgraph; +endfig; +beginfig(288) + draw begingraph(3cm,2cm) + gdata("data1", v, + path p; + augment p (v1,0); + augment p (v1,v2); + augment p (v1 Sadd "1",v2); + augment p (v1 Sadd "1",0); + gfill p--cycle withcolor .8white; + gdraw p--cycle; + ); + endgraph; +endfig; +beginfig(289) + draw begingraph(3cm,2cm) + gdata("data1", v, + + % Le dessus + path p; + augment p (v1,v2); + augment p (v1 Sadd "1",v2); + augment p (v1 Sadd "1.5", v2 Sadd "10"); + augment p (v1 Sadd ".5", v2 Sadd "10"); + gfill p--cycle withcolor white; + gdraw p--cycle; + + % Le côté + path p; + augment p (v1 Sadd "1",0); + augment p (v1 Sadd "1",v2); + augment p (v1 Sadd "1.5", v2 Sadd "10"); + augment p (v1 Sadd "1.5", "10"); + gfill p--cycle withcolor .5white; + gdraw p--cycle; + + % Le devant + path p; + augment p (v1,0); + augment p (v1,v2); + augment p (v1 Sadd "1",v2); + augment p (v1 Sadd "1",0); + gfill p--cycle withcolor .8white; + gdraw p--cycle; + + ); + endgraph; +endfig; +beginfig(290) + draw begingraph(3cm,2cm) + path p,q; + gdata("data1", v, + augment.p(v1,v2); + ); + q:= (xpart point 0 of p, 0) -- p -- + (xpart point length(p) of p, 0) -- cycle; + gfill q withcolor .8white; + gdraw p withpen pencircle scaled 2bp; + endgraph; +endfig; +beginfig(291) + draw begingraph(3cm,2cm) + gdata("data1", + v, + path p; + augment p ("0", i); + augment p (v2, i); + augment p (v2, i Sadd ".5"); + augment p (0, i Sadd ".5"); + gfill p--cycle withcolor .8white; + gdraw p--cycle; + ); + autogrid(otick.bot,); + endgraph; +endfig; +beginfig(292) + draw begingraph(3cm,2cm) + gdraw "data1"; + glabel.bot(btex Abscisse etex, OUT); + glabel.lft(btex Ordonnée etex, OUT); + endgraph; + +endfig; +beginfig(293) + draw begingraph(3cm,2cm) + gdraw "data1" withcolor red; + glabel.lft(btex 1 etex, 8); + gdraw "data2" withcolor blue; + glabel.bot(btex 2 etex, 9); + endgraph; + +endfig; +beginfig(294) + draw begingraph(3cm,2cm) + gdraw "data1"; + glabel.bot(btex Abscisse etex, OUT); + glabel.lft(btex Ordonnée etex rotated 90, OUT); + endgraph; +endfig; +beginfig(295) + % La légende + color couleur[]; + couleur[0] := red; + couleur[1] := green; + couleur[2] := blue; + picture p[], legende; + legende := nullpicture; + for i=0 upto 2: + p[i] := nullpicture; + addto p[i] also TEX("Courbe " & decimal(i+1)) + withcolor couleur[i]; + addto legende doublepath ( (0,0)--(5mm,0) ) + shifted (0, -5mm*i) + withpen currentpen withcolor couleur[i]; + addto legende also p[i] + shifted 1/2(lrcorner p[i] - ulcorner p[i]) + shifted (0, -5mm*i); + endfor; + % Les courbes + draw begingraph(3cm,2cm) + for i=1 upto 3: + gdraw "data" & decimal(i) withcolor couleur[i-1]; + endfor; + glabel.top(legende,OUT); + endgraph; +endfig; +beginfig(296) + draw begingraph(3cm,2cm) + setcoords(-linear,log); + gdraw "data1"; + endgraph; + +endfig; +beginfig(297) + draw begingraph(3cm,2cm) + gdraw "data1"; + endgraph; + +endfig; +beginfig(298) + draw begingraph(3cm,2cm) + setrange( (whatever,0), (whatever,whatever) ); + gdraw "data1"; + endgraph; + +endfig; +beginfig(299) + draw begingraph(3cm,2cm) + setrange(whatever, 0, whatever, whatever); + gdraw "data1"; + endgraph; + +endfig; +beginfig(300) + vardef TEX primary s = + write "verbatimtex" to "mptextmp.mp"; + write "\documentclass[12pt]{article}" to "mptextmp.mp"; + write "\usepackage[T1]{fontenc}" to "mptextmp.mp"; + write "\usepackage{amsmath,amssymb}" to "mptextmp.mp"; + write "\begin{document}" to "mptextmp.mp"; + write "etex" to "mptextmp.mp"; + write "btex "&s&" etex" to "mptextmp.mp"; + write EOF to "mptextmp.mp"; + scantokens "input mptextmp" + enddef; + vardef mylabel(expr pic, p, t) = + save A; pair A; + A = point t of p + + 8bp * unitvector(direction t of p) rotated 90; + label(pic, A); + enddef; + path p; u:=1cm; + p = (0,0)..(-u,u)..(u,u); + draw p; + for i=0 step .2 until length(p): + draw point i of p withpen pencircle scaled 4bp; + mylabel(TEX("$"&decimal(round(5*i))&"$"),p,i); + endfor; + +endfig; +beginfig(301) + path p; + p := subpath(1,3) of fullcircle scaled 2cm; + interim linejoin := mitered; + interim linecap := butt; + + interim ahangle := 30; + drawarrow p withpen pencircle scaled 2bp; + + interim ahangle := 45; + drawarrow p shifted (0,-5mm) withpen pencircle scaled 2bp; + + interim ahangle := 60; + drawarrow p shifted (0,-10mm) withpen pencircle scaled 2bp; + +endfig; +beginfig(302) + path p; + p := subpath(1,3) of fullcircle scaled 2cm; + interim linejoin := mitered; + interim linecap := butt; + interim ahangle := 30; + + interim ahlength := 2bp; + drawarrow p withpen pencircle scaled 2bp; + + interim ahlength := 4bp; + drawarrow p shifted (0,-5mm) withpen pencircle scaled 2bp; + + interim ahlength := 6bp; + drawarrow p shifted (0,-10mm) withpen pencircle scaled 2bp; + +endfig; +beginfig(303) + draw TEX( "Nous sommes le "& + decimal(day) &"/"& + decimal(month) &"/"& + decimal(year) &"." ); + +endfig; +beginfig(304) + path p; + p := (0,0) -- (2cm,0); + def doit (suffix p)(expr t) = + begingroup + interim linecap := t; + draw p withpen pencircle scaled 5mm withcolor .8white; + endgroup; + draw point 0 of p withpen pencircle scaled 4bp; + draw point 1 of p withpen pencircle scaled 4bp; + p := p shifted (0,-7mm) + enddef; + doit(p,rounded); + doit(p,butt); + doit(p,squared); + +endfig; +beginfig(305) + path p; + p := (0,0) -- (1cm,5mm) -- (2cm,0); + def doit (suffix p)(expr t) = + begingroup + interim linejoin := t; + draw p withpen pencircle scaled 5mm withcolor .8white; + endgroup; + draw point 0 of p withpen pencircle scaled 4bp; + draw point 1 of p withpen pencircle scaled 4bp; + draw point 2 of p withpen pencircle scaled 4bp; + p := p shifted (0,-7mm) + enddef; + doit(p,rounded); + doit(p,mitered); + doit(p,beveled); + +endfig; +bye; diff --git a/info/metapost/examples/mp2html.pl b/info/metapost/examples/mp2html.pl new file mode 100644 index 0000000000..143e2314e0 --- /dev/null +++ b/info/metapost/examples/mp2html.pl @@ -0,0 +1,170 @@ +#! perl -w + +# +# Builds an HTML file and a bunch of GIF files from a Metapost file +# Also creates a PS file +# +# (c) Vincent Zoonekynd <zoonek@math.jussieu.fr> +# August 1999 +# modified in august 2001 +# distributed under the GPL +# + +$main = $ARGV[0] || "examples"; +$main =~ s/\.mp$//i; + +# On crée les images GIF +# BUG : à chaque fois qu'il y a des fontes, ça plante. +# C'est normal pour deux raisons : +# - si j'utilisais prologuse:=2, il ne trouverait pas les fontes. +# - Comme j'utilise prologues:=0, c'est encore pire... +# L'idéal serait de créer un fichier LaTeX pour chaque fichier postscript, +# de lancer later puis dvips dessus et de récupérer le fichier postscript. + +# 1. Compile the examples + +system "TEX=latex mpost --interaction=nonstopmode $main"; + +# 2. Create a LaTeX file encompassing the examples and compile it + +open(LATEX,'>', "$main.tex") || die "Cannot open examples.tex for writing: $!"; +print LATEX '\documentclass[a4paper]{article}' ."\n"; +print LATEX '\usepackage{graphicx}' ."\n"; +print LATEX '\begin{document}' ."\n"; +print LATEX '\begin{verbatim}' ."\n"; +open(MP, "<", "$main.mp") || die "cannot open $main.mp for reading: $!"; +while(<MP>){ + if (m/^\s*beginfig\s*\((.*)\)/) { + print LATEX '\end{verbatim}' . "\n"; + print LATEX "\\includegraphics{${main}_$1.mps}\n"; + print LATEX '\begin{verbatim}' . "\n"; + print LATEX $_; + } elsif (m/^\s*endfig/) { + print LATEX $_; + print LATEX '\end{verbatim}' ."\n"; + print LATEX '\hrulefill' . "\n"; + print LATEX '\begin{verbatim}' . "\n"; + } else { + print LATEX $_; + } +} +print LATEX '\end{verbatim}' . "\n"; +print LATEX '\end{document}' ."\n"; +close MP; +close LATEX; + +opendir(DIR,"./") || die "Cannot open ./ directory for reading : $!"; +foreach $file (readdir DIR) { + if ($file =~ m/^$main.[0-9]+$/) { + my $new = $file; + $new =~ s/\./_/g; + $new .= ".mps"; + symlink $file, $new; + } +} +closedir(DIR); + +system "latex --interaction=nonstopmode $main.tex"; +system "dvips -o $main.ps $main.dvi"; +#system "pdflatex --interaction=nonstopmode $main.tex"; + +# 3. Create the GIF pictures + +opendir(DIR,"./") || die "Cannot open ./ directory for reading : $!"; +foreach $file (readdir DIR) { + if ($file =~ m/^$main.[0-9]+$/) { + + ## Création du fichier PS + symlink "$file", "$file.eps"; + open(TEX,">$file.tex") || die "cannot open $file.tex for writing : $!"; + print TEX '\nonstopmode' ."\n" ; + print TEX '\documentclass[a4paper,10pt]{article}' ."\n" ; + print TEX '\usepackage[T1]{fontenc}\usepackage[latin1]{inputenc}' ."\n" ; + print TEX '\usepackage{graphicx,amsmath,amssymb}' ."\n" ; + print TEX '\pagestyle{empty}' ."\n" ; + print TEX '\begin{document}' ."\n" ; + print TEX '\includegraphics{'. "$file.eps" .'}' ."\n" ; + print TEX '\end{document}' ."\n" ; + close TEX; + system "latex $file.tex"; + system "dvips -E -f $file.dvi -o $file.ps"; + + ## Transformation en GIF + my ($bbx,$bby,$bbw,$bbh); + open(PS,"$file.ps"); + while (<PS>) { + if (/^%%BoundingBox:\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)/) { + $bbx = 0-$1; $bby = 0-$2; + $bbw = $3+$bbx; $bbh = $4+$bby; +# print "*** Seen BBOX\n"; + } + last if /^%%EndComments/; + } + close(PS); + + my $scale = 3; + my $density = 72*$scale; + $bbw = $scale * $bbw; + $bbh = $scale * $bbh; +# print "*** gs -q -dNOPAUSE -dNO_PAUSE -sDEVICE=ppmraw -g${bbw}x${bbh} -r$density -sOutputFile=$file.ppm\n"; + open(GS, "|gs -q -dNOPAUSE -dNO_PAUSE -sDEVICE=ppmraw -g${bbw}x${bbh} -r$density -sOutputFile=$file.ppm"); + print GS "$bbx $bby translate\n"; + print GS "($file.ps) run\n"; + print GS "showpage\n"; + print GS "quit\n"; + close(GS); + + system("pnmcrop $file.ppm | ppmquant 256 | ppmtogif > $file.gif"); + + unlink "$file.ppm"; + } +} + + +# 4. Create the HTML file +open(MP,"$main.mp") || die "cannot open $main.mp for reading: $!"; +open(HTML,">$main.html") || die "cannot open $main.html for writing: $!"; +select HTML; +print "<HTML><HEAD><TITLE>Metapost : exemples</TITLE></HEAD><BODY>\n"; +print "<H1> Métapost : exemples </H1>\n"; +print "<HR><PRE>\n"; +while(<MP>){ + if (m/^\s*beginfig\s*\((.*)\)/) { + print "</PRE><IMG SRC=\"$main.$1.gif\"><PRE>\n"; + print ; + } elsif (m/^\s*endfig/) { + print; + print "</PRE><HR><PRE>\n"; + } else { + print; + } +} +print "</PRE>\n"; +print "</BODY></HTML>\n"; +close HTML; +close MP; + +# 5. Remove unnecessary files + +opendir(DIR,"./") || die "Cannot open ./ directory for reading : $!"; +foreach $file (readdir DIR) { + if ($file =~ m/^$main.[0-9]+$/) { + unlink $file; + unlink "$file.tex"; + unlink "$file.dvi"; + unlink "$file.aux"; + unlink "$file.log"; + unlink "$file.eps"; + unlink "$file.ps"; + my $new = $file; + $new =~ s/\./_/g; + $new .= ".mps"; + unlink $new; + } elsif( $file =~ m/\.mpx$/ ) { + unlink $file; + } +} +closedir DIR; +unlink "$main.aux"; +unlink "$main.log"; + |