1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
.. module:: pattern
*********************
Module :mod:`pattern`
*********************
.. sectionauthor:: Jörg Lehmann <joerg@pyx-project.org>
This module contains the :class:`pattern.pattern` class, which allows the definition of
PostScript Tiling patterns (cf. Sect. 4.9 of the PostScript Language Reference
Manual) which may then be used to fill paths. In addition, a number of
predefined hatch patterns are included.
Class :class:`pattern`
======================
The classes :class:`pattern.pattern` and :class:`canvas.canvas` differ only in their
constructor and in the absence of a :meth:`writeEPSfile` method in the former.
The :class:`pattern` constructor accepts the following keyword arguments:
+-----------------+-----------------------------------------------+
| keyword | description |
+=================+===============================================+
| ``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`` | desired horizontal spacing between pattern |
| | cells, use ``None`` (default) for automatic |
| | calculation from pattern bounding box. |
+-----------------+-----------------------------------------------+
| ``ystep`` | desired vertical spacing between pattern |
| | cells, use ``None`` (default) for automatic |
| | calculation from pattern bounding box. |
+-----------------+-----------------------------------------------+
| ``bbox`` | bounding box of pattern. Use ``None`` for an |
| | automatic determination of the bounding box |
| | (including an enlargement by ``bboxenlarge`` |
| | pts on each side.) |
+-----------------+-----------------------------------------------+
| ``trafo`` | additional transformation applied to pattern |
| | or ``None`` (default). This may be used to |
| | rotate the pattern or to shift its phase (by |
| | a translation). |
+-----------------+-----------------------------------------------+
| ``bboxenlarge`` | enlargement when using the automatic bounding |
| | box determination; default is 5 pts. |
+-----------------+-----------------------------------------------+
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 :meth:`stroke`, :meth:`fill`, :meth:`draw` or
:meth:`set` method of the canvas, just like you would do with a colour, etc.
|