home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / utilities / utilsm / mkdrawf / Doc / TutorialT < prev   
Text File  |  1995-04-28  |  20KB  |  470 lines

  1. [[ Note: This text-only version of the tutorial was produced by hand from
  2.    the Impression version. It is therefore likely that there are lots of
  3.    infelicities in the formatting; in particular, font changes have been
  4.    lost. If a sentence doesn’t seem to make any sense, see whether it’s
  5.    any better if you pretend some of the words in it are in italics. :-) ]]
  6.  
  7.  
  8. A mkdrawf tutorial
  9. ==================
  10.  
  11. This is a fairly gentle introduction to mkdrawf, a program for creating drawfiles. If you don’t know what a drawfile is, don’t worry: you will soon. If you don’t know what a program is, perhaps you should read some other tutorials first.
  12. In fact, even if that’s the case you can probably get a fair way into this
  13. tutorial, since most of it consists of instructions saying “Put this into a
  14. file and do that with it, and see what happens”.
  15.  
  16. When you’ve worked through this tutorial, you should find most of the manual pretty easy going. Actually most of the manual is easy going anyway, but it
  17. suffers a bit from being intended as a reference as well as a tutorial; this
  18. document has no such ambitions, and is unashamedly incomplete; it even
  19. contains a few (minor) lies. If it disagrees with the manual, you know which
  20. to trust.
  21.  
  22.  
  23. Running mkdrawf
  24. ---------------
  25.  
  26. mkdrawf manufactures drawfiles out of ordinary text files. There are two ways
  27. to use it. Firstly, you can run it from the command line: entering a command
  28. like
  29.  
  30.   mkdrawf textfile drawfile
  31.  
  32. will process the file textfile and produce an output file drawfile. Secondly,
  33. you can use the Wimp application !Drawf, which allows you to drag a text file
  34. to its icon, whereupon it will run that file through mkdrawf and allow you to
  35. drag the resulting drawfile somewhere to save it. The icon for !Drawf looks
  36. like this: <<sorry...>>  .
  37.  
  38.  
  39.  
  40. (As you might guess from the look of the icon, !Drawf will also decode
  41. drawfiles for you, producing output suitable for handing to mkdrawf again.
  42. There is a separate manual for !Drawf which will tell you all about this, and
  43. more besides.)
  44.  
  45. From now on, I shall assume that you can do one of these two things. When I say “run mkdrawf on this file”, this means: either choose an output filename and
  46. use the command-line, or else drag the file to the !Drawf icon and put the
  47. resulting output somewhere.
  48.  
  49.  
  50. Running !Draw
  51. -------------
  52.  
  53. The easiest way to see the results of using mkdrawf is to view the files it
  54. produces using !Draw. This program comes with every Archimedes or Risc PC, so
  55. you should definitely have a copy; you can probably find it by clicking on an
  56. icon labelled Apps at the left-hand side of your icon bar.
  57.  
  58. If you haven’t used !Draw before, the first thing you should do is to run it
  59. and play around with it for a while. This should give you an idea of the sort
  60. of thing it can do.
  61.  
  62. A drawfile is a file which !Draw can understand. A drawfile consists
  63. basically of a number of objects (lines, curves, bits of text, that sort of
  64. thing) strung together. In some cases (have you used the Group option on the
  65. menu?) an object can contain a number of other objects. As this tutorial
  66. proceeds, you will learn rather more about drawfiles than you actually want
  67. to know.
  68.  
  69. Every time you run mkdrawf you should have a look at the output by either
  70. double-clicking on the file it produces (after dragging it to a directory
  71. display, if you are using !Drawf) or dragging the file to !Draw’s icon on the
  72. icon bar. (Not quite every time; if something goes wrong and you get lots of
  73. error messages, the resulting drawfile may be full of rubbish, or at any rate
  74. not full of what you wanted.)
  75.  
  76.  
  77. A very simple example
  78. ---------------------
  79.  
  80. Put the following into a file using your favourite text editor, run it
  81. through mkdrawf, and look at the result using !Draw:
  82.  
  83.   # This is a comment; mkdrawf will ignore it.
  84.   Path {
  85.     Move 100 100
  86.     Line 300 200
  87.   }
  88.  
  89. You can probably guess what the result of this will be before you try it.
  90. Your guess will almost certainly be correct. This simple example actually
  91. demonstrates quite a few things about mkdrawf, though… The first line is
  92. self-explanatory. The remaining lines describe a single object. An object is
  93. introduced by saying what sort of object it is; in this case, it is a path
  94. object. (The typical drawfile consists mostly of path objects.) Further
  95. details about the object are given within those braces {}; in this case, the
  96. path consists of a single line segment from (100,100) to (300,200).
  97. Coordinates are always given, as in this example, as pairs of numbers. The
  98. unit, by the way, is the point; the ambiguity here is unfortunate but seldom
  99. causes trouble in practice. A point is 1/72 of an inch; the spacing between
  100. vertical lines here  is about 10 points.
  101.  
  102.  
  103. A slightly less simple example
  104. ------------------------------
  105.  
  106. As I already said, a drawfile typically contains several objects, one after
  107. another. This structure is represented in the obvious way in input to
  108. mkdrawf; namely, by putting one object description after another. Here’s an
  109. example, which (as usual) you should try.
  110.  
  111.   Path {
  112.     Move 100 100
  113.     Line 150 100
  114.   }
  115.   Path {
  116.     FillColour r220g0b0
  117.     Move 200 200
  118.     Line 300 200
  119.     Line 300 300
  120.     Close
  121.   }
  122.   Text {
  123.     Style Font "Trinity.Medium"
  124.     StartAt 200 300
  125.     Size 10 10
  126.     Text "Hello!"
  127.   }
  128.  
  129. This produces a drawfile containing three objects: two path objects and a
  130. text object. You can probably make a pretty good guess as to what this will
  131. look like, if I tell you that:
  132.  
  133.   • colours are given as RGB values, each component going from 0 (dark) to
  134.     255 (bright);
  135.   • Size 10 10 means “I want a 10-point font”;
  136.   • Trinity is the typeface in which this tutorial is printed.
  137.  
  138.  
  139. An easy exercise
  140. ----------------
  141.  
  142. Write a mkdrawf file which, when fed into mkdrawf and !Draw, produces the
  143. following picture. <<Sorry, again.>> You are not expected, of course, to
  144. produce the grid lines and the numbers labelling them (though you might be
  145. able to do something approximating to them), and you should not worry about
  146. the thicknesses of the lines. The grey colour inside the square is
  147. r119g119b119, I think; and the text is 20-point Trinity.Medium.Italic. When
  148. you’ve done this, check it (of course you won’t be able to check the scale)
  149. by running it through mkdrawf and !Draw.
  150.  
  151.  
  152. More about path objects
  153. -----------------------
  154.  
  155. You may have guessed from the previous picture (or you may have noticed while
  156. using !Draw) that all sorts of things we haven’t discussed yet are possible
  157. with path objects; for instance, the picture includes dashed lines, lines in
  158. colours other than black, and lines of different thicknesses. And there’s
  159. plenty more. Anyway, here is a mkdrawf file demonstrating some more features
  160. of path objects:
  161.  
  162.  Path {
  163.     Width 2        # all dimensions, including this, are in points
  164.     OutlineColour r0g0b255    # blue lines
  165.     Style { EndCap Triangular }    # !Draw will show you what this means
  166.     Move 100 100
  167.     Line 200 100
  168.     Curve  300 100  200 200  200 300    # a Bezier curve, ending at (200,300)
  169.     Line 200 400
  170.     Move 200 100        # a path can be made up of many subpaths
  171.     Line 200 300
  172.   }
  173.  
  174. What’s new here? The Width keyword allows you to say how thick you want a
  175. line to be. The width is, like all dimensions, given in points (1/72"). It’s
  176. a “diameter” rather than a “radius”. The Style keyword should be followed by
  177. some stuff in braces; there are several other things you can set in there.
  178. The OutlineColour keyword (so called in contrast to FillColour) determines
  179. the colour of lines and curves, as distinct from the filled-in space inside
  180. them. By the way, the usual 16-colour desktop palette doesn’t include a
  181. colour accurately matching r0g0b255, but !Draw will happily display the best
  182. approximation it can, and won’t throw away its information about exactly what
  183. colour you really wanted.
  184.  
  185. The line beginning Curve is more interesting. As well as straight lines, a
  186. path object can contain Bezier curves. A Bezier curve is described by giving
  187. its starting and ending points — in this case (200,100) and (200,300) — and
  188. two control points — in this case (300,100) and (200,200). The curve starts
  189. out from its starting point, heading towards its first control point