typedef struct arrowtype_t {
int type;
double lenfact; /* ratio of length of this arrow type to standard arrow */
- void (*gen) (GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag); /* generator function for type */
+ pointf (*gen) (GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag); /* generator function for type */
} arrowtype_t;
/* forward declaration of functions used in Arrowtypes[] */
-static void arrow_type_normal(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
-static void arrow_type_crow(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
-static void arrow_type_tee(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
-static void arrow_type_box(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
-static void arrow_type_diamond(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
-static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
-static void arrow_type_curve(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
-static void arrow_type_gap(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
+static pointf arrow_type_normal(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
+static pointf arrow_type_crow(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
+static pointf arrow_type_tee(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
+static pointf arrow_type_box(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
+static pointf arrow_type_diamond(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
+static pointf arrow_type_dot(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
+static pointf arrow_type_curve(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
+static pointf arrow_type_gap(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag);
static const arrowtype_t Arrowtypes[] = {
{ARR_TYPE_NORM, 1.0, arrow_type_normal},
}
}
-static void arrow_type_normal(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
+static pointf arrow_type_normal(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
{
(void)arrowsize;
gvrender_polygon(job, &a[2], 3, !(flag & ARR_MOD_OPEN));
else
gvrender_polygon(job, &a[1], 3, !(flag & ARR_MOD_OPEN));
+
+ return q;
}
-static void arrow_type_crow(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
+static pointf arrow_type_crow(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
{
pointf m, q, v, w, a[9];
double arrowwidth, shaftwidth;
gvrender_polygon(job, &a[3], 6, 1);
else
gvrender_polygon(job, a, 9, 1);
+
+ return q;
}
-static void arrow_type_gap(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
+static pointf arrow_type_gap(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
{
(void)arrowsize;
(void)penwidth;
a[0] = p;
a[1] = q;
gvrender_polyline(job, a, 2);
+
+ return q;
}
-static void arrow_type_tee(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
+static pointf arrow_type_tee(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
{
(void)arrowsize;
(void)penwidth;
a[0] = p;
a[1] = q;
gvrender_polyline(job, a, 2);
+
+ return q;
}
-static void arrow_type_box(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
+static pointf arrow_type_box(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
{
(void)arrowsize;
(void)penwidth;
a[0] = m;
a[1] = q;
gvrender_polyline(job, a, 2);
+
+ return q;
}
-static void arrow_type_diamond(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
+static pointf arrow_type_diamond(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
{
(void)arrowsize;
(void)penwidth;
gvrender_polygon(job, a, 3, !(flag & ARR_MOD_OPEN));
else
gvrender_polygon(job, a, 4, !(flag & ARR_MOD_OPEN));
+
+ return q;
}
-static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
+static pointf arrow_type_dot(GVJ_t * job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
{
(void)arrowsize;
(void)penwidth;
AF[1].x = p.x + u.x / 2. + r;
AF[1].y = p.y + u.y / 2. + r;
gvrender_ellipse(job, AF, !(flag & ARR_MOD_OPEN));
+
+ const pointf q = {p.x + u.x, p.y + u.y};
+
+ return q;
}
/* Draw a concave semicircle using a single cubic bezier curve that touches p at its midpoint.
* See http://digerati-illuminatus.blogspot.com.au/2008/05/approximating-semicircle-with-cubic.html for details.
*/
-static void arrow_type_curve(GVJ_t* job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
+static pointf arrow_type_curve(GVJ_t* job, pointf p, pointf u, double arrowsize, double penwidth, int flag)
{
(void)arrowsize;
else if (flag & ARR_MOD_RIGHT)
Bezier(AF, 3, 0.5, AF, NULL);
gvrender_beziercurve(job, AF, sizeof(AF) / sizeof(pointf), FALSE, FALSE, FALSE);
+
+ return q;
}
if (f == arrowtype->type) {
u.x *= arrowtype->lenfact * arrowsize;
u.y *= arrowtype->lenfact * arrowsize;
- (arrowtype->gen) (job, p, u, arrowsize, penwidth, flag);
- p.x = p.x + u.x;
- p.y = p.y + u.y;
+ p = (arrowtype->gen) (job, p, u, arrowsize, penwidth, flag);
break;
}
}