home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pyhtmldoc / d / drawf < prev   
Text File  |  1996-11-14  |  6KB  |  110 lines

  1. <TITLE>drawf -- Python library reference</TITLE>
  2. Next: <A HREF="../r/risclib" TYPE="Next">RiscLib</A>  
  3. Prev: <A HREF="../s/swi" TYPE="Prev">swi</A>  
  4. Up: <A HREF="../r/riscos_only" TYPE="Up">RISCOS ONLY</A>  
  5. Top: <A HREF="../t/top" TYPE="Top">Top</A>  
  6. <H1>13.4. Built-in Module <CODE>drawf</CODE></H1>
  7. This module provides an interface to the RiscOS drawfile module. It defines
  8. a new object type that holds a drawfile. The drawf type is a sequence type.
  9. It is considered as a sequence of objects. Assignment to elements and
  10. slices, and repetition are not yet implemented.
  11. <P>
  12. For more details see the documentation on the draw file format, and the
  13. DrawFile module.
  14. <P>
  15. Errors are reported as exceptions; the usual exceptions are given
  16. for type, index and value errors, while draw specific errors raise
  17. <CODE>drawf.error</CODE> as described below.
  18. <P>
  19. Module <CODE>drawf</CODE> defines the following data items:
  20. <P>
  21. <DL><DT><B>error</B> -- exception of module drawf<DD>
  22. This exception is raised on draw specific errors
  23. (e.g., not for illegal argument types).  Its
  24. string value is <CODE>'drawf.error'</CODE>.  The accompanying value is a
  25. string describing the error.
  26. </DL>
  27. It defines the following functions:
  28. <P>
  29. <DL><DT><B>load</B> (<VAR>filename</VAR>) -- function of module drawf<DD>
  30. Creates a new drawf object containing the drawfile loaded from the named
  31. file.
  32. </DL>
  33. <DL><DT><B>new</B> () -- function of module drawf<DD>
  34. Creates a new empty drawf object.
  35. </DL>
  36. Drawf objects support the following data items and methods:
  37. <P>
  38. <DL><DT><B>size</B> -- data of module drawf<DD>
  39. Returns the length in bytes of the drawfile.
  40. </DL>
  41. <DL><DT><B>box</B> ([<VAR>n</VAR>]) -- function of module drawf<DD>
  42. Returns the bounding box of object number <VAR>n</VAR>, or of the whole file if no
  43. <VAR>n</VAR> is given. The result is a tuple of 4 integers.
  44. </DL>
  45. <DL><DT><B>find</B> (<VAR>x</VAR>,<VAR>y</VAR> [, <VAR>n</VAR>]) -- function of module drawf<DD>
  46. Returns the index of the first object in the drawfile whose
  47. bounding box contains (<VAR>x</VAR>,<VAR>y</VAR>), or the first object after
  48. object <VAR>n</VAR> if <VAR>n</VAR> is given.
  49. </DL>
  50. <DL><DT><B>fonttable</B> (<VAR>fontdict</VAR>) -- function of module drawf<DD>
  51. Adds a font table object at the end of a diagram. This would normally be called
  52. for an empty diagram, as there should only be one such object, and it must
  53. preceed all text objects.
  54. <VAR>fontdict</VAR> is a dictionary with keys the font number, and values the font
  55. names.
  56. </DL>
  57. <DL><DT><B>group</B> (<VAR>drawf</VAR>) -- function of module drawf<DD>
  58. Appends the contents of <VAR>drawf</VAR> as a group object.
  59. </DL>
  60. <DL><DT><B>path</B> (<VAR>pathdesc</VAR>,<VAR>style</VAR> [, <VAR>dashpattern</VAR> , <VAR>dashstart</VAR>]) -- function of module drawf<DD>
  61. Adds a path. <VAR>pathdesc</VAR> is a list consisting of integers or pairs of
  62. integers. The data is that required for a draw path component, except the
  63. initial move and final end are added automatically.
  64. The <VAR>style</VAR> is a tuple of 4 integers representing the fill colour,
  65. outline colour, outline width and path style description.
  66. <P>
  67. The <VAR>dashpattern</VAR> is a list of integers representing lengths of 
  68. dash elements. <VAR>dashstart</VAR> is an integer representing the distance into
  69. the pattern to start, it defaults to zero.
  70. The dash pattern bit of the style description word is set automatically
  71. according to the presence of a dash pattern.
  72. </DL>
  73. <DL><DT><B>pathcolour</B> (<VAR>colour</VAR> [, <VAR>n</VAR> ...]) -- function of module drawf<DD>
  74. Sets the colour of paths. If no <VAR>n</VAR> is given all paths in the diagram
  75. are changed,
  76. otherwise the <VAR>n</VAR> must be indices of path or group objects. The path
  77. objects have their colours changed. The group objects are searched recursively
  78. for paths.
  79. </DL>
  80. <DL><DT><B>pathfill</B> (<VAR>colour</VAR> [, <VAR>n</VAR> ...]) -- function of module drawf<DD>
  81. Sets the fill colour. <VAR>n</VAR> is as for <CODE>pathcolour</CODE>.
  82. </DL>
  83. <DL><DT><B>render</B> (<VAR>flags</VAR>,<VAR>trans</VAR>,<VAR>clip</VAR>,<VAR>flat</VAR>) -- function of module drawf<DD>
  84. Renders the diagram. <VAR>flags</VAR> and <VAR>flat</VAR> are integers.
  85. <VAR>trans</VAR> is the address of a block of 6 integers.
  86. <VAR>clip</VAR> is the address of a block of 4 integers.
  87. See the documentation of SWI DrawFile_Render for details.
  88. </DL>
  89. <DL><DT><B>save</B> (<VAR>filename</VAR>) -- function of module drawf<DD>
  90. Saves the contents as a drawfile with name <VAR>filename</VAR>.
  91. </DL>
  92. <DL><DT><B>text</B> (<VAR>point</VAR>, <VAR>text</VAR>, <VAR>style</VAR>) -- function of module drawf<DD>
  93. Adds a text object. <VAR>point</VAR> is a pair giving the x and y coordinates of
  94. the start of the text base line.
  95. <VAR>text</VAR> is the text to print. <VAR>style</VAR> is a tuple of
  96. 5 integers, the text colour, text background colour hint, font number,
  97. and x and y sizes of the font. The sizes are in  point. 
  98. </DL>
  99. <DL><DT><B>textbackground</B> (<VAR>colour</VAR> [, <VAR>n</VAR> ...]) -- function of module drawf<DD>
  100. Sets the text background colour hint. <VAR>n</VAR> is interpreted as for
  101. <CODE>pathcolour</CODE> but using groups and text objects.
  102. </DL>
  103. <DL><DT><B>textcolour</B> (<VAR>colour</VAR> [, <VAR>n</VAR> ...]) -- function of module drawf<DD>
  104. Sets the text colour. <VAR>n</VAR> is interpreted as for
  105. <CODE>pathcolour</CODE> but using groups and text objects.
  106. </DL>
  107. All distances in group objects are in draw units  inch.
  108. <P>
  109. Colours are integers of the form <CODE>0xbbggrr00</CODE> or<CODE>-1</CODE> for transparent.
  110.