tmac.pictures 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. .de PI \" Picture Include
  2. . \" $1=file(page) $2=height,width,yoff,xoff $3=flags
  3. . \" Height, width, xoff, and yoff are for the frame, flags is for the
  4. . \" picture. Default dimensions are inches.
  5. \\X'PI:\\n(.o:\\n(.i:\\n(.l:\\n(.t:\\$1:\\$2:\\$3:'\\c
  6. ..
  7. .nr FT 0
  8. .de BP \" Begin a Picture
  9. . \"
  10. . \" $1=file(page) $2=height $3=width $4=position $5=offset $6=flags $7=label
  11. . \"
  12. . \" Height, width, position, and offset are for the frame, flags is for
  13. . \" the picture. The postion flag should be l, c, r, or "". Omitting the
  14. . \" position argument is also allowed for compatibility with the original
  15. . \" version of the macro. In that case offset is taken relative to your
  16. . \" left margin.
  17. .if \\n(FT>1 .EP
  18. . \" Need these when we switch environments.
  19. .nr Ov \\n(.v
  20. .nr Oi \\n(.i
  21. .nr Ol \\n(.l
  22. . \" Remember the arguments - sometimes as both a string and number register.
  23. .nr $2 \\$2i
  24. .nr $3 \\$3i
  25. .nr $4 \\$4i
  26. .ds $4 \\$4
  27. .nr $5 \\$5i
  28. .ds $5 \\$6
  29. .ds $6 \\$7
  30. . \" Accept a few unadvertised position flags.
  31. .if '\\*($4'L' .ds $4 l
  32. .if '\\*($4'C' .ds $4 c
  33. .if '\\*($4'R' .ds $4 r
  34. . \" A null with more than three arguments means l.
  35. .if \\n(.$>3 .if '\\*($4'' .ds $4 l
  36. . \" Default frame dimensions if missing, zero, or null.
  37. .if !\\n($2>0 .nr $2 3.0i
  38. .if !\\n($3>0 .nr $3 \\n(.lu-\\n(.iu-\\n($4u
  39. .if !\\n($3>0 .nr $3 \\n($2u
  40. . \" Figure out the offset that will be used the rest of the way.
  41. .if '\\*($4'l' .nr $4 \\n($5u
  42. .if '\\*($4'c' .nr $4 (\\n(.lu-\\n(.iu-\\n($3u)/2u+\\n($5u
  43. .if '\\*($4'r' .nr $4 \\n(.lu-\\n(.iu-\\n($3u+\\n($5u
  44. . \" If we haven't recognized the position flag assume it wasn't given and
  45. . \" treat argument four as an offset from the left.
  46. .if !'\\*($4'l' .if !'\\*($4'c' .if !'\\*($4'r' .ds $5 \\$5
  47. .if !'\\*($4'l' .if !'\\*($4'c' .if !'\\*($4'r' .ds $6 \\$6
  48. . \" Set increments for line length and indent.
  49. .nr Ii \\n($3u+\\n($4u+.1i
  50. .nr Il \\n(.lu-\\n(.iu-\\n($4u+.1i
  51. . \" Set the frame type to one of:
  52. . \" 0 - frame is as wide as a line of text - skip over it.
  53. . \" 1 - fits in left or right margins
  54. . \" 2 - fill with text on the right
  55. . \" 3 - on the left
  56. . \" 4 - or on both sides of the frame
  57. . \" 5 - only set in EP if FT was 4 and now filling on the right.
  58. . \" Assume the frame is as wide as a line of text, then check dimensions
  59. . \" to see what's really true. The order of these tests is important!
  60. .nr FT 0
  61. .if \\n($4u>1.0i .nr FT 3
  62. .if \\n($4u+\\n(.iu>=\\n(.lu .nr FT 1
  63. .if \\n($3u+\\n($4u+\\n(.iu+1.0i<\\n(.lu .nr FT 2
  64. .if \\n($3u+\\n($4u<=0 .nr FT 1
  65. .if \\n(FT=2 .if \\n($4u>1.0i .nr FT 4
  66. . \" Ask for some vertical space - labeled pictures need a little extra,
  67. . \" margin pictures a little less.
  68. .if \\n(FT=1 .if '\\*($6'' .ne \\n($2u
  69. .if \\n(FT=1 .if !'\\*($6'' .ne \\n($2u+2v
  70. .if !\\n(FT=1 .if '\\*($6'' .ne \\n($2u+3v
  71. .if !\\n(FT=1 .if !'\\*($6'' .ne \\n($2u+5v
  72. . \" Save our place, draw the picture, label it, and return. Need precise
  73. . \" control of when \X'...' is put out - thus the new environment.
  74. .mk Oh
  75. .ev 1
  76. .in \\n(Oiu
  77. .ll \\n(Olu
  78. .vs \\n(Ovu
  79. .if \\n(FT=1 .sp -1v
  80. .if \\n(FT=1 .PI \\$1 \\n($2u,\\n($3u,\\n(.vu,\\n($4u t\\*($5
  81. .if !\\n(FT=1 .PI \\$1 \\n($2u,\\n($3u,\\n(.vu,\\n($4u \\*($5
  82. .in
  83. .ll
  84. .vs
  85. .ev
  86. .lt \\n($3u
  87. .tl \(ts\(ts\\h'\\n($4u+\\n(.iu'\\v'\\n($2u+1.5v'\\*($6\\v'-\\n($2u-1.5v'\\h'-\\n($4u-\\n(.iu'\(ts\(ts
  88. .lt
  89. 'sp |\\n(Ohu
  90. . \" Figure out what to do with the text that follows.
  91. .if !'\\*($6'' .nr $2 +2v
  92. .if \\n(FT=0 .sp \\n($2u+2v
  93. .if \\n(FT=1 .nr FT 0
  94. .if \\n(FT=2 'in +\\n(Iiu
  95. .if \\n(FT>2 .ll -\\n(Ilu
  96. .if \\n(FT>1 .di BB
  97. .if \\n(FT>1 .dt \\n($2u+2v+1u EP
  98. . \" Clean things up.
  99. .rr $2
  100. .rr $3
  101. .rr $4
  102. .rm $4
  103. .rr $5
  104. .rm $5
  105. .rm $6
  106. .rr Oh
  107. .rr Oi
  108. .rr Ol
  109. .rr Ov
  110. .if \\n(FT=0 .EP
  111. ..
  112. .de EP \" End the Picture - Normally called from a trap, although it can be used
  113. . \" on its own to mark the end of a picture.
  114. .nr Ot 0
  115. .if \\n(.tu<\\n(.pu .nr Ot \\n(.tu
  116. .if \\n(Ot>0 .if \\n(FT=4 .nr FT 3
  117. .if \\n(FT<2 .nr Ot 0
  118. .if \\n(Ot>0 .br
  119. .if \\n(FT=5 .nr Ot 0
  120. .if \\n(FT>1 \{\
  121. . ev 1
  122. . eo
  123. . br
  124. . di
  125. . nf
  126. . in 0
  127. . BB
  128. . in
  129. . fi
  130. . ec
  131. . ev
  132. . rm BB\}
  133. .if \\n(FT=5 \{\
  134. . nr FT 2
  135. ' sp |\\n(Nhu+1v\}
  136. .if \\n(FT=4 \{\
  137. . mk Nh
  138. . nr Nh -1v
  139. . nr FT 5
  140. ' sp -\\n(dnu+1v
  141. ' in +\\n(Iiu
  142. . ll +\\n(Ilu
  143. . di BB
  144. . dt \\n(dnu-2v+1u EP\}
  145. .if \\n(FT=2 'in -\\n(Iiu
  146. .if \\n(FT=3 .ll +\\n(Ilu
  147. .if \\n(FT<4 .nr FT 0
  148. .if \\n(Ot>0 .sp \\n(Otu
  149. .rr Ot
  150. .if \\n(FT=0 \{\
  151. . rr Nh
  152. . rr Ii
  153. . rr Il\}
  154. ..