The classes pattern and canvas differ only in their constructor and in the absence of a writeEPSfile() method in the former. The pattern constructor accepts the following keyword arguments:
| keyword | |
| painttype | 1 (default) for coloured patterns or 2 for uncoloured patterns |
| tilingtype | 1 (default) for constant spacing tilings (patterns are spaced constantly by a multiple of a device pixel), 2 for undistorted pattern cell, whereby the spacing may vary by as much as one device pixel, or 3 for constant spacing and faster tiling which behaves as tiling type 1 but with additional distortion allowed to permit a more efficient implementation. |
| xstep | horizontal spacing between pattern cells, use None (default) for automatic calculation from pattern bounding box. |
| ystep | vertical spacing between pattern cells, use None (default) for automatic calculation from pattern bounding box. |
| bbox | box of pattern. Use None for an
automatic determination of the bounding box (including an
enlargement by |
| trafo | transformation applied to pattern or None (default). This may be used to rotate the pattern or to shift its phase (by a translation). |
After you have created a pattern instance, you define the pattern shape by drawing in it like in an ordinary canvas. To use the pattern, you simply pass the pattern instance to a stroke(), fill(), draw() or set() method of the canvas, just like you would do with a colour, etc.