[cairo] Coloring problem with mesh patterns

Andrea Canciani ranma42 at gmail.com
Fri Jun 24 02:53:05 PDT 2011

On Fri, Jun 24, 2011 at 10:50 AM, Maximilian Heinzler <maxi at heinzler.de> wrote:
> I think there is a bug with the coloring of a mesh pattern. There is a
> source file attached shows this problem.

The source you attached shows the expected behavior.
Please try the attached source and open the generated mesh.pdf in Adobe
Reader or a similar "trusted" pdf viewer (Poppler and Apple Preview do not
render that file correctly) to verify this.

> I'm very sure that the green and blue zone should more look like the two
> others.

No, the rendering is correct. Please check again the PDF specification
section Type 6 Shadings (Coons Patch Meshes):
Patches can sometimes appear to fold over on themselves—for example,
if a boundary curve intersects itself. As the value of parameter u or
v increases in parameter space, the location of the corresponding
pixels in device space may change direction so that new pixels are
mapped onto previous pixels already mapped. If more than one point (u,
v) in parameter space is mapped to the same point in device space, the
point selected shall be the one with the largest value of v. If
multiple points have the same v, the one with the largest value of u
shall be selected. If one patch overlaps another, the patch that
appears later in the data stream shall paint over the earlier one.

The same is explained in the cairo documentation for meshes:

> One other question:
> In the resulting mesh.png you can see the path of the mesh colored in
> black. Is it correct that the painted area lies partially outside of
> this path?

Yes, that is correct. As explained in the PDF specification, the mesh
patches can go outside the patch boundary, depending on the patch
control points.
See Figure 29 – Painted Area and Boundary of a Coons Patch at
page 195 of PDF 32000-1:2008.

> Anyway a very cool new feature!

Good to know that people is interested in it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mesh-pattern.c
Type: text/x-csrc
Size: 1436 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20110624/34c18797/attachment.c>

More information about the cairo mailing list