The Drawfile Module

Home David Projects The Drawfile Module
Updated: 2010-01-15


The Drawfile format is a file format for storing vector graphics created using the Draw application on RISC OS systems. As the standard file format for vector graphics on the RISC OS platform it has enjoyed support from both users and from developers, although only with the creation of the Drawfile module has the format become accessible to applications made by smaller development organisations. The simplicity of the Draw application and its competitors, such as Drawplus and Vector, has inspired a large amount of freely available clip art despite the restrictions the format places on the complexity of drawings which can be created.

Available libraries and tools

The drawfile module

This Python module was written to ensure that many of the diagrams and illustrations I required for my thesis would be portable to platforms other than RISC OS in the case that I should encounter problems with my workstation. The module contains classes which encapsulate the standard objects present in Drawfiles and allow them to be individually read, modified and written back to Drawfiles, providing varying degrees of abstraction over the underlying data. For example, the path object will contain information on the line and fill styles of a path, and maintains a list of the path operations, but does not provide a convenient interface for adding or removing points to or from a path. This approach works quite well for the text_area object which will construct a list of text formatting commands and arguments to assist applications in recreating visual representations of text areas.

Since Drawfiles may contain images in the form of sprites, embedded as single image Spritefiles within sprite objects, the drawfile module will attempt to import the spritefile module on initialisation, although this is not really necessary if the lazy flag is passed to drawfile objects on initialisation. This flag is used by sprite objects to determine whether the embedded Spritefiles they contain should be decoded when read, and encoded when written.

The module supports the following Drawfile objects:

The drawinput filter for Sketch

A description of this filter is available on the Sketch Plugins and Tools page.


The drawfile module and the tool.