[cairo] Horizontal artifacts rendering to an image surface
Floyd May
FMay at sstsoftware.com
Fri Jul 27 14:20:42 PDT 2012
I've been able to boil this down to a reproducible, small case.
Basically, two four-point polygons where one edge from each is
collinear. Using even-odd rendering, I'm getting these artifacts:
http://imagebin.org/222354
Again, this is based on v 1.10.2, on Windows (both x86 and x64 exhibit
the issue), based on a recent download of GTK+ binaries.
Here is C# source (using Mono.Cairo; should be able to adapt to C code
relatively easily):
class Program
{
static void Main(string[] args)
{
var records = new Cairo.PointD[][]{
new Cairo.PointD[]{
new Cairo.PointD(448.948314981535,
264.938083162531),
new Cairo.PointD(448.51546072308, 220.797386273742),
new Cairo.PointD(530, 220),
new Cairo.PointD(561.332719124854,
261.581040261313),
},
new Cairo.PointD[]{
new Cairo.PointD(339.794010419399,
236.296868257225),
new Cairo.PointD(346.503195904195,
229.764422696084),
new Cairo.PointD(448.474225856364,
216.590856667608),
new Cairo.PointD(448.948314981535, 264.938083162531)
},
};
using (var surface = new
Cairo.ImageSurface(Cairo.Format.Argb32, 1024, 1024))
{
using (var ctx = new Cairo.Context(surface))
{
ctx.FillRule = Cairo.FillRule.EvenOdd;
foreach (var ring in records)
{
ctx.MoveTo(ring.First());
foreach (var pt in ring.Skip(1))
{
ctx.LineTo(pt);
}
ctx.ClosePath();
}
ctx.SetSourceColor(0, 0.5, 1);
ctx.FillPreserve();
ctx.SetSourceColor(0, 0, 0);
ctx.Stroke();
}
surface.Flush();
surface.WriteToPng("image.png");
}
}
}
More information about the cairo
mailing list