<< . .

. 31
( : 45)



. . >>



Looke into this Businesse thorowly,
And call these foule O¬endors to their Answeres.
” WILLIAM SHAKESPEARE, Second Part of Henry the Sixth (1594)

If you can™t solve a problem,
you can always look up the answer.
But please, try ¬rst to solve it by yourself;
then you™ll learn more and you™ll learn faster.
” DONALD E. KNUTH, The book (1986)
(page 256)




B
Basic
Operations
Appendix B: Basic Operations 257


This appendix de¬nes the macros of the plain base. Let™s begin with table, useful
inventory
an informal inventory of all the features that are available. Boolean
Numeric
known
Boolean things: true, false; expression ;
unknown
cycle
odd numeric ; charexists numeric ;
± 
 boolean 
 numeric  ±
  ± <± 
 
 
 pair   boolean  <=  boolean
   
 numeric     numeric 
     
 
     
=
path
expression ; pair pair ;
    <>  
 string     string 
 
pen

 picture     
  >=  

 

  
  transform transform
 string 
 
  >
transform
not boolean ; boolean and boolean ; boolean or boolean .
Numeric things: tracingtitles, . . . , yoffset (see Chapter 25);
eps, epsilon, infinity; tolerance, join_radius, displaying; constant ;
± lft 
±sqrt ± floor 
 rt 
 
sind
  round 
  
   
    
 top 
    
cosd numeric ; numeric ; numeric ;
hround
mlog  vround   bot 
     
    good.x
     
 
 
mexp ceiling
good.y
±xxpart

xypart  ASCII
xpart pair
; transform ; string ;
oct
yxpart
ypart transform   hex
yypart
normaldeviate; uniformdeviate numeric ; whatever;
angle pair ; turningnumber cycle ; totalweight picture ;
+
numeric
incr
- numeric ; variable ; byte ;
string
decr
constant
+ ++
numeric numeric ; numeric numeric ;
- +-+
*
mod
numeric numeric ; numeric numeric ;
/
div
± 
**
numeric 

 
pair
abs
max
pair dotprod pair ; ( numerics ); ;
length  path 
min  
string
numeric [ numeric , numeric ]; solve function ( numeric , numeric );
directiontime pair of path .
258 Appendix B: Basic Operations


Pair things: left, right, up, down, origin; ( numeric , numeric ); Pair
Path
z su¬x ; dir numeric ; unitvector pair ; round pair ;
±  ±good.lft ±  Pen
lft     Picture
point
   good.rt    String
rt precontrol Transform
pair ; pair ; numeric of path ;
top good.top postcontrol
     
good.bot
bot direction
+
+
- pair ; pair pair ; numeric [ pair , pair ];
-
constant
*
numeric * pair ; pair numeric ; pair transformer ;
/
max
intersectionpoint
path path ; ( pairs );
min
intersectiontimes
penoffset pair of pen ; directionpoint pair of path .

Path things: quartercircle, halfcircle, fullcircle;
unitsquare; flex( pairs ); makepath pen ;
superellipse( pair , pair , pair , pair , numeric );
reverse path ; counterclockwise path ; tensepath path ;
path transformer ; interpath( numeric , path , path );
± 
 
..
 
 
 
 
...
  .. tension ..  ±

±  ± 
 
{ pair }   { pair }  pair 
  
pair .. controls ..
{ curl } { curl } path ;
path     
 
--
 
empty empty cycle
 
 
 
---
 
 
 
 
&
softjoin
subpath pair of path .

Pen things: pencircle, pensquare, penrazor, penspeck;
nullpen; currentpen; makepen path ; pen transformer .

Picture things: nullpicture, blankpicture; unitpixel;
+ +
picture ; picture picture ;
currentpicture;
- -
picture transformer .

String things: "constant"; ditto; jobname; readstring;
str su¬x ; decimal numeric ; char numeric ;
max
string & string ; ( strings ); substring pair of string .
min

Transform things: identity; currenttransform;
inverse transform ; transform transformer .
Appendix B: Basic Operations 259


Transformers: transformed transform ; Transformers
Conditions
scaled Loops
rotated shifted Diagnostic things
numeric ; numeric ; pair ;
xscaled Starting a job
slanted zscaled
yscaled Conversion to pixel units

reflectedabout( pair , pair ); rotatedaround( pair , numeric ).

Conditions:
else: text
if boolean : text {elseif boolean : text } ≥0 fi.
empty

Loops: forever: text endfor;
± 
 
numeric upto numeric
=
for ν numeric downto numeric : text(ν) endfor;
:=  
numeric step numeric until numeric
=
expressions : text( ) endfor;
for
:=
=
forsuffixes σ su¬xes : text(σ) endfor;
:=
exitif boolean ; ; exitunless boolean ; .

Diagnostic things: ???; interact; hide( statements );
loggingall, tracingall, tracingnone.
numeric
Starting a job: \mode= modename ; mag= ;
magstep numeric
screenchars; screenstrokes; imagerules; gfcorners; nodisplays;
notransforms; input ¬lename .

Conversion to pixel units: mode_setup; fix_units;
pixels_per_inch, blacker, fillin, o_correction;
mm#, cm#, pt#, pc#, dd#, cc#, bp#, in#;
mm, cm, pt, pc, dd, cc, bp, in;
mode_def; extra_setup;
± 
define_pixels
 
 
 
 
define_whole_pixels
 
 
 
 
define_whole_vertical_pixels
 
 
 
 
define_good_x_pixels
 
 
define_good_y_pixels
( names ).
 
define_blacker_pixels
 
 
 
 
define_whole_blacker_pixels

define_whole_vertical_blacker_pixels 
 
 
 
 
 
 
define_corrected_pixels
 
define_horizontal_corrected_pixels
260 Appendix B: Basic Operations


Character and font administration: Drawing
Screen display
beginchar( code , width# , height# , depth# ); extra_beginchar; Statements
italcorr numeric# ; change_width; endchar; extra_endchar;
± 
font_size
 
 
 
  ± 
font_slant

 font_normal_space   ligtable ligs/kerns
  
   
   charlist codes 
font_normal_stretch  
=
numeric# ;
:= extensible codes ;
 font_normal_shrink   
   fontdimen info 
empty
   
   
 
font_x_height
 
  headerbytes info
 
 
font_quad
 
font_extra_space
=
font_identifier := string .
font_coding_scheme empty
Drawing: penpos su¬x ( length , angle ); penstroke path(e) ;
pen
; pen number :=savepen; clear_pen_memory;
pickup
saved pen number
pen_lft, pen_rt, pen_top, pen_bot;
± 
 
fill
  draw
unfill drawdot
cycle ; path ; pair ;
undraw
 filldraw 
  undrawdot
cutdraw
unfilldraw
erase picture command ; cutoff( pair , angle );
addto picture variable also picture ;
≥0
contour cycle withpen pen
addto picture variable ;
doublepath path withweight numeric
withweight numeric
keeping
cull picture variable pair .
empty
dropping
Screen display: currentwindow; screen_rows, screen_cols;
openwindow numeric from screen pair to screen pair at pair ;
display picture variable inwindow numeric .
Statements: empty ; string ; begingroup statements endgroup;
± 
± ± ± 
 boolean   ≥1
 boolean    boolean 
 numeric  
 numeric   
  numeric 


 
 
   
 
   
 
   pair 

 
  

    
pair
pair  
   
  
  
path
path = path
; names ;
  :=  
  
pen
pen  
   
pen
 picture  
 picture   

<< . .

. 31
( : 45)



. . >>