Hello,

It seems that the pdf and ps backends draw the quadratic bezier line
incorrectly.
Here is a little test script.


# -- begin test script --
import matplotlib.pyplot as plt
import matplotlib
from matplotlib.path import Path
from matplotlib.patches import PathPatch

plt.clf()
ax = plt.gca()
ax.set_aspect(1.)
pp1 = PathPatch(Path([(0, 0), (1, 0), (1, 1), (0, 0)], [1, 3, 3, 5]), fc="none",
                transform=ax.transData)

ax.add_patch(pp1)
ax.plot([0.75], [0.25], "ro")

plt.draw()
plt.savefig("test_quad_bezier_%s" % (matplotlib.get_backend()))

# -- end --


I'm attaching the result for the pdf backend. The lower-right
(quadratic bezier) path is supposed to path through the red dot.
The agg backends are fine, and so is the svg backend. I haven't tested
with others.
I tracked down this to an incorrect conversion of quadratic bezier
curve to cubic one.
Given (q0, q1, q2) as control points of quadratic one, these backends
simply produce a cubic one with (q0, q1, q1, q2) as its control
points, which is not correct (see
http://fontforge.sourceforge.net/bezier.html for example).

I'm attaching a patch (for pdf and ps backends) which I believe
correctly handle this.
I hope this patch is reviewed and applied. Note that the function
_quad2cubic is duplicated in both backends. This function might be
moved to some common place.

Regards,

-JJ

Attachment: test_quad_bezier_pdf.pdf
Description: Adobe PDF document

Attachment: bezier_pdf_ps.diff
Description: Binary data

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to