summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMenner <mik@gmx.org>2015-07-02 19:30:00 -0500
committerFederico Mena Quintero <federico@gnome.org>2015-07-02 19:30:00 -0500
commit99805d95a0459190d60339540f0fa6824d266435 (patch)
tree949227c62ac506e6e69646d68b4c51c6255419fc
parent1ef73bd08cdfc920cf3db6f06d517dac56de1221 (diff)
downloadlibrsvg-99805d95a0459190d60339540f0fa6824d266435.tar.gz
bgo#476507 - Marker endpoints have the wrong angle
If a curveto has coincident control points at the start or end, then the angle of the marker at that endpoint is not computed correctly. This uses the next or previous control points as appropriate to compute the correct angle.
-rw-r--r--rsvg-marker.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/rsvg-marker.c b/rsvg-marker.c
index bd289e58..a26d7bdf 100644
--- a/rsvg-marker.c
+++ b/rsvg-marker.c
@@ -276,10 +276,18 @@ rsvg_render_markers (RsvgDrawingCtx * ctx,
code == CAIRO_PATH_CLOSE_PATH) {
if (endmarker) {
if (code == CAIRO_PATH_CURVE_TO) {
- rsvg_marker_render (endmarker, x, y,
- atan2 (y - data[2].point.y,
- x - data[2].point.x),
- linewidth, ctx);
+ if (data[2].point.x == x && data[2].point.y == y) {
+ /* Can't calculate angle as points are coincident; use the previous point */
+ rsvg_marker_render (endmarker, x, y,
+ atan2 (y - data[1].point.y,
+ x - data[1].point.x),
+ linewidth, ctx);
+ } else {
+ rsvg_marker_render (endmarker, x, y,
+ atan2 (y - data[2].point.y,
+ x - data[2].point.x),
+ linewidth, ctx);
+ }
} else {
rsvg_marker_render (endmarker, x, y,
atan2 (y - lasty, x - lastx),
@@ -290,11 +298,20 @@ rsvg_render_markers (RsvgDrawingCtx * ctx,
code == CAIRO_PATH_CLOSE_PATH) {
if (startmarker) {
if (nextcode == CAIRO_PATH_CURVE_TO) {
- rsvg_marker_render (startmarker, x, y,
- atan2 (nextdata[1].point.y - y,
- nextdata[1].point.x - x),
- linewidth,
- ctx);
+ if (nextdata[1].point.x == x && nextdata[1].point.y == y) {
+ /* Can't calculate angle as points are coincident; use the next point */
+ rsvg_marker_render (startmarker, x, y,
+ atan2 (nextdata[2].point.y - y,
+ nextdata[2].point.x - x),
+ linewidth,
+ ctx);
+ } else {
+ rsvg_marker_render (startmarker, x, y,
+ atan2 (nextdata[1].point.y - y,
+ nextdata[1].point.x - x),
+ linewidth,
+ ctx);
+ }
} else {
rsvg_marker_render (startmarker, x, y,
atan2 (nextp.point.y - y, nextp.point.x - x),