Showing changes from revision #4 to #5:
Added | Removed | Changed
Great care must be taken when using the SWIs provided by the Draw Module?Draw module because four different units of measurement are used.
The transformation matrix is the method used to perform numerous functions on lines, such as scaling, rotating and transforming. It consists of a three by three array. A full explanation of how it is used can be found here.
The winding rule is used by the Draw module to determine which pixels are interior or exterior, that is, which pixels should be filled.
Four different methods of determining this are provided.
Even-Odd | Specifies that an area should be filled if it is enclosed by an even number of subpaths. This results in an area never having two adjacent areas of the same state. i.e filled or unfilled |
Non-Zero | Determines whether an area should be filled based on the direction of the surrounding subpaths were constructed. If an equal number of subpaths in each direction surround the area, then the area is not filled, otherwise it is |
Positive | Fill an area if it is surrounded by more anti-clockwise subpaths than clockwise |
Negative | Fill an area if it is surrounded by more clockwise subpaths than anti-clockwise |
Note: The even-odd and non-zero winding rules are printer driver compatible, whereas the positive and negative are not.
Flattening is the process of converting a Bezier curve into a series of lines within a specified distance of the curve. The flatness is the term used to specify how closely the outputted lines will resemble the original Bezier curve.
The shorter the distance of line, the more accurate resemblance to the original Bezier curve. A longer line will hence, result in a less accurate approximation.
All moving and drawing is relative to the VDU graphics origin. None of the Draw SWIs will plot outside the boundaries of the VDU graphics window. All calls use the colour (both pixel pattern and dash pattern) set up for the VDU driver. Note that not all such colours are compatible with printer drivers.
The path is a sequence of subpaths, each of which is a sequence of elements. Each element is from one to seven words in length. The lower byte of the first word specifies the element type and the remaining three bytes are free for use. On output to an input path, the Draw module will leave the three bytes unchanged, but if output to an output path, the three bytes will store zeros. A table showing the path structure is available here.
When stroking, if a subpath ends with a 4 or 5 then it is closed and the ends are joined.
If the subpath is a 2 or a 3, then it leaves the subpath open, and the loose ends are capped. These four path elements explicitly leave a stroked subpath open or closed.
If must be noted, that some operations close open subpaths. This, however, will be stated in the descriptions.
In addition, just because the ends of a subpath have the same co-ordinates does not mean that the subpath is closed.
Certain SWIs has the ability to output to an output rather than to the screen. After a path has been written to an output path, it is identical to an input path. When the output path is first passed to a SWI as a parameter, the start of the block should contain an element type zero, followed by the number of available bytes. This is to ensure that it will not accidently overrun the buffer.
Flattening is the process of converting a Bezier curve into a series of straight lines when outputting. Flatness is used to specify how closely the outputted lines will resemble the original Bezier curve. The flatness is the maximum distance that a line is allowed to be from a Bezier curve when flattening it.
To ensure a good approximation of the Bezier curve, it is recommended that the flatness value is between 0.5 and 1.0 pixel. Any less is unnoticeable, but any more and the curve becomes noticeably jaggy.
An easy way to calculate the flatness value is:
flatness = number of user units in x axis / number of pixels in x axis
A value of zero specifies the default flatness value, which provides a good balance between speed and accuracy (using default scaling).
If outputting a path to a high resolution printer instead of a screen, it is advisable to use a smaller flatness value, that results in a more accurate representation of the curve.
The thickness of the line is specified in user co-ordinates rather than OS units or Draw’ own internal co-ordinate system. The following points must be noted when specifying the thickness.
Cap and join styles specify how the cap and joins are displayed. Joins can be mitred, round or bevelled. Whereas caps can be butted, round, square or triangular.
More information on Cap and Join styles can be found here.
The dash pattern as the name suggests, specifies the pattern of dashes used to represent a given line.
More information on the dash pattern is provided here.
Draw uses fixed point arithmetic for speed, rather than floating point.
The SWIs used by the Draw module all use integer numbers, however, SWI names and numbers have been allocated to support future versions that support Floating Point. To use the floating point versions, the suffix ‘FP’ needs to be appended to the current SWI name.
The Floating Point numbers used in the specification are IEEE single precision floating point numbers.
Note: Not yet implemented and if used will result in an error if called.
If printing, it is important to note that not all features are compatible. As a general rule, the following features should be avoided: