summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-22 00:39:53 +0000
committerDavid Robillard <d@drobilla.net>2015-02-22 00:39:53 +0000
commit99b449b7e39f0a74b04f37c4abd74f20d05d87b2 (patch)
treea82f4e91c5f4d1d11b8c6ef12b106ecb378d304a /src
parent1e73d9839e79807324f6c002502411377b44e69e (diff)
downloadganv-99b449b7e39f0a74b04f37c4abd74f20d05d87b2.tar.gz
ganv-99b449b7e39f0a74b04f37c4abd74f20d05d87b2.tar.bz2
ganv-99b449b7e39f0a74b04f37c4abd74f20d05d87b2.zip
Improve appearance of graphs with circle nodes.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5596 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/circle.c15
-rw-r--r--src/edge.c32
2 files changed, 30 insertions, 17 deletions
diff --git a/src/circle.c b/src/circle.c
index fe2a54b..2863e7d 100644
--- a/src/circle.c
+++ b/src/circle.c
@@ -189,12 +189,13 @@ ganv_circle_vector(const GanvNode* self,
const double other_x = GANV_ITEM(other)->impl->x;
const double other_y = GANV_ITEM(other)->impl->y;
+ const double border = circle->node.impl->border_width;
const double xdist = other_x - cx;
const double ydist = other_y - cy;
const double h = sqrt((xdist * xdist) + (ydist * ydist));
const double theta = asin(xdist / (h + DBL_EPSILON));
const double y_mod = (cy < other_y) ? 1 : -1;
- const double ret_h = h - circle->impl->coords.radius;
+ const double ret_h = h - circle->impl->coords.radius - border / 2.0;
const double ret_x = other_x - sin(theta) * ret_h;
const double ret_y = other_y - cos(theta) * ret_h * y_mod;
@@ -296,19 +297,23 @@ ganv_circle_draw(GanvItem* item,
ganv_node_get_draw_properties(
&circle->node, &dash_length, &border_color, &fill_color);
+ // Fill
cairo_new_path(cr);
cairo_arc(cr,
x,
y,
- impl->coords.radius,
+ impl->coords.radius + (impl->coords.width / 2.0),
0, 2 * G_PI);
-
- // Fill
color_to_rgba(fill_color, &r, &g, &b, &a);
cairo_set_source_rgba(cr, r, g, b, a);
- cairo_fill_preserve(cr);
+ cairo_fill(cr);
// Border
+ cairo_arc(cr,
+ x,
+ y,
+ impl->coords.radius,
+ 0, 2 * G_PI);
color_to_rgba(border_color, &r, &g, &b, &a);
cairo_set_source_rgba(cr, r, g, b, a);
cairo_set_line_width(cr, impl->coords.width);
diff --git a/src/edge.c b/src/edge.c
index d2833e4..6b91d97 100644
--- a/src/edge.c
+++ b/src/edge.c
@@ -375,12 +375,6 @@ ganv_edge_draw(GanvItem* item,
cairo_curve_to(cr, src_x1, src_y1, src_x2, src_y2, join_x, join_y);
cairo_curve_to(cr, dst_x2, dst_y2, dst_x1, dst_y1, dst_x, dst_y);
- if (impl->coords.arrowhead) {
- cairo_line_to(cr, dst_x - 12, dst_y - 4);
- cairo_move_to(cr, dst_x, dst_y);
- cairo_line_to(cr, dst_x - 12, dst_y + 4);
- }
-
#ifdef GANV_DEBUG_CURVES
cairo_stroke(cr);
cairo_save(cr);
@@ -413,28 +407,42 @@ ganv_edge_draw(GanvItem* item,
cairo_restore(cr);
#endif
+ cairo_stroke(cr);
+ if (impl->coords.arrowhead) {
+ cairo_move_to(cr, dst_x - 12, dst_y - 4);
+ cairo_line_to(cr, dst_x, dst_y);
+ cairo_line_to(cr, dst_x - 12, dst_y + 4);
+ cairo_close_path(cr);
+ cairo_stroke_preserve(cr);
+ cairo_fill(cr);
+ }
+
} else {
// Straight line from (x1, y1) to (x2, y2)
cairo_move_to(cr, src_x, src_y);
cairo_line_to(cr, dst_x, dst_y);
+ cairo_stroke(cr);
if (impl->coords.arrowhead) {
const double ah = sqrt(dx * dx + dy * dy);
- const double adx = dx / ah * 10.0;
- const double ady = dy / ah * 10.0;
+ const double adx = dx / ah * 8.0;
+ const double ady = dy / ah * 8.0;
- cairo_line_to(cr,
+ cairo_move_to(cr,
dst_x + adx - ady/1.5,
dst_y + ady + adx/1.5);
- cairo_move_to(cr, dst_x, dst_y);
+ cairo_set_line_join(cr, CAIRO_LINE_JOIN_BEVEL);
+ cairo_line_to(cr, dst_x, dst_y);
+ cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);
cairo_line_to(cr,
dst_x + adx + ady/1.5,
dst_y + ady - adx/1.5);
+ cairo_close_path(cr);
+ cairo_stroke_preserve(cr);
+ cairo_fill(cr);
}
}
- cairo_stroke(cr);
-
if (impl->coords.handle_radius > 0.0) {
cairo_move_to(cr, join_x, join_y);
cairo_arc(cr, join_x, join_y, impl->coords.handle_radius, 0, 2 * G_PI);