From fe996324d365f3a35e59dda8e10db5327de444e8 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sat, 8 Jan 2011 16:41:55 +0100 Subject: Take a better approach to drawing the grid. If the diagram is zoomed out too much, just use bigger steps between dots. --- src/ld-canvas.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ld-canvas.c b/src/ld-canvas.c index b008fb8..fdec62b 100644 --- a/src/ld-canvas.c +++ b/src/ld-canvas.c @@ -1072,11 +1072,13 @@ on_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) static void draw_grid (GtkWidget *widget, DrawData *data) { + gdouble grid_step; gdouble x_init, y_init; gdouble x, y; - if (data->scale < 2) - return; + grid_step = data->scale; + while (grid_step < 5) + grid_step *= 5; ld_canvas_color_apply (COLOR_GET (data->self, COLOR_GRID), data->cr); cairo_set_line_width (data->cr, 1); @@ -1090,10 +1092,10 @@ draw_grid (GtkWidget *widget, DrawData *data) /* Iterate over all the points. */ for (x = x_init; x <= data->exposed_rect.x + data->exposed_rect.width; - x += data->scale) + x += grid_step) { for (y = y_init; y <= data->exposed_rect.y + data->exposed_rect.height; - y += data->scale) + y += grid_step) { cairo_move_to (data->cr, x, y); cairo_line_to (data->cr, x, y); -- cgit v1.2.3-70-g09d2