Class Cairo.MeshPattern

Inheritance graph
Cairo.Pattern Cairo.MeshPattern
Description

Mesh patterns are tensor-product patch meshes (type 7 shadings in PDF). Mesh patterns may also be used to create other types of shadings that are special cases of tensor-product patch meshes such as Coons patch meshes (type 6 shading in PDF) and Gouraud-shaded triangle meshes (type 4 and 5 shadings in PDF).

Mesh patterns consist of one or more tensor-product patches, which should be defined before using the mesh pattern. Using a mesh pattern with a partially defined patch as source or mask will put the context in an error status with a status of STATUS_INVALID_MESH_CONSTRUCTION.

A tensor-product patch is defined by 4 Bézier curves (side 0, 1, 2, 3) and by 4 additional control points (P0, P1, P2, P3) that provide further control over the patch and complete the definition of the tensor-product patch. The corner C0 is the first point of the patch.

Degenerate sides are permitted so straight lines may be used. A zero length line on one side may be used to create 3 sided patches.


          C1     Side 1       C2
           +---------------+
           |               |
           |  P1       P2  |
           |               |
    Side 0 |               | Side 2
           |               |
           |               |
           |  P0       P3  |
           |               |
           +---------------+
         C0     Side 3        C3
 

Each patch is constructed by first calling begin_patch(), then move_to() to specify the first point in the patch (C0). Then the sides are specified with calls to curve_to() and line_to().

The four additional control points (P0, P1, P2, P3) in a patch can be specified with set_control_point().

At each corner of the patch (C0, C1, C2, C3) a color may be specified with set_corner_color_rgb() or set_corner_color_rgba(). Any corner whose color is not explicitly specified defaults to transparent black.

A Coons patch is a special case of the tensor-product patch where the control points are implicitly defined by the sides of the patch. The default value for any control point not specified is the implicit value for a Coons patch, i.e. if no control points are specified the patch is a Coons patch.

A triangle is a special case of the tensor-product patch where the control points are implicitly defined by the sides of the patch, all the sides are lines and one of them has length 0, i.e. if the patch is specified using just 3 lines, it is a triangle. If the corners connected by the 0-length side have the same color, the patch is a Gouraud-shaded triangle.

Calling end_patch() completes the current patch. If less than 4 sides have been defined, the first missing side is defined as a line from the current point to the first point of the patch (C0) and the other sides are degenerate lines from C0 to C0. The corners between the added sides will all be coincident with C0 of the patch and their color will be set to be the same as the color of C0.

Additional patches may be added with additional calls to begin_patch()/end_patch().


Inherit Pattern

inherit Pattern : Pattern


Method create

Cairo.MeshPattern Cairo.MeshPattern()

Description

Create a new mesh pattern.