Next: RiscLib
Prev: swi
Up: RISCOS ONLY
Top: Top
13.4. Built-in Module drawf
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.
For more details see the documentation on the draw file format, and the
DrawFile module.
Errors are reported as exceptions; the usual exceptions are given
for type, index and value errors, while draw specific errors raise
drawf.error
as described below.
Module drawf
defines the following data items:
- error -- exception of module drawf
-
This exception is raised on draw specific errors
(e.g., not for illegal argument types). Its
string value is
'drawf.error'
. The accompanying value is a
string describing the error.
It defines the following functions:
- load (filename) -- function of module drawf
-
Creates a new drawf object containing the drawfile loaded from the named
file.
- new () -- function of module drawf
-
Creates a new empty drawf object.
Drawf objects support the following data items and methods:
- size -- data of module drawf
-
Returns the length in bytes of the drawfile.
- box ([n]) -- function of module drawf
-
Returns the bounding box of object number n, or of the whole file if no
n is given. The result is a tuple of 4 integers.
- find (x,y [, n]) -- function of module drawf
-
Returns the index of the first object in the drawfile whose
bounding box contains (x,y), or the first object after
object n if n is given.
- fonttable (fontdict) -- function of module drawf
-
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.
fontdict is a dictionary with keys the font number, and values the font
names.
- group (drawf) -- function of module drawf
-
Appends the contents of drawf as a group object.
- path (pathdesc,style [, dashpattern , dashstart]) -- function of module drawf
-
Adds a path. pathdesc 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 style is a tuple of 4 integers representing the fill colour,
outline colour, outline width and path style description.
The dashpattern is a list of integers representing lengths of
dash elements. dashstart 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.
- pathcolour (colour [, n ...]) -- function of module drawf
-
Sets the colour of paths. If no n is given all paths in the diagram
are changed,
otherwise the n must be indices of path or group objects. The path
objects have their colours changed. The group objects are searched recursively
for paths.
- pathfill (colour [, n ...]) -- function of module drawf
-
Sets the fill colour. n is as for
pathcolour
.
- render (flags,trans,clip,flat) -- function of module drawf
-
Renders the diagram. flags and flat are integers.
trans is the address of a block of 6 integers.
clip is the address of a block of 4 integers.
See the documentation of SWI DrawFile_Render for details.
- save (filename) -- function of module drawf
-
Saves the contents as a drawfile with name filename.
- text (point, text, style) -- function of module drawf
-
Adds a text object. point is a pair giving the x and y coordinates of
the start of the text base line.
text is the text to print. style 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.
- textbackground (colour [, n ...]) -- function of module drawf
-
Sets the text background colour hint. n is interpreted as for
pathcolour
but using groups and text objects.
- textcolour (colour [, n ...]) -- function of module drawf
-
Sets the text colour. n is interpreted as for
pathcolour
but using groups and text objects.
All distances in group objects are in draw units inch.
Colours are integers of the form 0xbbggrr00
or-1
for transparent.