home *** CD-ROM | disk | FTP | other *** search
- <TITLE>drawf -- Python library reference</TITLE>
- Next: <A HREF="../r/risclib" TYPE="Next">RiscLib</A>
- Prev: <A HREF="../s/swi" TYPE="Prev">swi</A>
- Up: <A HREF="../r/riscos_only" TYPE="Up">RISCOS ONLY</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H1>13.4. Built-in Module <CODE>drawf</CODE></H1>
- This module provides an interface to the RiscOS drawfile module. It defines
- a new object type that holds a drawfile. The drawf type is a sequence type.
- It is considered as a sequence of objects. Assignment to elements and
- slices, and repetition are not yet implemented.
- <P>
- For more details see the documentation on the draw file format, and the
- DrawFile module.
- <P>
- Errors are reported as exceptions; the usual exceptions are given
- for type, index and value errors, while draw specific errors raise
- <CODE>drawf.error</CODE> as described below.
- <P>
- Module <CODE>drawf</CODE> defines the following data items:
- <P>
- <DL><DT><B>error</B> -- exception of module drawf<DD>
- This exception is raised on draw specific errors
- (e.g., not for illegal argument types). Its
- string value is <CODE>'drawf.error'</CODE>. The accompanying value is a
- string describing the error.
- </DL>
- It defines the following functions:
- <P>
- <DL><DT><B>load</B> (<VAR>filename</VAR>) -- function of module drawf<DD>
- Creates a new drawf object containing the drawfile loaded from the named
- file.
- </DL>
- <DL><DT><B>new</B> () -- function of module drawf<DD>
- Creates a new empty drawf object.
- </DL>
- Drawf objects support the following data items and methods:
- <P>
- <DL><DT><B>size</B> -- data of module drawf<DD>
- Returns the length in bytes of the drawfile.
- </DL>
- <DL><DT><B>box</B> ([<VAR>n</VAR>]) -- function of module drawf<DD>
- Returns the bounding box of object number <VAR>n</VAR>, or of the whole file if no
- <VAR>n</VAR> is given. The result is a tuple of 4 integers.
- </DL>
- <DL><DT><B>find</B> (<VAR>x</VAR>,<VAR>y</VAR> [, <VAR>n</VAR>]) -- function of module drawf<DD>
- Returns the index of the first object in the drawfile whose
- bounding box contains (<VAR>x</VAR>,<VAR>y</VAR>), or the first object after
- object <VAR>n</VAR> if <VAR>n</VAR> is given.
- </DL>
- <DL><DT><B>fonttable</B> (<VAR>fontdict</VAR>) -- function of module drawf<DD>
- Adds a font table object at the end of a diagram. This would normally be called
- for an empty diagram, as there should only be one such object, and it must
- preceed all text objects.
- <VAR>fontdict</VAR> is a dictionary with keys the font number, and values the font
- names.
- </DL>
- <DL><DT><B>group</B> (<VAR>drawf</VAR>) -- function of module drawf<DD>
- Appends the contents of <VAR>drawf</VAR> as a group object.
- </DL>
- <DL><DT><B>path</B> (<VAR>pathdesc</VAR>,<VAR>style</VAR> [, <VAR>dashpattern</VAR> , <VAR>dashstart</VAR>]) -- function of module drawf<DD>
- Adds a path. <VAR>pathdesc</VAR> is a list consisting of integers or pairs of
- integers. The data is that required for a draw path component, except the
- initial move and final end are added automatically.
- The <VAR>style</VAR> is a tuple of 4 integers representing the fill colour,
- outline colour, outline width and path style description.
- <P>
- The <VAR>dashpattern</VAR> is a list of integers representing lengths of
- dash elements. <VAR>dashstart</VAR> is an integer representing the distance into
- the pattern to start, it defaults to zero.
- The dash pattern bit of the style description word is set automatically
- according to the presence of a dash pattern.
- </DL>
- <DL><DT><B>pathcolour</B> (<VAR>colour</VAR> [, <VAR>n</VAR> ...]) -- function of module drawf<DD>
- Sets the colour of paths. If no <VAR>n</VAR> is given all paths in the diagram
- are changed,
- otherwise the <VAR>n</VAR> must be indices of path or group objects. The path
- objects have their colours changed. The group objects are searched recursively
- for paths.
- </DL>
- <DL><DT><B>pathfill</B> (<VAR>colour</VAR> [, <VAR>n</VAR> ...]) -- function of module drawf<DD>
- Sets the fill colour. <VAR>n</VAR> is as for <CODE>pathcolour</CODE>.
- </DL>
- <DL><DT><B>render</B> (<VAR>flags</VAR>,<VAR>trans</VAR>,<VAR>clip</VAR>,<VAR>flat</VAR>) -- function of module drawf<DD>
- Renders the diagram. <VAR>flags</VAR> and <VAR>flat</VAR> are integers.
- <VAR>trans</VAR> is the address of a block of 6 integers.
- <VAR>clip</VAR> is the address of a block of 4 integers.
- See the documentation of SWI DrawFile_Render for details.
- </DL>
- <DL><DT><B>save</B> (<VAR>filename</VAR>) -- function of module drawf<DD>
- Saves the contents as a drawfile with name <VAR>filename</VAR>.
- </DL>
- <DL><DT><B>text</B> (<VAR>point</VAR>, <VAR>text</VAR>, <VAR>style</VAR>) -- function of module drawf<DD>
- Adds a text object. <VAR>point</VAR> is a pair giving the x and y coordinates of
- the start of the text base line.
- <VAR>text</VAR> is the text to print. <VAR>style</VAR> is a tuple of
- 5 integers, the text colour, text background colour hint, font number,
- and x and y sizes of the font. The sizes are in point.
- </DL>
- <DL><DT><B>textbackground</B> (<VAR>colour</VAR> [, <VAR>n</VAR> ...]) -- function of module drawf<DD>
- Sets the text background colour hint. <VAR>n</VAR> is interpreted as for
- <CODE>pathcolour</CODE> but using groups and text objects.
- </DL>
- <DL><DT><B>textcolour</B> (<VAR>colour</VAR> [, <VAR>n</VAR> ...]) -- function of module drawf<DD>
- Sets the text colour. <VAR>n</VAR> is interpreted as for
- <CODE>pathcolour</CODE> but using groups and text objects.
- </DL>
- All distances in group objects are in draw units inch.
- <P>
- Colours are integers of the form <CODE>0xbbggrr00</CODE> or<CODE>-1</CODE> for transparent.
-