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